> For the complete documentation index, see [llms.txt](https://docs.fathom.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fathom.fi/fxd-stablecoin/fxd-smart-contract-architecture.md).

# 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.
