> For the complete documentation index, see [llms.txt](https://clio-defi.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://clio-defi.gitbook.io/docs/how-it-works.md).

# How it works

Clio DeFi is composed of four onchain components and one offchain rendering layer. Router and Vault contracts are active on BNB Smart Chain, the lending execution path activates during Phase III rollout, Treasury control is handled through multi-sig, and the indexer feeds the dashboard; the front-end is a Next.js application served from `cliodefi.xyz`.

### 1. Router Contract

The Router is the single user-facing entry point for swaps. It accepts a swap intent (`tokenIn`, `tokenOut`, `amountIn`, `minAmountOut`, `recipient`, `deadline`) and dispatches across whitelisted DEX adapters (PancakeSwap V3 and Biswap at launch). The Router itself does not custody assets between hops; transfers settle atomically per call.

Security review scope is being finalized for independent third-party assessment.

### 2. Vault Contract Family

Three Vault contracts — one per lock period (7d, 30d, 90d). Each Vault accepts the staked asset, mints a non-transferable receipt token (`cBNB7`, `cBNB30`, `cBNB90`, `cUSDT30` etc.), and records the deposit timestamp. Yield is accrued in two ways at launch:

* **Native staking strategies** for BNB pools (delegated to validator partners under Clio Treasury supervision)
* **Curated lending positions** for stablecoin pools (Venus, Kinza)

Auto-compound runs every 24 hours via a Chainlink Automation upkeep.

### 3. Lending Module (Phase III Rollout)

The Lend module UI is live in the application, and the onchain lending execution path rolls out in Phase III. At launch, collateralized lending routes through whitelisted venues with explicit risk and health-factor visualization in the interface. Borrow limits and liquidation thresholds are enforced per market profile.

### 4. Treasury Contract

A Gnosis Safe multi-sig (3-of-5) that holds the Treasury Reserve allocation, the yield strategy buffer, and the Ecosystem Growth budget. All signers are publicly disclosed in Team. Multi-sig transactions over 50,000 USDT-equivalent require a 24-hour timelock.

### 5. Indexer

A subgraph (The Graph protocol) indexes Router and Vault events and exposes a GraphQL endpoint to the dashboard. The indexer is the only offchain dependency in the read path; all writes settle directly onchain.

### 6. Front-End

Next.js application, statically generated, deployed to Vercel with edge caching. Wallet connection through MetaMask, Coinbase Wallet, and Phantom. Default chain prompt is **BNB Smart Chain (chainId 56, hex 0x38)**; the app prompts users to add or switch chains when required.

### A Typical User Journey

1. User opens `cliodefi.xyz` and connects MetaMask.
2. Wallet auto-prompts to switch to BNB Smart Chain.
3. User opens **Module I (Swap)**, exchanges 1 BNB for USDT, signs once.
4. Router dispatches across PancakeSwap V3 and Biswap; returns USDT.
5. Indexer detects the event; the user's dashboard timeline updates within seconds.
6. The user opens **Module II (Stake)**, locks 1,000 USDT into the 30-day pool, signs once.
7. Vault mints `cUSDT30` to the user; deposit appears in the timeline.
8. Twenty-four hours later, the auto-compound upkeep accrues yield. The dashboard shows a new "Yield" event.
9. The user opens **Module III (Lend)**, supplies collateral, reviews health factor, and optionally opens a borrow position.


---

# 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://clio-defi.gitbook.io/docs/how-it-works.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.
