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

# Technical Architecture

Aegis is a decentralized, non-custodial staking protocol built on the BNB Smart Chain (BSC). It utilizes a Factory-based architecture to deploy and manage liquidity pools dynamically. \
The protocol is designed to be modular, gas-efficient, and secure, leveraging industry standard libraries (OpenZeppelin) alongside custom logic for hybrid staking models.<br>

<figure><img src="/files/0eHwDYFNW1rFB81rnz9D" alt=""><figcaption></figcaption></figure>

#### Core Components

The Aegis ecosystem consists of three primary smart contract types:

1\. The Aegis Factory (`StakingFactory`) The heart of the protocol. This singleton contract acts as the central registry and deployment mechanism.

* Deterministic Deployment: Allows the protocol administrator to deploy new pools without modifying the frontend source code.
* Registry: Maintains an on-chain array (`allPools`) of every deployed staking contract, ensuring transparency and discoverability.
* Access Control: Utilizes `Ownable` restricted functions to prevent unauthorized pool creation.

2\. Fixed Yield Vaults (`NeonFixedStaking`) Designed for deterministic returns based on time-locking.

* Logic: Users stake tokens for a pre-defined `lockDuration`.
* Reward Calculation: Rewards are calculated linearly based on the APY set at deployment:

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

* Lock Mechanism: The `withdraw` function enforces a timestamp check (`block.timestamp >= stakeTimestamp + lockDuration`), ensuring liquidity remains in the protocol for the agreed period.
* Decimal Agnostic: The math logic dynamically handles tokens with varying decimals (e.g., 6 for USDC vs 18 for native tokens) by calculating rewards based on the principal amount ratio.

3\. Flexible Liquidity Mining (`NeonStaking`) Based on the Synthetix "StakingRewards" logic, optimized for continuous liquidity provision.

* Logic: Users can stake and unstake at any second (`block.timestamp` precision).
* Reward Distribution: Rewards are distributed pro-rata based on the user's share of the total pool:

<figure><img src="/files/2msmOGOHVc320ZshXD6k" alt=""><figcaption></figcaption></figure>

* Solvency Checks: The contract includes a `notifyRewardAmount` function with built-in checks to ensure the contract always holds enough reward tokens to cover the advertised rate for the remaining duration.


---

# 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://docs.metuslabs.com/metus/dapps/aegis/technical-architecture.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.
