# SubvaultModule

### Purpose

The `SubvaultModule` represents an isolated child vault within a modular vault system. It is tightly controlled by its parent vault (typically a `VaultModule`) and is responsible for securely holding and releasing assets upon authenticated requests.

### Responsibilities

* Store and isolate a portion of vault assets
* Allow trusted actor (curator) to delegate liquidity from the Subvault to external protocol based on the `Verifier` setup for this specific subvault
* Respond to `pullAssets` calls from the parent vault only

### Storage Layout (`SubvaultModuleStorage`)

```solidity
struct SubvaultModuleStorage {
  address vault;
}
```

* `vault`: Address of the root vault that controls this subvault. Only this address can request asset withdrawals.

The layout is stored in a deterministic custom slot derived using:

```solidity
SlotLibrary.getSlot("SubvaultModule", name_, version_)
```

### View Functions

### `vault() → address`

Returns the address of the parent vault that instantiated this subvault.

### Mutable Functions

### `pullAssets(asset: address, value: uint256)`

Allows the parent vault to withdraw a specified amount of an asset.

* **Access Control**: Can only be called by the `vault()` address
* **Reverts**: With `NotVault()` if the caller is not the vault
* **Transfer Behavior**: Uses `TransferLibrary.sendAssets()` to forward tokens or native ETH to the `Vault.sol` address
* **Emits**: `AssetsPulled(asset, vault, value)`

### Internal Initialization

### `__SubvaultModule_init(address vault_)`

Internal setup method to be called during construction or proxy initialization.

### Events

### `event AssetsPulled(address indexed asset, address indexed to, uint256 value)`

Triggered when assets are withdrawn by the parent vault.

* `asset`: Address of the ERC20 token or native ETH
* `to`: Always equals the `vault()` address
* `value`: Amount of the asset transferred

### Error Handling

* **`NotVault()`**: Raised when a non-vault caller attempts to call `pullAssets()`


---

# Agent Instructions: 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:

```
GET https://docs.mellow.finance/core-vaults/architecture/modules/subvaultmodule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
