> For the complete documentation index, see [llms.txt](https://docs.margined.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.margined.io/design/high-level-architecture.md).

# High Level Architecture

Locust integrates on-chain smart contracts with an off-chain executor. This architecture delivers a DeFi native product with high levels of customization, flexible strategies, and excellent performance.

**Core Components**

1. **Fund Contract (Vault):**
   * **User Interactions:** Users deposit funds into the Fund Contract and redeem them when needed.
   * **Purpose:** It acts as a secure vault for storing user assets and serves as the central repository for fund management.
2. **Strategy Contract:**
   * **Fund Withdrawal:** The Strategy Contract periodically withdraws funds from the Fund Contract to implement specific investment strategies.
   * **Periodic Repayment:** To support ongoing user redemptions and ensure accurate accounting, the Strategy Contract periodically repays a portion of the funds back to the Fund Contract.
   * **Authz Grants:** This contract issues authorization (Authz) grants to the off-chain Locust executor, defining what actions the executor is permitted to perform.
3. **Locust Off-Chain Executor:**
   * **Management Role:** It manages the funds held within the Strategy Contract, executing strategy-specific operations.
   * **Security via Authz:** The executor is only authorized to sign messages on behalf of the Strategy Contract when it holds the appropriate Authz permissions. This design ensures that every action taken is explicitly permitted and verificable on-chain.

<figure><img src="/files/hN986oGTqZCcZT0EBia1" alt=""><figcaption><p>Figure 1: High Level Locust Architecture</p></figcaption></figure>

{% file src="/files/1rErjHZiyQnPvq1rCs9n" %}


---

# 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.margined.io/design/high-level-architecture.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.
