UnifiFactory.sol

Primary Uses - The uTrade V2 Factory contract creates an LP token for any pairs listed on uTrade V2, and indexes them for easy retrieval. In addition, it can return the address of the LP token based on a call of the addresses of the two tokens that make up the liquidity pool.

uTrade V2 Factory Code / Interfaces

uTrade V2 Factory Contract Addresses

Events

PairCreated

event PairCreated(address indexed token0, address indexed token1, address pair, uint);

Anytime a pair is created on uTrade V2 using the createPair function, a PairCreated event is emitted. Contracts can be deployed to listen for new pairs on the uTrade V2 BTTC Factory address.

  • token0 is the token address of the first asset in the token pair.

  • token1 is the token address of the second asset in the token pair.

  • pair is the address of the newly created uTrade V2 liquidity pool.

  • uint refers to the index of this uTrade V2 Factory. For example, the first liquidity pool created on uTrade V2 is 1, the second liquidity pool is 2, and so on. This number can used with the allPairs(uint) to return the address. The current number, and therefore the total number of LP pools on uTrade V2 AVAX, can be accessed using the allPairsLength function.

Read-Only Functions

getPair

function getPair(address tokenA, address tokenB) external view returns (address pair);

A call to the getPair function returns the address of the pair for tokenA and tokenB.

  • If the pair does not exist, the call will return address(0).

  • The order of the tokens is irrelevant in this call. For example, a call for USDT.t, WBTT will return the same pair address as WBTT, USDT.t

allPairs

function allPairs(uint) external view returns (address pair);

A call to the allPairs function returns the address of a pair based on the indexed uint value assigned upon creation of the LP.

  • For example, allPairs(0) will return the first pair created on uTrade V2 BTTC.

  • If the index number is too high, as in, there aren't enough pairs created yet, the function will return address(0).

allPairsLength

function allPairsLength() external view returns (uint);

A call to the allPairsLength function returns the current number of pairs.

  • For example, if there are 201 total liquidity pool pairs on uTrade V2 BTTC, this call will return 200 as an uint value.

feeTo

function feeTo() external view returns (address);

A call to the feeTo function returns the percentage of trading fees that Unifi Protocol receives.

  • Due to the nature of UP Token economics, this is set to zero, but is preserved for flexibility in the future.

feeToSetter

function feeToSetter() external view returns (address);

A call to the feeToSetter function returns the address to which the feeTo would send trading fees, if trading fees were collected.

State-Changing Functions

createPair

function createPair(address tokenA, address tokenB) external returns (address pair);

Creates a liquidity pool pair for tokenA and tokenB if one does not currently exist. After the function is confirmed on chain, a PairCreated event is emitted.

Interface Code

interface UnifiFactory {  
  event PairCreated(address indexed token0, address indexed token1, address pair, uint);
  function getPair(address tokenA, address tokenB) external view returns (address pair);  
  function allPairs(uint) external view returns (address pair);  
  function allPairsLength() external view returns (uint);
  function feeTo() external view returns (address);  function feeToSetter() external view returns (address);
  function createPair(address tokenA, address tokenB) external returns (address pair);
  }

Last updated