The XchangeFactory contract is a factory contract that allows the creation of token pairs for a decentralized exchange.
It includes functions for setting addresses, managing trusted and failsafe liquidator addresses, and creating new pairs of tokens.
interface IXchangeFactory {}
interface IXchangePair {}
interface IXchangeERC20 {}
interface IERC20 {}
interface IXchangeDiscountAuthority {}
interface IUniswapV2Callee {}
Xchange Factory Contract interfaces with multiple interfaces. These interfaces define the required functions, events, and structures that need to be implemented in the respective contracts to ensure proper functionality and interaction within the Xchange ecosystem.
IXchangeFactory: Provides functions and events related to the XchangeFactory contract, including pair creation, trusted address management, and fee settings.IXchangePair: Represents the interface for a pair of tokens in the XchangePair contract. It includes functions for token swapping, liquidity minting/burning, and balance synchronization.IXchangeERC20: Represents the interface for an ERC20 token used in the XchangePair contract. It includes functions for token transfers, approvals, and permit functionality.IERC20: Represents the standard ERC20 interface with basic token-related functions such as name, symbol, decimals, balanceOf, allowance, transfer, and transferFrom.IXchangeDiscountAuthority: Provides a function to retrieve the fee percentage for a given address.IUniswapV2Callee: Represents the interface for a contract that can be called by the UniswapV2 router during token swaps.
contract XchangeERC20 is IXchangeERC20 {}
contract XchangePair is IXchangePair, XchangeERC20 {}
The XchangeERC20 contract is an implementation of the IXchangeERC20 interface. It represents an ERC20 token with additional functionality specific to the XchangePair contract.
The XchangePair contract is an implementation of the IXchangePair interface and inherits from the XchangeERC20 contract. It represents a pair of tokens in the Xchange ecosystem and includes functions for token swapping, liquidity management, fee calculations, and synchronization with token balances.
address public feeTo;
address public discountAuthority;
mapping(address => bool) _isTrusted;
mapping(address => bool) _isFailSafeLiquidator;
mapping(address => mapping(address => address)) public getPair;
mapping(address => bool) public isPair;
address[] public allPairs;
// Pair Address => token address => Is in the pair
mapping(address => mapping(address => bool)) public pairTokens;
