> For the complete documentation index, see [llms.txt](https://steakhouse.financial/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://steakhouse.financial/docs/products/infrastructure/box-vaults/box-vaults-technical.md).

# Technical Reference

This is the smart contract technical reference for Box, the ERC-4626 child vault built by Steakhouse Financial. It documents the contract's roles and permissions (Owner, Curator, Guardian, Allocator, Feeder), timelock governance, allocation and swap safety controls, lifecycle states, and funding module integrations for Aave v3 and Morpho Blue.

## What Box does

* Holds a single base asset (e.g., USDC) and issues ERC-4626 shares.
* Allocates between the base asset and whitelisted ERC-20 tokens.
* Borrows and lends through whitelisted funding modules.
* Tracks NAV using token oracles and funding module NAV.

## Architecture

{% @mermaid/diagram content="flowchart LR
VaultV2\[Morpho Vault V2] --> Adapter\[BoxAdapter / BoxAdapterCached]
Adapter --> Box\[Box Vault]
Box --> Swapper\[Swapper Integrations]
Box --> Tokens\[Whitelisted Tokens]
Box --> Funding\[Funding Modules]
Funding --> Aave\[FundingAave]
Funding --> Morpho\[FundingMorpho]" %}

Adapters are the intended feeders for Box. Box shares are held by adapters and reported back to Vault V2 using `previewRedeem` (cached in `BoxAdapterCached`).

## Roles & permissions

**Owner**

* Sets the curator.
* Transfers ownership.
* Sets `skimRecipient`.

**Curator**

* Manages allocators and funding modules.
* Adds/removes whitelisted tokens and oracles.
* Configures slippage limits.
* Submits timelocked changes.
* Can initiate shutdown.

**Guardian**

* Vetoes timelocked actions (`revoke`).
* Triggers shutdown.
* Can recover from shutdown before winddown.
* May update oracles only in final winddown.
* Commonly controlled by an Aragon DAO representing Vault V2 share holders.

**Allocator**

* Executes swaps (`allocate`, `deallocate`, `reallocate`).
* Pledges collateral, borrows, repays via funding modules.
* Can use `flash` for atomic multi-step operations.

**Feeder**

* The only role allowed to deposit/mint shares.
* In practice, adapters act as feeders.

## Timelock governance

Critical functions require a timelock delay and must be queued with `submit()` before execution. Governance is intentionally structured so Vault V2 share holders can intervene via the Aragon DAO-controlled guardian, allowing them to veto queued actions or trigger shutdowns if needed.

Typical timelocked actions include:

* Adding/removing feeders
* Setting `maxSlippage`
* Adding tokens, oracles, funding modules, or facilities
* Setting guardian

Timelock delays default to `0`; deployments should initialize non-zero delays to prevent immediate execution.

## Allocation & swap safety

Box enforces **two layers of slippage control**:

1. **Per-swap slippage check** Based on oracle prices, each swap must satisfy `received ≥ expected * (1 - maxSlippage)`.
2. **Epoch slippage budget** Realized slippage is tracked relative to NAV over `slippageEpochDuration`. If accumulated slippage exceeds `maxSlippage`, further swaps are blocked until the epoch resets.

During **winddown**, the per-epoch limit is ignored and the per-swap tolerance linearly ramps up to 1%.

{% @mermaid/diagram content="flowchart LR
Allocator\[Allocator] -->|Allocate| Box\[Box Vault]
Box -->|Oracle price| Oracle\[Token Oracle]
Box -->|Execute swap| Swapper\[Swapper]
Swapper -->|Tokens back| Box
Box -->|Emit event| Allocator
" %}

## Lifecycle states

{% @mermaid/diagram content="stateDiagram-v2
\[*] --> Normal
Normal --> Shutdown: guardian/curator triggers
Shutdown --> Normal: guardian recovers (before warmup)
Shutdown --> Winddown: shutdownWarmup elapsed
Winddown --> \[*]" %}

## Funding modules

Box integrates lending protocols through `IFunding` modules. Each module is owned by the Box and supports:

* Facilities (protocol-specific configuration)
* Whitelisted collateral tokens
* Whitelisted debt tokens

Box will only add **empty** funding modules (no facilities, no tokens, no debt).

### FundingAave (Aave v3)

* `facilityData` must be empty (`""`).
* Uses Aave Pool and optional `eMode`.
* `pledge` supplies collateral and enables collateral usage.
* `borrow` returns debt tokens to Box.
* NAV is `collateral value - debt value`, floored at zero.

### FundingMorpho (Morpho Blue)

* `facilityData` encodes Morpho market parameters.
* Supports multiple facilities per module.
* Enforces LTV caps via `lltvCap` against each market’s LLTV.
* `pledge` / `borrow` validated per facility.
* NAV computed per facility and aggregated, floored at zero.

## Flash operations

Allocators (or anyone during winddown) can call `flash()` to temporarily source liquidity for complex sequences. NAV is cached during the flash to prevent manipulation, and the flash token must be returned in the same transaction.

## Audit and source

* ChainSecurity audit (Dec 2025): [2025-12-16-chainsecurity.pdf](https://github.com/Steakhouse-Financial/box/blob/52ab8b9f20184c5882448df7be31701df1cf6f39/audits/2025-12-16-chainsecurity.pdf)
* Cantina audit (Jan 2026): [2026-01-06-cantina.pdf](https://github.com/Steakhouse-Financial/box/blob/52ab8b9f20184c5882448df7be31701df1cf6f39/audits/2026-01-06-cantina.pdf)


---

# 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://steakhouse.financial/docs/products/infrastructure/box-vaults/box-vaults-technical.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.
