Baker DAO
Baker DAO
  • documentation
    • Introduction
    • $BREAD Rises
  • What makes BakerDAO Unique
  • Pre-Deposit Vaults and Whitelists
  • Mechanics
    • Baking and Burning
    • Loans
    • Looping
    • Borrowing vs Looping
    • Interest Fees
    • Staking
  • Contract Addresses
  • The Bakery
    • BreadGT
    • Pooled Baking
    • BreadBox
    • Auto TWAP
    • iBREAD
    • GameFi
  • Security
  • User Guide
    • Using the Bake/Burn Page
    • Borrowing with $BREAD Collateral
    • How to use Looping
    • Repaying Loans
  • Links
    • Website
    • Twitter/X
  • Telegram
  • Legal
    • Terms and Conditions
    • Privacy Policy
Powered by GitBook
On this page
  • Leveraged borrowing
  • One-click looping
  • Solidity implementation
  • Flash Burn
  1. Mechanics

Looping

For the degens and Yeetards

PreviousLoansNextBorrowing vs Looping

Last updated 2 months ago

Using leverage carries risks. It is possible to lose all of your collateral if you do not pay back your loan in time.

Leveraged borrowing

  • Advanced Feature: Users can borrow $BERA against their $BREAD, use the borrowed $BERA to bake or buy more $BREAD, and repeat this process; i.e., looping

  • UI Support: A user friendly interface on the BakerDAO website facilitates looping in one transaction, making it quick and simple to open and unwind leveraged positions

  • Fee Discount: The $BREAD baking fee is discounted from 2.69% to 1.42% when opening leveraged positions

  • Liquidation: If a leverage position defaults, then the $BREAD collateral is burned, causing the ratio of $BERA per $BREAD to increase. $BREAD collateral from liquidated positions are burned collectively, every day, at 00:00 UTC

Important Note: You can only have one active loan position at a time in BakerDAO. If you already have a Standard loan, you cannot create an automated looped position (and vice versa) until you close your existing position

Using looping allows users to create leveraged $BREAD exposure. If a position is max looped, no more liquid $BERA may be borrowed against the position due to diminishing amount of $BERA being used each loop.

One-click looping

In order to facilitate easier opening of looped positions, users can open max looped positions in one click which utilize flashloans to create the position in a single transaction. This allows users to easily open and close leveraged positions, and baking fees are reduced from 2.69% to 1.42% for these transactions.

Solidity implementation

    /// @notice Calculates the leverage fee for a loan
    /// @param bera Amount of BERA to borrow
    /// @param numberOfDays Duration of the loan in days
    function loopCalcs(uint256 bera, uint256 numberOfDays) public view returns (uint256 bakeFee, uint256 userBorrow, uint256 overCollateralizationAmount, uint256 interest) {
        bakeFee = bera * leverageFeeBps / BPS_DENOMINATOR;
        uint256 userBera = bera - bakeFee;
        userBorrow = userBera * COLLATERAL_RATIO / BPS_DENOMINATOR;
        overCollateralizationAmount = userBera - userBorrow;
        interest = getInterestFee(userBorrow, numberOfDays);
    }

Flash Burn

This functionality allows users to close a position using the $BREAD collateral itself without needing to acquire additional $BERA. To use this, select "Existing Collateral" in the repayment modal.

When you choose "Existing Collateral", the following process occurs:

  1. Collateral Valuation: The system calculates the current value of your BREAD collateral in terms of BERA based on the protocol's backing ratio.

  2. Burn Fee Application: A 2.69% burn fee is applied to your BREAD's valuation, reducing the effective value.

  3. Debt Settlement: The remaining value (after the fee) is used to settle your outstanding loan.

  4. Excess Value Check: The system determines if there's any value left after repaying the loan:

    • If the remaining value exceeds the loan amount, the excess is returned to you as BERA.

    • If the remaining value is less than or equal to the loan amount, nothing is returned (the entire collateral value is consumed).