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 (Solidity)
uTrade V2 Factory Interface as JSON
GitHub
uTrade V2 Factory Interface as Typescript
GitHub
Import statement codeblock (when available)

uTrade V2 Factory Contract Addresses

Network
Address
BSC Main Net
0xA5Ba037Ec16c45f8ae09e013C1849554C01385f5 (Link)
BSC Test Net
0xcAF0DFf51989Cee8f6437A7152001A42116170d5 (Link)

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 BSC 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 BSC, 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 BNB, UNFI will return the same pair address as UNFI, BNB.

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 BSC.
  • 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 BSC, 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);
}

Copy link
Outline
uTrade V2 Factory Code / Interfaces
uTrade V2 Factory Contract Addresses
PairCreated
Read-Only Functions
getPair
allPairs
allPairsLength
feeTo
feeToSetter
State-Changing Functions
createPair
Interface Code