# Caretaker Module

The Caretaker module is responsible for deprecating the entire protocol, and particularly the Shrine,  in a graceful manner by allowing `yin` holders to claim collateral backing their `yin`. Note that, in the future, other modules may have their own shutdown mechanisms that fall outside the purview of the Caretaker.

## Description of key functions

* `shut`: permanently disables user actions for the Shrine and transfers a percentage of the collateral backing the prevailing total troves' debt to the Caretaker
* `release`: allow trove owners to withdraw all collateral from their trove after `shut` has occurred
* `reclaim`: allow `yin` holders to burn `yin` and receive a percentage of the collateral in the Caretaker, up to the total troves' debt, after `shut` has occurred.&#x20;

## Shutdown

<figure><img src="/files/r7nzqCRDNc8sgC8K5dge" alt=""><figcaption></figcaption></figure>

Once `shut` is executed, all troves' debt cannot be repaid, and all collateral that is needed to back the value of the total amount of debt forged by troves is transferred from the Shrine to the Caretaker. Anyone may then subsequently burn `yin` to claim a proportional percentage of this collateral, up to the total amount of the troves' debt that the Caretaker is supposed to back. The total troves' debt at the time of shutdown is stored in the Caretaker, and is gradually decremented as users call `reclaim`.

The transfer of collateral at the time of shutdown acts as a final system-wide redistribution on all trove owners because the same percentage of all `yang`s are transferred to the Caretaker.

* This also means that if the total value of `yang`s in the Shrine is less than the total amount of troves' debt, then there would be no collateral remaining for trove owners to withdraw because the entire amount of `yang`s will be used to back the circulating `yin` representing the total amount of troves' debt.

At the time of `shut`, there may be troves with unaccrued interest. This means that for each trove, the `Trove.debt` value in storage will be taken to be the amount of debt for that `Trove` , and collectively the prevailing total troves' debt in Shrine would similarly exclude all unaccrued interest. This may result in a permanent loss of income for the allocated recipients because they would otherwise have been minted as debt surpluses via the Equalizer. This design is intended as the alternative to charge interest on all troves may be too expensive.

In addition, the protocol owned `yang` amounts are rebased to zero to the benefit of all trove owners. Note that in the initial transfer of collateral to the Caretaker, the total backing is calculated with the protocol owned `yang` amounts included, which means that a proportional amount of the underlying assets of the protocol owned `yang` amounts were also transferred to the Caretaker, to the benefit of yin holders. Therefore, this subsequent rebasing ensures that both yin holders and trove owners are treated fairly.

## Redeeming \`yin\` for assets

<figure><img src="/files/jhWIQ13kuKwsqBI21ew6" alt=""><figcaption></figcaption></figure>

After `shut`, `yin` holders may exchange their `yin` for a percentage of the collateral assets in the Caretaker. The amount of assets a `yin` holder is entitled to is proportional to the remaining amount of `yin` that is reclaimable. Users may rely on `preview_reclaim` to determine the amount of assets they are entitled to for a given `yin` amount.

## Withdrawing remaining collateral from troves

<figure><img src="/files/crwjR64VGJnIf5zFDfIa" alt=""><figcaption></figcaption></figure>

After `shut`, trove holders may withdraw all remaining collateral in their troves. Due to the system-wide redistribution during `shut`, the amount of collateral remaining for withdrawal will likely be a fraction of what was deposited in the trove prior to `shut`. Trove owners may rely on `preview_release` to determine the amount of assets they are entitled to withdraw from their trove.


---

# Agent Instructions: 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:

```
GET https://docs.opus.money/current/technical-documentation/smart-contracts/caretaker-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
