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

# Codebase

Perennial V2 has been designed to be as modular as possible, allowing for horizontal scaling to many markets, oracles & vaults.&#x20;

### Ownership Hierarchy&#x20;

In terms of structure, the protocol owns three factories covering Markets, Oracles & Vaults. The protocol owner can use these factories to spawn new markets, exotic oracles & vaults to direct liquidity. \
\
Additionally, the protocol owns the Multi Invoker (an Operator contract for the UI)

<figure><img src="/files/eGcgIEkA3W4ammwgsq6d" alt=""><figcaption><p>A hierarchical ownership tree for the perennial protocol.</p></figcaption></figure>

### Standard Market Flow w/ MultiInvoker

When a user interacts with a market using the MultiInvoker they are able to bundle a number of steps required to modify their position.

<figure><img src="/files/92ACkPale3TJtO7WPuva" alt=""><figcaption><p>A user takes a 1 unit position in a market.</p></figcaption></figure>

### Standard Vault flow w/ MultiInvoker

When a user interacts with a Vault they generally follow this flow to adjust the vault balances between markets.

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