> For the complete documentation index, see [llms.txt](https://docs.mellow.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mellow.finance/core-vaults/architecture/hooks/redirectingdeposithook.md).

# RedirectingDepositHook

### Overview

`RedirectingDepositHook` is a deposit-time liquidity allocation hook implementing the `IHook` interface. It is designed to **redirect newly deposited assets** from a vault into its underlying **subvaults**, based on per-subvault risk and capacity constraints defined by a `RiskManager`.

This hook helps distribute liquidity optimally during deposit flows.

### Purpose

* Automatically **forwards newly deposited assets** from the main vault into eligible subvaults.
* Delegates decision-making to the vault’s configured `RiskManager`, which determines per-subvault deposit limits.
* Ensures that **subvaults do not exceed their capacity constraints**.

### Key Function

### `callHook(address asset, uint256 assets)`

Distributes a given amount of `asset` across available subvaults based on their individual deposit capacity.

**Execution Logic:**

1. Retrieves:
   * Active `vault` context via `IVaultModule(address(this))`
   * Configured `RiskManager` via `vault.riskManager()`
   * Number of subvaults via `vault.subvaults()`
2. Iterates over each subvault:
   * Fetches max allowed deposit via `riskManager.maxDeposit(subvault, asset)`
   * If allowed amount is zero → skip
   * Otherwise:
     * Pushes `min(assets, allowed)` via `vault.hookPushAssets()`
     * Decrements `assets` accordingly
     * Stops early if full amount has been distributed

### Components and Assumptions

* **Vault:** Must implement `IVaultModule`:
  * `subvaults()` → number of subvaults
  * `subvaultAt(index)` → returns subvault address
  * `hookPushAssets(subvault, asset, amount)` → transfers tokens to subvault
  * `riskManager()` → returns associated `IRiskManager`
* **Risk Manager:** Must implement:
  * `maxDeposit(subvault, asset)` → returns max allowed deposit into that subvault


---

# 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.mellow.finance/core-vaults/architecture/hooks/redirectingdeposithook.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.
