> ## Documentation Index
> Fetch the complete documentation index at: https://docs.perpsagent.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# System architecture

> Components and data flow across the Perps Agent stack.

Perps Agent is split into clear, independently testable layers.

## Layers

| Layer                    | Role                                                                  |
| ------------------------ | --------------------------------------------------------------------- |
| **Telegram UX**          | User-facing product. Configure, launch, monitor, stop.                |
| **AI agent loop**        | Proposes risk-adjusted grid parameters. Learns from attested history. |
| **Grid engine**          | Places and manages laddered orders. Tracks fills, PnL, drawdown.      |
| **Exchange abstraction** | Adapter interface for venues (Bybit today, more on the roadmap).      |
| **Mantle proof layer**   | Commits configs and attests outcomes on-chain.                        |

## Data flow

```text theme={null}
Telegram → AI loop → Mantle (commit)
                    ↓
              Grid engine → Exchange adapter → Bybit
                    ↓
              Mantle (attest) ← verified outcome
                    ↓
             Telegram (results)
```

## Design properties

* **Non-custodial.** The exchange adapter holds only trade-only API keys; user funds never move off Bybit.
* **Pre-trade commitment.** No order is placed until the config hash is committed on Mantle.
* **Post-trade attestation.** No outcome counts toward the agent's track record unless it is attested on-chain.
* **Pluggable venues.** Adding a new exchange means writing one adapter — the grid engine, AI loop, and proof layer don't change.
