PairFactory

PairFactory is the contract that deploys DysonPair. Unlike Uniswap, Dyson allows multiple Pair instances for a trading pair of two tokens. Factory also serves as a beacon providing the current controller address for all pairs.

allPairsLength

Retrieves the total number of created pairs.

function allPairsLength() external view returns (uint)

Return Values:

NameTypeDescription

None

uint

Total number of created pairs.

getInitCodeHash

Retrieves the keccak256 hash of the creation code for the Pair contract.

function getInitCodeHash() external pure returns (bytes32)

Return Values:

NameTypeDescription

None

bytes32

Keccak256 hash of the Pair contract creation code.

createPair

Creates a new Pair contract with the specified token addresses and initializes it. This function introduces a mechanism to generate unique Pair contract instances in Solidity. This uniqueness is achieved through the utilization of a cryptographic hash known as salt. The salt is computed by encoding (hashing) a combination of token0, token1, and id. By incorporating salt, the function ensures that each created Pair contract possesses a distinctive identifier, guarding against the duplication of identical configurations.

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

Parameters:

NameTypeDescription

tokenA

address

Address of the first token.

tokenB

address

Address of the second token.

Return Values:

NameTypeDescription

pair

address

Address of the newly created Pair contract.

setController

Sets a new controller address. Can only be called by the current controller.

function setController(
    address _controller) external

Parameters:

NameTypeDescription

_controller

address

The new controller address.

becomeController

Allows the pending controller to become the new controller. Must be called by the pending controller.

function becomeController() external

open2public

Opens the factory to public creation of pairs. Must be called by the current controller.

function open2public() external

Last updated