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

# Keepers

Keepers are automated bots that maintain protocol health by monitoring positions and executing liquidations. They are a critical part of MegaTAO's infrastructure.

## What keepers do

When a trader's margin ratio falls below the maintenance threshold, the position becomes eligible for liquidation. Keepers detect these unhealthy positions and submit liquidation transactions to close them before they become insolvent.

Without keepers, undercollateralized positions could accumulate bad debt, meaning losses that exceed the trader's deposited margin. This would put vault depositors at risk. Keepers prevent this by ensuring liquidations happen promptly.

## How it works

1. Keepers continuously monitor all open positions across all markets
2. For each position, they calculate the current margin ratio using the latest oracle price
3. When a position's margin ratio drops below the maintenance margin (currently 10%), the keeper submits a liquidation transaction
4. The protocol verifies the position is indeed liquidatable and executes the liquidation on-chain
5. The keeper receives a portion of the liquidation fee as incentive

## Incentives

Keepers are incentivized through the liquidation fee. When a position is liquidated, a 5% fee is charged on the remaining margin. A portion of this fee goes to the keeper that executed the liquidation, compensating them for monitoring costs and gas.

This incentive structure ensures liquidations happen quickly even during volatile markets when gas costs may be elevated.

## Keeper roles

Keepers also perform other protocol maintenance tasks:

* **Funding rate updates:** Keepers trigger funding rate recalculations to keep rates current with market conditions
* **Interest fee updates:** Keepers update interest accruals based on vault utilization

## Decentralization

The keeper role is permissioned at the contract level. The protocol team currently operates the primary keeper infrastructure to ensure reliable liquidation execution. As the protocol matures, the keeper system may be opened to additional participants.


---

# 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.megatao.com/core/keepers.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.
