Loan Auto-close

One click loan close without requiring any asset in your wallet

Hubble's auto-close feature is a quality-of-life feature on the protocol that enables users to settle their loans without having USDH or collateral on hand. In short, auto-close means that, should a user have their USDH deployed elsewhere, they can still close their position and withdraw their remaining collateral.

At present, this is available for all loans with one asset as collateral. Eg. only SOL, or only mSOL, not both.

Auto-close is facilitated by flash loan transaction that contain numerous instructions. Specifically, the auto-close steps occur as follows:

  1. A flash loan is initiated, in USDH, from a general-purpose lending market. Now we have an open loan that we need to repay before the end of current transaction. The borrowed amount is equal to the debt that the Hubble loan has.

  2. This newly borrowed USDH is used to repay your Hubble debt. Now the Hubble loan has no more debt.

  3. With Hubble debt rapid, your total collateral is all withdrawn (and your loan is now closed).

  4. Part of withdrawn collateral is swapped to USDH using Jupiter in order to to repay the original loan taken in Step 1 (including fees). You will have remaining collateral (essentially the net equity) that will stay in your wallet.

  5. The USDH from Step 4 is used to pay the debt taken at Step 1 (including fees). The flash loan is now closed. The rest of your collateral is returned to you.

The loan will now be closed, and the flash loan repaid. All of this happens when a user clicks the "Close Loan" button, all within a single atomic transaction.

Note: flash-loan fees are typically 0.3% of the borrowed amount.

Auto-close Example (with Illustrations)

Step 1:

User has a loan with:

  • $25.77 collateral, stSOL only

  • 10.05 USDH Debt

  • 0 USDH in Wallet

  • $16.25 Total In wallet + $15.72 Equity Value on Loan = $31.97 Net Value

Step 2:

  • User enters loan management interface and navigates to dropdown

Step 3:

User Clicks to Close Loan

  • Flash loan is initiated at this point

  • Steps 1 - 5, mentioned above, take place

  • After confirming in wallet, user receives a combination of stSOL, USDH, and SOL

Step 4:

Loan is Closed

  • Debt is repaid, and collateral withdrawn

  • Total Equity = $32.24

Last updated