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

# Architecture Overview

BrownFi V3 consists of five core smart contracts and a set of supporting facilities:

* Factory: Creates new V3 pair pools (permissioned to pool creator role).
* Router: Handles user-facing swap computations — both forward (amountIN given) and backward (amountOUT given) — and routes amounts to/from pair contracts.
* Oracle Gateway: Aggregates price from multiple sources (Pyth, Chainlink, Redstone, on-chain AMM TWAP), computes skew price and pre-trade spread price, and feeds them to pair contracts.
* Pair Contract (V3 Pool): Holds token reserves, executes add/remove LP, performs inventory verification per swap, mints protocol fee LP tokens. Each pool has distinct base and quote tokens.
* Config Contract: Stores all configurable parameters (Kappa, fee, spread, skewness, gamma) outside the pool contract, enabling dynamic adjustment without redeployment.

<figure><img src="https://1650977365-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6rXUpqa3NfdkRgiX5Xu6%2Fuploads%2FJI8aopEoEJzGRUxgLJBk%2Fbrownfi_arch_v5.png?alt=media&amp;token=35422b1d-4bba-4a1a-8ef3-34e7deaa5412" alt=""><figcaption></figcaption></figure>
