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

# Loops

While a position is open, a scheduled keeper runs it. The keeper runs as two lanes on different clocks. A protection lane runs every few minutes, because a price move is a now problem, and carries the hedge and liquidation guards. A yield lane runs hourly, because funding moves over hours, and carries the carry guard. A separate daily lane watches key expiry.

Every pass begins by reading the trading key. A revoked or expired key stops the pass there, which makes revocation the off lever: nothing further triggers once the key is gone. Otherwise the pass reads the live position, evaluates the guards, and for a guard set to act on its own, signs the repair with the trading key and settles it on HyperCore. The keeper is otherwise always armed.

<figure><img src="https://2200787856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXtrI3YGWysOEHYt3fLKo%2Fuploads%2Ft3LJPrOLhjBBheIdAwd7%2Fimage.png?alt=media&amp;token=d7027248-5f47-48f6-a943-a589e9b97b00" alt=""><figcaption></figcaption></figure>

### Authorization

Before a repair is signed, the backend gates it. It checks, in order, that the key is present and not revoked, that the key has not expired, and that the action is in the trading key's scope. A revoked or missing key stops the repair. An expired key stops it and flags the key for renewal. Trades and margin top-ups fall inside that scope, so the trading key signs them itself and the user is never prompted. A withdrawal or a margin-mode change falls outside it and routes to the user to sign.

The authorization gate and the risk layer are separate concerns. The risk layer decides what the position needs. The gate decides whether the key is allowed to do it. An auto-act repair still passes the scope check, and anything out of scope becomes a request for the user to sign.

<figure><img src="https://2200787856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXtrI3YGWysOEHYt3fLKo%2Fuploads%2FlrEq2PSIslV6hK4J4nHE%2Fimage.png?alt=media&amp;token=f2ef2348-312c-4946-b830-0fb00c68db1d" alt=""><figcaption></figcaption></figure>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.renzofinance.com/architecture/loops.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
