Architecture

Fathom DEX relies on a robust and secure smart contract architecture to facilitate its decentralized exchange functionalities.

These smart contracts are the Uniswap V2 direct fork. They are battle-tested on various networks and are considered safe.

Overview of Smart Contract Architecture

Factory Contract

  • Role: The factory contract is responsible for deploying new liquidity pool contracts. It maintains a registry of all active liquidity pools on the platform.

  • Functions:

    • CreatePair: Deploys a new pair contract for a given token pair.

    • GetPair: Retrieves the address of an existing pair contract.

Pair Contract

  • Role: Each pair contract represents a liquidity pool for a specific token pair. It manages the addition and removal of liquidity, as well as the execution of token swaps.

  • Functions:

    • AddLiquidity: Allows users to add tokens to the liquidity pool.

    • RemoveLiquidity: Allows users to withdraw their tokens from the liquidity pool.

    • Swap: Facilitates token swaps between the two tokens in the pair.

Router Contract

  • Role: The router contract provides the main interface for users to interact with the DEX. It routes transactions to the appropriate pair contracts.

  • Functions:

    • AddLiquidity: Simplifies the process of adding liquidity by automatically calculating the optimal token amounts.

    • RemoveLiquidity: Manages the removal of liquidity, ensuring users receive the correct token amounts.

    • SwapExactTokensForTokens: Executes a token swap with a specified input amount.

    • SwapTokensForExactTokens: Executes a token swap with a specified output amount.

Last updated

Copyright© Fathom App 2024.