> ## 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.

# Tech stack

> Languages, frameworks, and infrastructure behind Perps Agent.

A short, opinionated stack chosen for **safety, speed, and verifiability**.

## Backend

* **Language:** TypeScript (Node.js runtime) for the trading services and Telegram bot.
* **Real-time:** WebSocket clients for venue market data and fills; lightweight event bus internally.
* **Storage:** Postgres for off-chain operational state (per-user config, open runs, alerts). Authoritative track record lives on Mantle, not in Postgres.

## AI loop

* **Model orchestration:** Python service for proposal and scoring.
* **Features:** market microstructure, regime tags, attested historical runs from Mantle.
* **Objective:** risk-adjusted score with hard caps on drawdown and leverage.

## Signals

Three external AI feeds fuse into the live **regime fingerprint** that sizes every grid:

* **Surf AI** — market microstructure (realized volatility, funding, RSI) → the core regime read.
* **Nansen AI** — smart-money net flows → `smart_money_flow`.
* **Elfa AI** — real-time social / mention momentum → `social_momentum`.

## Grid engine

* **Language:** TypeScript.
* **Design:** event-driven — fills come in, ladder state updates, refill orders go out.
* **Risk:** all order intents pass through a cap-enforcement layer before hitting the exchange adapter.

## Exchange adapters

* **Bybit:** REST + WebSocket through their v5 API.
* **Future venues:** the same `Adapter` interface, implemented per venue.

## On-chain (Mantle)

* **Language:** Solidity.
* **Contracts:** `StrategyLedger`, `StrategyMemory`, `Vault`.
* **Tooling:** Foundry for tests and deployments.
* **Indexing:** event-driven indexer feeding the AI loop's "recall" step.

## Product surface

* **Telegram bot:** grammY (TypeScript) for the chat UX.
* **Docs:** Mintlify.
