Factory
The xSwapFactory contract is a core component of the xSwap protocol, designed to streamline the creation and management of token pairs and liquidity pools within the decentralized exchange (DEX). The xSwapFactory introduces a robust framework for DeFi interactions on the platform.
Key Functionalities of xSwapFactory
Events
PairCreated: This event is emitted whenever a new pair is created through the xSwapFactory. It logs the addresses of the two tokens (
token0andtoken1), the address of the newly created pair, and a sequential identifier for the pair.token0is always sorted to be lesser thantoken1to ensure consistent ordering.The sequential identifier starts at 1 for the first pair created and increments with each new pair.
Read-Only Functions
getPair: Given the addresses of two tokens (
tokenAandtokenB), this function returns the address of the pair contract if it exists, or the zero address otherwise.The order of
tokenAandtokenBis interchangeable.Pair addresses can be deterministically calculated using the SDK for predictable interactions.
allPairs: This function retrieves the address of a pair based on its sequential creation order within the factory.
Input is 0-indexed;
0would return the first pair created,1the second, and so on.
allPairsLength: Returns the total count of pairs created by the xSwapFactory to date, providing insight into the protocol's liquidity diversity.
feeTo: Returns the address designated to receive trading fees collected by the protocol, part of xSwap's incentive mechanism for liquidity providers.
feeToSetter: Identifies the address with the authority to modify the
feeToaddress, ensuring controlled management of protocol incentives.
State-Changing Functions
createPair: Initiates the creation of a new liquidity pair for two tokens if it doesn't already exist. This function is critical for expanding the protocol's trading capabilities.
Emits a
PairCreatedevent upon successful creation.tokenAandtokenBare interchangeable, promoting flexibility in pair creation.
Last updated