> For the complete documentation index, see [llms.txt](https://docs.shiftctrl.money/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shiftctrl.money/developer/tab-protocol-smart-contract/vault.md).

# Vault

## VaultManager contract

The VaultManager contract is the core component of the Tab Protocol, responsible for managing and executing various vault operations:

1. **createVault:** Create a vault for depositing reserves into the protocol and minting Tabs from the deposited reserves. The QWERTY application retrieves the signed median rate from an authorized source and submits it to the `createVault` function.

{% hint style="info" %}
**Note:** Before calling the createVault function, the QWERTY application will invoke the`approve`function on the reserve token to grant sufficient allowance to the VaultManager.
{% endhint %}

2. **withdrawTab:** Mint additional Tabs from the user's vault. The signed median rate is included in the submission.
3. **paybackTab:** Burn Tabs from the user's wallet to reduce the outstanding Tab balance of the user's vault.

{% hint style="info" %}
**Note:** Before calling the paybackTab function, the QWERTY application will invoke the`approve`function on the Tab token to grant sufficient allowance to the VaultManager.
{% endhint %}

4. **withdrawReserve:** Withdraw reserves from the user's vault. The signed median rate is included in the submission.
5. **depositReserve:** Deposit additional reserves into the user's vault.

{% hint style="info" %}
**Note:** Before calling the depositReserve function, the QWERTY application will invoke the `approve` function on the reserve token to grant sufficient allowance to the VaultManager.
{% endhint %}

### chargeRiskPenalty function

The Tab Keeper module continuously monitors the reserve ratios of all vaults. If a vault's reserve ratio falls below the configured threshold, the system calculates the corresponding risk penalty and adds it to the vault's outstanding Tab balance.

If unaddressed, this risk penalty can further deteriorate the vault's reserve ratio, potentially leading to liquidation, especially if the market value of the reserve assets continues to decline.

To improve the reserve ratio of an existing vault, users can either use the `paybackTab` function to reduce the vault's outstanding Tab balance or the `depositReserve` function to increase the vault's reserve amount.

### liquidateVault function

When a vault's reserve ratio drops below the liquidation threshold (default 120%), the system triggers a liquidation process via the `liquidateVault` function. The vault's assets are auctioned off to cover the outstanding Tabs.&#x20;

Any excess reserves remaining after the auction are returned to the vault. The vault owner can then use the `withdrawReserve` function to claim the remaining reserves.

### ctrlAltDel function

The ShiftCTRL Tab Protocol community has the option to propose and vote to de-peg a Tab from its fiat currency to Bitcoin using the `ctrlAltDel` function.

Once the community successfully executes a Ctrl-Alt-Del de-peg, matching value of reserves are transferred into ProtocolVault contract, and excess reserves remain in their respective vaults. \
These vaults remain open until the vault owner claims the excess reserves using the `withdrawReserve` function.

## ProtocolVault contract

Following a successful Ctrl-Alt-Del de-peg action, a new Protocol Vault is created to consolidate the reserves from all de-pegged Tab vaults. The protocol then manages all future Tab minting and burning actions based on the newly defined BTC peg (e.g., 1 BTC : 55,000,000 sARS).

### buyTab function

The `buyTab` function allows users to mint Tabs by depositing reserves into the protocol vault.

{% hint style="info" %}
**Note:** Since the BTC peg is fixed and does not fluctuate, there is no need for excess reserves. \
Metrics such as minimum reserve ratios, liquidation thresholds, and risk penalties do not apply to Tabs that have been successfully de-pegged.
{% endhint %}

### sellTab function

The `sellTab` function enables users to withdraw BTC reserves from the protocol vault by burning their Tabs, based on configured conversion rate.
