The Xfai architecture design
The Xfai constant product market maker (CPMM) model consists of several smart contracts:
Every hosted ERC20 token on Xfai has its own pool contract. A pool contract keeps track of state, i.e. it keeps track of its reserve, weight, oracle, LP tokens, etc. A pool's reserves and weight can only be modified by Xfai's Core contract.
The core contract is where the AMM logic resides. It contains the functions to perform swaps, liquidity provisioning, liquidity redemption, and infinity staking. The core contract is responsible to change the states of pools e.g. when a swap is initialized.
The Factory contract's role is to create new Xfai Pools, as well as to inform Xfai pools on the current Core contract address. If the pools are contacted by a contract, that according to the Factory is not the current Core contract, then access to state modifying functions is restricted. This decoupling of state and execution logic allows us to easily swap Core contracts with upgraded versions, without having to migrate liquidity to new pools.
When executing Xfai V0 protocol related functions such as swap, mint, burn, etc., it is not advised to interact with the core contract directly, as it does not perform important safety checks. Most interactions with the Xfai DEX go through the periphery contract, which then contacts the core contract. Developers interacting with Xfai should always try to interact with the periphery contract.
The INFT contract is the Infinity NFT contract responsible for INFT issuance, INFT fee collection, staking, harvesting, etc. INFT holders accumulate fees from the Xfai protocol.