# Architecture

The system operates on a trust-minimized architecture separating **Decision Making** from **Execution**:

1. **Ditto Keeper (Off-chain)**: Monitors yield opportunities 24/7.
2. **APR Oracle (On-chain)**: Snapshots realized APRs from underlying protocols to prevent manipulation.
3. **Rebalancer (On-chain)**: A stateless contract that calculates the optimal split of funds to maximize APY.
4. **Vault (ERC-4626)**: Atomically executes deposits/withdrawals across strategies.

#### Security Measures

* **Non-Custodial**: User funds are held in the smart contract, never by Ditto or the integrator.
* **Atomic Execution**: Rebalances happen in a single transaction.
* **Slippage Protection**: The vault snapshots Total Value Locked (TVL) before and after every rebalance.
* **Reward Debt Model**: Protocol fees are minted exclusively from yield. The principal deposit is never touched.

<figure><img src="/files/8dwlOAnmpgZ4zBOETtkx" alt=""><figcaption></figcaption></figure>


---

# 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.dittonetwork.io/ditto-usd-meta-lending/architecture.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.
