> 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/zh/mechanics/deep-dives/liquidations-and-earn.md).

# 清算与收益池

清算债务抵销、抵押品分配和稳定池存款记账

清算关闭抵押率低于分支最低值 `MCR` 的 Trove。稳定池用已存 USDHN 抵销部分或全部债务并接收抵押品；剩余债务与抵押品再分配给同分支其他 Trove。

## 清算流程

抵押率按分支预言机价格和当前债务计算，含累计利息及再分配。

1. 调用者向 `TroveManager.batchLiquidateTroves` 提交 ID。
2. 合约检查 active 或 `zombie` Trove，清算严格低于 `MCR` 的仓位。
3. 关闭 Trove，从借款人活跃仓位中移除。
4. 稳定池可用存款抵销债务，销毁对应 USDHN 并接收分配抵押品。
5. 剩余债务和抵押品经 DefaultPool 再分配。
6. 清算人获得 Gas 补偿，借款人的剩余抵押品记入 CollSurplusPool 供领取。

稳定池不足时，Trove 仍关闭，剩余债务通过再分配移交其他 Trove。

## 稳定池承担多少债务

设 `pool` 为 USDHN 存款、`D` 为清算债务，使用超出 1 USDHN 的部分：

$$
\text{AvailableUSDHN} = \max(pool - 1, 0)
$$

$$
\text{DebtOffset} = \min(D, \text{AvailableUSDHN})
$$

存款不足 1 USDHN 时抵销为零。抵销少于债务时，其余进入再分配。

抵销路径初始按债务抵销比例分配 Trove 抵押品。合约扣除抵押品 Gas 补偿，再按分支稳定池清算罚金限制转入量。最终记录借款人剩余抵押品前，再分配路径可使用此阶段的余量。

池子接收分支抵押代币：KAIA 分支为 WKAIA，EarnUSDT 分支为 wEarnUSDT。

## 各参与方变化

| 参与方          | 变化                                 |
| ------------ | ---------------------------------- |
| 被清算借款人       | Trove 关闭，债务从该仓位移出，抵押品分配；已记录余量仍可领取。 |
| 稳定池存款人       | USDHN 存款按抵销比例减少，抵押品奖励增加。           |
| 其他 Trove 借款人 | 按 stake 比例接收债务和抵押品。                |
| 清算人          | 接收 Gas 补偿。                         |

稳定池存款没有借款仓位式的个人清算阈值。池子抵销清算债务时，各存款人的 USDHN 按池份额减少。

## 存款与抵押品记账

对单次事件定义：

* `pool`：抵销前全池 USDHN 存款。
* `you`：抵销前个人存款。
* `offset`：为抵销债务销毁的 USDHN。
* `collGain`：实际交付池子的抵押代币。

按比例计算：

$$
you\_{after} \approx you \times \left(1 - \frac{offset}{pool}\right)
$$

$$
yourCollateralGain \approx \frac{you}{pool} \times collGain
$$

合约用存款乘积 `P`、抵押累积器 `S` 和个人快照跟踪。USDHN 利息奖励用独立 `B`。链上整数除法向下取整，记账还包含 scale 变化。

以下排除利息奖励和他人新增存款；WKAIA 按 $2 估值。所列抵押收益为清算分配后实际到池数量。

### 示例 1：一次清算

| 项目    | 数量                |
| ----- | ----------------- |
| 清算前全池 | 10,000 USDHN      |
| 个人存款  | 1,000 USDHN，占 10% |
| 抵销债务  | 500 USDHN         |
| 抵押品入池 | 250 WKAIA，值 $500  |

个人存款变为 `1,000 × (1 − 500 / 10,000) = 950` USDHN，抵押奖励为 `10% × 250 = 25` WKAIA。

事件后持有 **950 USDHN 存款和 25 WKAIA 奖励**。

### 示例 2：连续两次清算

仍从全池 10,000、个人 1,000 USDHN 开始。

| 事件 | 全池清算前        | 个人清算前       | 抵销          | 池抵押收益     | 个人清算后     | 个人抵押收益   |
| -- | ------------ | ----------- | ----------- | --------- | --------- | -------- |
| 1  | 10,000 USDHN | 1,000 USDHN | 500 USDHN   | 250 WKAIA | 950 USDHN | 25 WKAIA |
| 2  | 9,500 USDHN  | 950 USDHN   | 1,900 USDHN | 950 WKAIA | 760 USDHN | 95 WKAIA |

第二次消耗剩余存款的 20%：

$$
950 \times \left(1 - \frac{1{,}900}{9{,}500}\right) = 760
$$

两次后持有 **760 USDHN 存款和累计 120 WKAIA 奖励**，抵押奖励继续以 WKAIA 单独记账。

### 示例 3：两次清算间追加

从全池 10,000、个人 1,000 USDHN 开始。

1. 抵销 200 USDHN，入池 100 WKAIA。个人存款 980、奖励 10 WKAIA，全池 9,800 USDHN。
2. 追加 500 USDHN，个人 1,480，全池 10,300 USDHN。
3. 下次抵销 2,060 USDHN，入池 1,030 WKAIA。

新的存款与抵押收益：

$$
1{,}480 \times \left(1 - \frac{2{,}060}{10{,}300}\right) = 1{,}184
$$

$$
\frac{1{,}480}{10{,}300} \times 1{,}030 = 148\ \text{WKAIA}
$$

两次后持有 **1,184 USDHN 存款和累计 158 WKAIA 奖励**。追加存款改变了第二次清算前的个人份额。

## USDHN 利息奖励

ActivePool 铸造分支汇总利息和一次性费用，将稳定池份额发送入池。`triggerUSDHNRewards` 将其加入奖励记账。

奖励与清算后剩余存款单独累计。池存款低于 1 USDHN 时，新收益暂存，直到达到分配阈值。

| 操作                         | USDHN 奖励                              | 抵押奖励                                       |
| -------------------------- | ------------------------------------- | ------------------------------------------ |
| 存取时 `claimRewards = true`  | 发到钱包                                  | 发到钱包，含此前记录部分                               |
| 存取时 `claimRewards = false` | 加入存款                                  | 记入 `stashedColl` 待领                        |
| 有存款时领取                     | `withdrawFromSP(0, true)` 发出 USDHN 奖励 | 同一调用发出抵押奖励                                 |
| 有存款时再存                     | `withdrawFromSP(0, false)` 加入存款       | 保留池内记录                                     |
| 无存款时领取抵押品                  | 个人 USDHN 存款保持为空                       | `claimAllCollGains()` 将 `stashedColl` 发到钱包 |

通过 `withdrawFromSP` 提取、领取或再存时，全池须保留至少 1 USDHN。

## 收益为何变化

利息奖励取决于借款债务、利率和池存款规模。清算结果取决于抵销量和收到的抵押品，其市场价值随价格与退出流动性变化。

分别跟踪剩余 USDHN 存款、USDHN 奖励和抵押品奖励。操作见[USDHN 与 Earn](/zh/protocol/usdhn-and-earn.md)，借款人仓位见[借款与清算](/zh/protocol/borrowing-and-liquidation.md)，市场、合约和预言机风险见[风险披露](/zh/security/risk-disclosure.md)。


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hann.finance/zh/mechanics/deep-dives/liquidations-and-earn.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
