> For the complete documentation index, see [llms.txt](https://docs.crystal.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.crystal.exchange/liquidity/vaults.md).

# Vaults

Deposit into the vault to earn 3x Crystals and a share of $3,750 in MON rewards.

A Crystal vault is a pool of quote and base assets that one operator trades on a single Crystal market. Depositors receive vault shares which are a proportional claim on everything the vault holds.

Vaults work like Uniswap V2 liquidity positions: you deposit both assets at the vault's current ratio, receive shares, and redeem shares for your slice of both assets at any time after your lockup ends.

### How It Works

| Role       | What they do                                           | What they control                                    |
| ---------- | ------------------------------------------------------ | ---------------------------------------------------- |
| Operator   | Creates the vault, seeds it, places and cancels orders | Strategy, deposit pause, lockup, deposit cap, market |
| Depositor  | Deposits both assets, holds shares, withdraws          | When to enter and exit                               |
| Governance | Sets protocol-wide limits                              | Max lockup, max order count, minimum initial deposit |

Governance can only set global defaults. It cannot move vault funds or trade on a vault's behalf.

### 1. Deposit

Every deposit must include both the quote asset and the base asset. The vault takes the two amounts at its current quote-to-base ratio and refunds the excess of whichever asset you over-supplied. Set minimum amounts to protect against the ratio moving before your transaction lands.

Shares are minted proportionally: if your deposit adds 10% to the vault's balances, you receive 10% of the new total supply.

ETH can be deposited directly. The factory wraps it into WETH for you.

Use `previewDeposit` to see the exact amounts and shares before sending a transaction.

Deposits are rejected when:

* the vault is **locked** or **closed**;
* the vault holds only one of its two assets (fully skewed after trading);
* the deposit would exceed the vault's deposit cap, if the operator set one.

### 2. Lockup

Each vault has a withdrawal lockup, set by the operator and capped by governance. After you deposit, your shares are locked for that duration.

**Every deposit resets your lockup.** Adding to an existing position restarts the clock on your entire balance, not just the new amount.

The lockup is per address and applies only to withdrawals. Shares are non-transferable.

### 3. Withdraw

Burn shares and receive your proportional amount of both assets. The calculation uses the vault's total balances, including funds locked in open orders, so your claim on in-flight orders is honored.

If the vault does not have enough free balance to pay you, it reduces the operator's open orders to free the funds. How much it reduces depends on the vault's decrease behavior:

| Mode                 | Behavior on withdrawal                                                        |
| -------------------- | ----------------------------------------------------------------------------- |
| Decrease on withdraw | Every open order shrinks by your withdrawal percentage                        |
| Default              | Orders on the short side shrink only as much as needed to cover the shortfall |

Either way you receive your full proportional amount. Set minimum amounts to guard against the balances shifting before execution.

Use `previewWithdrawal` to see what a given number of shares is worth now.

### 4. Operator Rules

The operator must hold **more than 5%** of the vault's total shares at all times. Deposits that would dilute the operator below 5% revert. The operator cannot reduce below 5% except by exiting entirely, which closes the vault.

The operator trades by sending batches of order actions directly to the vault. The operator can also:

* pause and resume new deposits;
* set or change the deposit cap;
* shorten or lengthen the lockup, up to the governance maximum;
* switch decrease behavior;
* cancel all orders;
* move the vault to the canonical market for its pair, which cancels all orders first.

The operator cannot transfer depositor funds anywhere except into orders on the vault's market. Withdrawals are always proportional, so the operator's exit pays them exactly their share.

Vault shares follow the ERC20 interface for balance reads but cannot be transferred or approved.
