> For the complete documentation index, see [llms.txt](https://leveracc.gitbook.io/leveracc-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://leveracc.gitbook.io/leveracc-docs/how-it-works/architecture.md).

# Architecture

How LeverAcc splits work between HyperCore (trading) and HyperEVM (financing and settlement), its main contracts, and how a trade is financed.

LeverAcc splits responsibility between Hyperliquid's two layers:

> **HyperCore holds the trading truth. HyperEVM holds the financing and settlement truth.**

| Layer                       | What lives there                                                                                                                                                                                                |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **HyperCore**               | The user's trading account: own funds, positions, margin, fills, order execution.                                                                                                                               |
| **HyperEVM**                | The LeverAcc smart contracts: user accounts, debt and interest, the Fund Vault, signed user intents, withdrawals, settlement and bad-debt handling.                                                             |
| **Off-chain control plane** | LeverAcc services that watch accounts, run risk checks, collect interest, settle fees and operate partner onboarding. They never hold user funds and cannot withdraw for users. On-chain state is always final. |

## Main contracts

| Contract                                | Role                                                                                          |
| --------------------------------------- | --------------------------------------------------------------------------------------------- |
| **Registry**                            | Roles, module addresses, protocol mode (Normal / Frozen), leverage cap, per-project settings. |
| **Account Factory**                     | Creates one deterministic Account per user and project.                                       |
| **Account** (upgradeable via beacon)    | The user's financing ledger: borrow, repay, withdraw, settle, wallet bindings.                |
| **Fund Vault** (via Fund Vault Manager) | Funder supply and redemptions, lending, interest, bad-debt write-off.                         |
| **Economic Config**                     | Borrow-rate model, profit-fee settings.                                                       |
| **Project Revenue Manager**             | Splits fee revenue between the platform and partners; partners claim their share.             |
| **Builder Policy Registry**             | Which Hyperliquid builder codes each partner project may use.                                 |

## How a trade is financed

1. The user creates (or the partner creates for them) a LeverAcc **Account** and funds it.
2. The user signs a **borrow intent**. The vault lends USDC to the Account in the same transaction that records the debt.
3. Funds move to the user's HyperCore trading account. The partner's **execution wallet** places orders on Hyperliquid.
4. LeverAcc's risk engine monitors the account continuously and keeps an exchange-side stop-loss in place.
5. Interest is collected periodically. The user repays, withdraws, or requests a stop and the account is settled.

Anyone can relay a user's signed intent on-chain, but no one can act without the user's signature. A receipt from HyperCore only proves submission; LeverAcc confirms results by reading balances back.
