> 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/redemptions.md).

# 赎回

赎回分配、利率顺序、费用计算和抵押率变化

普通赎回销毁 USDHN，减少所选 Trove 债务。赎回人收到扣费后的抵押品，费用留在 Trove。CollateralRegistry 跨分支分配数量，各 TroveManager 选择仓位。

## 分支分配

分支需启用、未关闭，且总抵押率 `TCR` 至少达到关闭抵押率 `SCR`。

对合格分支 `j`：

$$
u\_j = \max(\text{BranchDebt}\_j - \text{SPDeposits}\_j, 0)
$$

这是超出稳定池存款的债务，仍由 Trove 抵押品支持。

若 `u_j` 总和为正，请求量以上述总和为上限，按 `u_j` 比例分配；若所有合格分支 `u_j = 0`，改按分支总债务。

忽略整数除法时：

$$
A\_j = A \times \frac{w\_j}{\sum\_k w\_k}
$$

`A` 为限额后数量，`w_j` 为 `u_j` 或备用情况下的分支债务。合约按注册顺序处理，每次分配后重新计算剩余数量与权重，整数余量在后续分配处理。

![25 USDHN 按超出稳定池存款的债务权重，以 40%、20%、40% 分给三个分支。](https://2468384826-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNSloZoJik3NAsr6vrfDs%2Fuploads%2Fgit-blob-479973ac12180c4a5e8df8b43b53359878996bac%2Fredemption-allocation.svg?alt=media)

蓝色代表分支债务，青柠色代表稳定池 USDHN，虚线部分为超出存款的债务。

**示例：25 USDHN。** 三个分支债务为 150、100、170 USDHN，稳定池存款为 50、50、70，权重为 100、50、100。赎回分配为 10、5、10 USDHN。稳定池存款保持原量，赎回人接收扣费抵押品。

## 分支内 Trove 顺序

普通路径：

1. 检查 `lastZombieTroveId`，即此前赎回留下小额债务的记录仓位。
2. 从 `SortedTroves.getLast()` 沿 `getPrev()` 按**年利率从低到高**遍历。
3. 跳过按普通预言机价格计算 CR 低于 100% 的 Trove。
4. 应用累计利息和再分配，再计算可赎回债务。
5. 取剩余分配 USDHN 与仓位债务的较小值。

![赎回 250,000 USDHN，使 4% Trove 债务从 200,000 变为零，4.3% Trove 从 60,000 变为 10,000；4.4% Trove 保持 450,000。](https://2468384826-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNSloZoJik3NAsr6vrfDs%2Fuploads%2Fgit-blob-e0f4a420ccac0700e6d805dc0fe1d0af4c9fa1bd%2Fredemption-order.svg?alt=media)

**示例：某分支分到 250,000 USDHN。** 4% 仓位提供全部 200,000，4.3% 仓位再提供其 60,000 中的 50,000，剩余 10,000；4.4% 仓位保持原状。

可选迭代上限计入所有遍历仓位，包括跳过者。`0` 取消上限。分配量用完或列表结束时循环停止。

借款人自行设置利率或使用管理人。提高利率推后顺序并增加成本。同管理人的仓位使用批量利率。

## 赎回费

费率由最低费与基础费率组成，以下以比例表示：

* `b`：存储的基础费率。
* `m`：上次费用操作以来的整分钟数。
* `A`：分支限额后的尝试量。
* `S`：交易开始时 USDHN 总供应。
* `λ = 0.998076443575628800`：每分钟衰减因子。
* `β = 1`：赎回增量除数。
* `f₀ = 0.005`：0.5% 最低费率。

$$
b\_{decayed} = b\lambda^m
$$

$$
b\_{quote} = \min\left(1, b\_{decayed} + \frac{A}{\beta S}\right)
$$

$$
f = \min(1, f\_0 + b\_{quote})
$$

衰减半衰期为 6 小时。Registry 部署时基础费率从 100% 开始，随时间衰减。链上使用整数定点运算。

赎回前检查 `f` 是否超过调用者上限；执行后以**实际赎回量**更新基础费率。因此，受迭代限制的部分赎回可能支付按更大尝试量报价的费率。

Registry 提供 `getRedemptionRateWithDecay()`、`getRedemptionRateForRedeemedAmount(amount)`、`getEffectiveRedemptionFeeInUSDHN(amount)`，取决于供应、费率、时间和数量。

## 到账抵押品与留存费用

设：

* `r`：在单个 Trove 上赎回的 USDHN。
* `pᵣ`：分支每抵押代币的赎回价格。
* `f`：赎回费率。

按归一化单位：

$$
\text{CorrespondingCollateral} = \frac{r}{p\_r}
$$

$$
\text{CollateralFee} = \frac{r}{p\_r}f
$$

$$
\text{CollateralSent} = \frac{r}{p\_r}(1-f)
$$

债务减少 `r`，抵押品减少 `CollateralSent`，`CollateralFee` 留在 Trove。合约用 `fetchPrice()` 检查 100% 资格，以 `fetchRedemptionPrice()` 计算输出。

普通价格 `p`、抵押价值 `V`、债务 `D` 下，新比率为：

$$
CR' = \frac{V-r(1-f)p/p\_r}{D-r}
$$

要求 `r < D`。全额赎回时债务归零，剩余抵押品保留。

## 抵押率示例

以下固定普通价格与赎回价格相等，费用和利息为零，抵押价值和债务均减少 `r`：

$$
CR' = \frac{V-r}{D-r}
$$

对 `V > D`、`0 < r < D`：

$$
CR' - CR = \frac{r(V-D)}{D(D-r)} > 0
$$

抵押品和债务同时减少，抵押率提高。

### 示例 1：一次赎回

起点 `V = $200`、`D = 100` USDHN，`200 / 100 = 200%`。

赎回 20 后 `V′ = $180`、`D′ = 80`：

$$
CR' = \frac{180}{80} = 225%
$$

抵押缓冲提高，仓位变小。若计入费用且两价格相等，留存费用还会增加相对无费用示例的抵押品。

### 示例 2：赎回后借款

从 `V = $180`、`D = 80`、`CR = 225%` 出发，保持抵押数量并再借 40，债务增至 120：

$$
CR = \frac{180}{120} = 150%
$$

新增借款使用了赎回产生的抵押率缓冲。

### 示例 3：赎回后跌价

仍从 `V = $180`、`D = 80` 出发，价格下跌 40%，价值变为 `180 × 0.6 = $108`：

$$
CR = \frac{108}{80} = 135%
$$

`MCR > 135%` 的分支可清算该仓位；`MCR = 135%` 时，继续下跌即低于阈值。赎回减少债务后，抵押品仍承担价格风险。

## 小额或全额赎回债务

普通赎回后低于 `MIN_DEBT`，Trove 变为 `zombie` 并移出 SortedTroves。非零余额可记入 `lastZombieTroveId` 供下次处理。全额赎回后债务为零，剩余抵押品仍属于该 Trove。

关闭可取回抵押品。仍有小额债务的仓位可通过合格调整恢复 active。

## Helper 与关闭分支路径

`RedemptionHelper` 从调用者转入 USDHN，调用 registry，检查 `_minCollRedeemed` 中各资产最低量，转出抵押品并退款，需要 USDHN 授权。应用直接使用 registry 从调用者销毁，无需授权额度。

关闭分支支持 `TroveManager.urgentRedemption(amount, troveIds, minCollateral)`。调用者指定 ID，按指定仓位处理。当前合约给 2% 抵押奖励，以上限为可用抵押品，普通赎回费为零，并检查传入的最低输出。

操作见[赎回与风险](/zh/protocol/redemptions-and-risk.md)，抵押率见[CDP 抵押条件](/zh/mechanics/deep-dives/cdp-safety.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/redemptions.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.
