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

# Vault

The protocol vault is MegaTAO's liquidity layer. It provides instant execution for all trades and acts as the counterparty when there is no orderbook match.

## How the vault works

When a trader opens a position:

1. The order is first sent to the orderbook for matching
2. If no match is found, the protocol vault fills the order directly
3. Execution is instant, no waiting for a counterparty

This hybrid model combines the price discovery of an orderbook with the guaranteed liquidity of a vault.

## Vault deposits

Liquidity providers can deposit TAO into the vault to earn yield from:

* Trading fees (0.25% of notional value on each trade)
* Funding payments when the vault holds net positions
* Liquidation fees (5% of remaining margin on liquidated positions)

The vault takes on the opposite side of trader positions. When traders profit, the vault's value decreases. When traders lose, the vault's value increases.

## Vault utilization

The protocol monitors vault utilization to manage risk:

* When utilization is high, the vault's capacity to take on new positions is reduced
* Maximum aggregate exposure is capped to prevent excessive risk
* Per-market limits ensure no single market can dominate vault exposure

## Insurance fund

A portion of fees is directed to an insurance fund that covers bad debt from positions that become insolvent before liquidation can execute. This protects vault depositors from losses due to extreme market moves.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.megatao.com/core/vault.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
