> For the complete documentation index, see [llms.txt](https://docs.hann.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hann.finance/mechanics/deep-dives/looping-and-leverage.md).

# Leverage

Derivations for leveraged collateral exposure, equity, CR, liquidation price, and repayment cost.

A leveraged Trove holds more collateral than the initial deposit funds on its own. USDHN debt finances the additional exposure. The app's flash-assisted transaction changes the position once and settles its temporary liquidity in that transaction; the resulting USDHN debt continues to accrue interest.

## Borrow, swap, and add collateral

A manual loop repeats these actions:

1. Borrow USDHN against collateral.
2. Swap USDHN into more of the branch's collateral.
3. Add that collateral to the same Trove.

Both posted collateral and debt increase. When the extra debt grows faster than the collateral's value, CR falls. The leverage zapper combines the required collateral and debt changes through the branch's configured pools.

The mainnet app supports KAIA and earnUSDT leverage. HNKAIA leverage is exposed in the testnet app. A Trove opened through a leverage zapper retains the same branch's collateral, interest, redemption, and liquidation rules.

## Equity and leverage

Let:

* `V` be the collateral value in dollars.
* `D` be the USDHN debt, including principal, accrued interest, and charged fees, valued at `$1` per USDHN for this calculation.
* `E = V − D` be equity in this valuation.

For `E > 0`, collateral exposure per dollar of equity is:

$$
L=\frac{V}{E}=\frac{V}{V-D}
$$

Without debt, `L = 1`. At `L = 2`, one dollar of equity supports two dollars of collateral exposure. Fees, liquidation penalties, and the cost of exchanging assets are additional deductions from realized proceeds.

If the market price of one USDHN is `p`, mark-to-market equity before execution costs is `V − pD`. The protocol's collateral-ratio calculation and the market cost of buying USDHN for repayment are separate quantities.

## Converting CR to leverage

For `D > 0`, the collateral ratio is:

$$
CR=\frac{V}{D}
$$

Use a ratio such as `2.0` for `200%`. For `CR > 1`:

$$
L=\frac{V}{V-D}
\=\frac{1}{1-D/V}
\=\frac{1}{1-1/CR}
\=\frac{CR}{CR-1}
$$

| CR           | Leverage under this valuation |
| ------------ | ----------------------------- |
| `300% = 3.0` | `1.5×`                        |
| `200% = 2.0` | `2.0×`                        |
| `150% = 1.5` | `3.0×`                        |

At `CR = 1`, equity is zero and this leverage expression is undefined. Lower CR above that boundary means greater leverage and a smaller collateral-value buffer.

## Liquidation-price relationship

Let `Q > 0` be the collateral quantity, `P` its unit price, `D > 0` the debt, and `MCR` the branch's minimum collateral ratio. With quantity and debt fixed:

$$
CR=\frac{QP}{D},\qquad
P\_{liq}=\frac{MCR\cdot D}{Q}
$$

Substituting the current collateral ratio gives:

$$
P\_{liq}=P\_{now}\frac{MCR}{CR\_{now}}
$$

The equality describes the threshold with fixed debt and collateral and the same price-feed valuation. Accrued interest, a redemption, or a position adjustment changes those inputs. The actual liquidation condition uses the branch's current price and CR rules.

Increasing leverage lowers CR, which moves the threshold closer to the current price. [CDP collateral ratios](/mechanics/deep-dives/cdp-safety.md) covers the branch thresholds and their calculation.

## A worked position

Use an initial collateral deposit worth `$1,000`, a final CR of `200%`, USDHN priced at `$1`, and no interest, fees, or swap price impact in this calculation.

Since `L = 2/(2 − 1) = 2`, the resulting position has:

| Quantity             | Calculation       | Value         |
| -------------------- | ----------------- | ------------- |
| Collateral value `V` | `2 × $1,000`      | `$2,000`      |
| Debt `D`             | `$2,000 / 2`      | `1,000` USDHN |
| Equity `E`           | `$2,000 − $1,000` | `$1,000`      |

If the collateral price falls `20%` while quantity and debt stay fixed:

* Collateral value falls to `$1,600`.
* Debt remains `1,000` USDHN.
* CR falls to `160%`.
* Equity falls to `$600`: a `40%` loss on the initial equity.

Whether the Trove is liquidatable at that point depends on its branch's MCR. A yield-bearing collateral asset can accrue value while the debt accrues interest; both affect the next position value.

## Increase, decrease, and close

| Action                 | Settlement                                                                            | Position after success                                             |
| ---------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| Increase leverage      | Acquire more collateral and borrow USDHN to settle temporary liquidity.               | More collateral and more debt.                                     |
| Decrease leverage      | Use temporary liquidity to repay debt and spend part of the collateral to settle it.  | Less collateral and less debt.                                     |
| Close with USDHN       | Pay the entire live debt from the wallet.                                             | No open Trove; collateral is returned.                             |
| Close using collateral | Repay the live debt with temporary liquidity and use collateral for flash settlement. | No open Trove; remaining collateral and route tokens are returned. |

A partial repayment must preserve the branch's minimum debt. Full repayment uses the close operation. The KAIA branch unwraps returned WKAIA to KAIA; the earnUSDT route unwraps wEarnUSDT collateral to earnUSDT for settlement and returns the remainder.

Opening and leverage adjustments enforce `maxDebt`. A collateral-funded close carries `troveId` and `profitReceiver`, without a user-specified minimum output. The app shows `100%` slippage for that close. Its return estimate does not bound the actual settlement cost.

## Repayment price and exit liquidity

For a debt of `1,000` USDHN:

| USDHN market price | Cost to buy `1,000` USDHN before swap fees |
| ------------------ | ------------------------------------------ |
| `$1.02`            | `$1,020`                                   |
| `$0.98`            | `$980`                                     |

A larger debt increases the dollar effect of a USDHN price change. A collateral-funded close also depends on both the collateral route and the USDHN/USDT pool being able to settle the required amounts.

Interest raises debt over time, even with a flat collateral price. A stressed pool can increase price impact, require more collateral for repayment, or make the transaction revert. A revert preserves the Trove state; it does not reverse earlier approvals or refund the failed transaction's network fee.

An LST or receipt token returned on closing keeps its own withdrawal rules. In particular, bKAIA withdrawal requires a withdrawal request and later collection when the ticket is ready. A secondary-market sale has a different liquidity-dependent price. [bKAIA and HNKAIA](/protocol/bkaia-and-hnkaia.md) describes those paths.

[Leverage positions](/protocol/loops.md) gives the app procedure. [StableSwap mechanics](/mechanics/deep-dives/stableswap.md) explains swap bounds and pool-price effects, and [Zappers](/protocol/zapper.md) covers manager permissions and returned tokens.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hann.finance/mechanics/deep-dives/looping-and-leverage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
