> For the complete documentation index, see [llms.txt](https://syntheticrealities.gitbook.io/white-paper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://syntheticrealities.gitbook.io/white-paper/theta-vaults/theta-vaults-architecture.md).

# Theta vaults architecture

## Vault flow example

<figure><img src="https://3892452927-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4C4inEd86LAr6PST2zXH%2Fuploads%2FOTiUnIS0tTaVnVCPKHkU%2Fimage.png?alt=media&amp;token=b2532be5-87b5-4364-81cc-6acc0060e9f3" alt=""><figcaption></figcaption></figure>

* User deposits 100 BNB into T-BNB-C (BNB call).
* On Friday 8 am UTC, the vault closes the previous week round and subsequently uses 100% of its funds to mint 100 otokens, which are ERC20 representations of options contracts. The 100 BNB is locked for a week in Opyn.
* After receiving the 100 otokens, the vault puts it up for auction on Paradigm.
  * Registered users can participate and bid on the otokens. They pay the premiums for the otoken in BNB. Paradigm can use different kinds of auctions to maximise depositors' returns (e.g. blind auctions)
  * At the end of the auction, the vault collects 1 BNB in premiums in the form of BNB.
  * Any remaining otokens that are not bought are burned, redeeming 1 otoken for 1 unit of collateral from Opyn.
* On the next Friday 8 am UTC,
  * If the options expire in the money, the vault withdraws less than 100 BNB from Opyn.
  * If the options expire out the money, the vault withdraws exactly 100 BNB.
* Let's say it expires out the money. The vault repeats step 2 with 101 BNB (original 100 BNB + 1 BNB premium).

### **Standard withdrawals**

* Withdrawals are created with the `initiateWithdraw` function, which queues the shares to be burned.
* Withdrawals are completed with `completeWithdraw` function, which burns the shares, and returns the assets.
* Users can only call `completeWithdraw` only AFTER the week's Friday 10am UTC. For example, the user calls `initiateWithdraw` on Wednesday. They can only complete the withdrawal after the same week's Friday 10am UTC.
* Withdrawals stack on top of each other. This means that if I do `initiateWithdraw(10)`, and I do `initiateWithdraw(20)` again, I will have a total withdrawal of 30 shares by Friday.

### **Instant withdrawals**

* Instant withdrawals are only accessible to funds that are deposited mid-week.
* For example, user deposits 10 ETH into TV on Wednesday. They can call `withdrawInstantly` to return up to 10 ETH, from Wednesday till Friday.

## Share Redemption Flow

<figure><img src="https://3892452927-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4C4inEd86LAr6PST2zXH%2Fuploads%2FbAAa3jOhqDKV6o6Nqqfy%2Fimage.png?alt=media&amp;token=ec4e644c-1fbd-4338-b41f-00550341b163" alt=""><figcaption></figcaption></figure>

As mentioned before, when the user deposits into the vault, the vault mints and holds custody of the user's shares on `address(this)`. This is not ideal for protocols or Meta-Vaults that want to hold custody of their shares. By calling the `redeem` or `maxRedeem` function, contracts are able to take custody of their vault shares.

The share redemption flow is also triggered implicitly when users call `initiateWithdraw`.

## Access Control

| Name  | Privileges                                                                                                                                                                                                                                          |
| ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Owner | <p>The owner can set key parameters of the vault such as feeRecipient, performanceFee, managementFee, deposit cap etc.</p><p>Some functions in the vault's lifecycle is only limited to the owner, such as commitAndClose and rollToNextOption.</p> |
| Admin | The admin can upgrade the proxy's implementation address.                                                                                                                                                                                           |

Both of these privileged roles use a multisig wallet.
