Factory
The Factory smart contract oversees the full functionality of token pair registration and transactions in MESHswap.
Events
Read-Only Functions
State-Changing Functions
event ChangeCreateFee(uint _createFee);
- An event to change the Pool Contract Creation Fee when adding a new liquidity pool pair
event CreatePool(address token0, uint amount0, address token1, uint amount1, uint fee, address exchange, uint exid);
- Event to create new liquidity pool
- parameters
token0
: token0 address in pairamount0
: token0 amount in pooltoken1
: token1 address in pairamount1
: token1 amount in poolfee
: pool fee rateexchange
: exchange contract address of this poolexid
: exchange id
- WETH contract address.
- MESH contract address
- Returns the total number of pairs created through the factory so far.
- Returns the total number of pairs created through the factory so far.
- The amount of MESH that must be paired to create a new liquidity pool pair
- Factory Contract Address
- The next Governance Contract Address set in advance.
- List of liquidity pool pairings
- Each item saves the smart contract address of the liquidity pool
- Returns if the contract for the given liquidiy pool pair exists
- The contract address corresponding to the token0, token1 pair
- When the addresses of token0 and token1 are inputted, this returns the contract address of the corresponding pairing
- Returns the same contract address regardless of the order of the liquidity pool pairing tokens:tokenToPool[token0][token1] == tokenToPool[token1][token0]
function allPairs(uint) external view returns (address pair);
- Returns the address of the
n
th pair (0
-indexed) created through the factory
function getPair(address token0, address token1) external view returns (address pair);
- Returns the address of the pair for
token0
andtoken1
, if it has been created, elseaddress(0)
(0x0000000000000000000000000000000000000000
).
function getPoolAddress(uint idx) public view returns (address)
- Returns the address of the
n
th pair (0
-indexed) created through the factory
function createETHPool(address token, uint amount, uint fee) public payable
- A method called to add a liquidity pair with one side as MATIC
- The wallet that calls this must have MESH greater than or equal to createFee
- Token for when the WMATIC / ERC-20 pair to be registered has never been registered before
- Parameters
token
: ERC-20 token address to add liquidityamount
: the amount of tokens (ERC-20) to be provided for the initial liquidityfee
: Sets the initial fee value for liquidity pairs- A value between 0 and 100
- Meaning: 0 -> 0%, 100 -> 1%
msg.value
: MATIC quantity to initially supply liquidity- Delivers the transaction value without specifying otherwise
function createTokenPool(address token0, uint amount0, address token1, uint amount1, uint fee) public
- Method called to add liquidity pair in case of ERC-20 token pair
- The wallet calling the MESH above createFee must have it.
- parameter
token0
: The address of the first tokenamount0
: The quantity of the first token that supplies the initial liquiditytoken1
: The address of the second tokenamount1
: The quantity of the second token that supplies the initial liquidityfee
: Sets the initial fee value for liquidity pairs
Last modified 4mo ago