> For the complete documentation index, see [llms.txt](https://altodex.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://altodex.gitbook.io/docs/getting-started/1.2-architecture-and-core-concepts.md).

# 1.2 Architecture & Core Concepts

<figure><img src="/files/DLzD1QXWyZQTwsTUGb1k" alt=""><figcaption></figcaption></figure>

The foundation of Alto's architecture is modularity; every subsystem is made as a separate building block that can be expanded, changed, or upgraded without interfering with the larger protocol. In DeFi, where innovation occurs rapidly and protocols that are unable to adapt run the risk of becoming outdated, this strategy is crucial. Alto guarantees long-term resilience, upgradability, and user trust by making each layer flexible and decomposable.

The Perpetual Engine, Vaults, Oracles, Risk Engine, and Governance Layer are the five main modules that make up Alto's architecture at a high level. Each contributes differently to the protocol's sustainability, transparency, and functionality.

***

#### Perpetual Engine

The Perpetual Engine is the **core trading layer** of Alto. It manages:

* **Order Matching:** A hybrid mechanism that combines orderbook-style execution and AMM-style liquidity matches incoming buy and sell orders. This guarantees that traders gain from accurate order control as well as deep liquidity.
* **PnL (Profit and Loss) Calculation:** To guarantee that traders always have visibility into their positions, the engine continuously updates unrealized and realized PnL in real-time.  Alto's PnL math is completely transparent and verifiable on-chain, in contrast to centralized exchanges where computations may be opaque.
* **Margin Accounting:** Depending on the user's preferences, the engine calculates the necessary margin, monitors collateral usage, and applies isolation or cross-margin.  In contrast to single-asset collateral models, the engine guarantees a more flexible trading experience by supporting multi-collateral portfolios.

The Perpetual Engine's scalable and gas-efficient design lowers transaction costs without sacrificing transparency. It uses modular smart contracts that can be independently upgraded through governance votes to avoid full-system redeployments.

***

#### Vaults

The foundation of Alto's liquidity is its vaults. Alto offers segmented vaults that accommodate various LP (Liquidity Provider) risk preferences in place of a single undifferentiated pool:

* **Delta-Neutral Vaults:** These vaults automatically hedge exposure, preventing LPs from taking on directional market risk and allowing them to earn yield primarily from fees and funding. For conservative LPs, this makes the experience more "savings-account-like."
* **Directional Vaults:** By choosing to take a long or short position on particular assets, LPs can profit from protocol fees while effectively expressing market opinions. Although directional exposure is introduced, the yield is increased.
* **Volatility Vaults:** These vaults, which offer larger rewards in return for increased exposure, are ideal for LPs who are prepared to assume greater risk.

Since tokenized ERC-20 shares are issued by each vault, LP positions can be staked, traded, or even used as collateral in other DeFi protocols. This flexibility guarantees that LP capital can move throughout the larger ecosystem rather than being restricted to Alto alone.

Additionally, vault mechanics are made to be sustainable. Alto vaults employ automated risk management techniques (like capped exposure and delta-hedging strategies) to prevent systemic LP losses, in contrast to traditional models where LPs may be depleted by one-sided markets.

***

#### Oracles

Since pricing accuracy has a direct impact on funding rates, liquidations, and market trust in general, it is crucial in perpetual exchanges. To reduce manipulation and increase dependability, Alto uses a hybrid oracle system:

* **Primary Feed:** Chainlink provides extremely secure and extensively used price data, making it the default oracle provider.
* **Secondary Feeds:** Alto incorporates TWAP (Time-Weighted Average Price) from decentralized exchanges such as Uniswap and Sushiswap in the event of outages or anomalies.
* **Failover Mechanisms:** To stop malicious actors from taking advantage of single-source pricing, the system automatically switches between feeds if anomalies are found.

Users are shielded from common DeFi attack vectors like price manipulation driven by flash loans thanks to this multi-layered approach. Additionally, every Oracle update is recorded on-chain, guaranteeing complete transparency in the pricing process.

***

#### Risk Engine

Alto's safeguard against systemic failure is the Risk Engine. It upholds regulations intended to keep the protocol transparent, equitable, and solvent.

**Key responsibilities include:**

* **Leverage Management**: Adaptive leverage limits that reduce in high-volatility times are known as leverage management. As a result, traders and LPs are protected from the risk of liquidation cascades.
* **Volatility Monitoring**: Tracking of asset volatility in real time, which causes automatic modifications to position limits, margin requirements, and maximum leverage.
* **Liquidation Thresholds**: Thresholds for liquidating positions that are well-defined and openly auditable. This guarantees equity and eliminates uncertainty.
* **Circuit Breakers**: Like TradFi stock market halts, the Risk Engine can cause brief trading pauses in response to significant market disruptions.

Alto circumvents the "black box" issue that besets centralized exchanges by making all of these parameters auditable and on-chain. Traders are always aware of the game's rules.

***

#### Governance Layer

The protocol is governed by AltoDAO, which guarantees that users will determine its direction. With features like delegation and quorum thresholds, governance is token-based ($ALTO) but aims to prevent plutocracy.

**The Governance Layer regulates:**

* **Market Listings:** Selecting which collateral assets or new perpetual markets to launch.\
  Updates to vault ratios, liquidation penalties, and leverage caps are examples of parameter adjustments.
* **Treasury Management:** Distributing money for grants, ecosystem incentives, and cooperative ventures.
* **Upgrades**: Accepting modifications to smart contracts or their incorporation into other protocols.

Community proposals go through a lifecycle of discussion, voting, and execution, and all governance decisions are transparent and on-chain.

***

#### Modular Independence

Module independence is arguably Alto's most significant design element. For instance:

Circuit breakers protect vaults and the perpetual engine in the event that the oracle system fails.\
The perpetual engine and other vault types are unaffected if one vault strategy performs poorly.\
In order to prevent upgrades from destabilizing unrelated system components, governance changes are timelocked and isolated.

* Circuit breakers protect vaults and the perpetual engine in the event that the oracle system fails.
* The perpetual engine and other vault types are unaffected if one vault strategy performs poorly.
* In order to prevent upgrades from destabilizing unrelated system components, governance changes are timelocked and isolated.

A "Lego-like" financial architecture is produced by this modularity, allowing for component upgrades without sacrificing the system's overall integrity.


---

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

```
GET https://altodex.gitbook.io/docs/getting-started/1.2-architecture-and-core-concepts.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.
