# FXD Smart Contract Architecture

<figure><img src="/files/3NY0FJtQYqEDorM1vxGO" alt=""><figcaption><p>FXD Stablecoin Smart Contract System Design</p></figcaption></figure>

<figure><img src="/files/uVrfgVdipZER3UMCSljH" alt=""><figcaption><p>FXD Stablecoin Smart Contract Architecture</p></figcaption></figure>

#### Fathom Protocol Smart Contract Architecture

The structure comprises distinct modules, each responsible for a set of defined operations.

**Core Components**

1. **Proxy Module**: Interfaces for the core contracts of the protocol.
   * **ProxyWallet**: Calls functions within the FathomProxyActions contract for user interactions.
   * **ProxyActionsStorage**: Stores the address of the FathomProxyActions contract.
   * **ProxyWalletRegistry**: Oversees the creation of proxy wallets owned by users.
2. **Position Module**: Handles the creation and tracking of user positions.
   * **PositionManager**: Initiates user positions and maintains a record of them.
3. **Stablecoin Core Module**: Central to the management of the FXD stablecoin's lifecycle.
   * **BookKeeper**: Monitors and manages each position's locked collateral and debt share.
   * **CollateralPoolConfig**: Manages configurations for collateral pools.
   * **StablecoinAdapter**: Oversees the minting and burning functions of the FathomStablecoin contract.
4. **StableSwapModule**: Supports the provision of liquidity and the execution of FXD<->xUSDT 1:1 swaps.
   * **StableSwapModuleWrapper**: Integrates and administers the protocol's liquidity pools.
5. **Price Module**: Delivers accurate price information for assets.
   * **PriceFeed**: Gathers price data from price source and feeds it into the protocol.
   * **PriceOracle**: Transforms raw price from PriceFeed to include a safety margin, using the LTV ratio.
6. **Liquidation Module**: Maintains the protocol's financial health by managing under-collateralized positions.
   * **LiquidationEngine**: Carries out the liquidation process according to predefined rules.
   * **FixedSpreadLiquidationStrategy**: Directs liquidation activities, ensuring consistency through a fixed spread.
7. **Emergency Module**: Pause or Terminate the protocol.
   * **ShowStopper**: Stops and terminates the whole protocol and executes the emergency shutdown process to return collateral
   * **AdminControls**: Pauses the protocol at once.


---

# Agent Instructions: 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.fathom.fi/fxd-stablecoin/fxd-smart-contract-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.
