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.
Return Values:
None
uint
Total number of created pairs.
getInitCodeHash
Retrieves the keccak256 hash of the creation code for the Pair
contract.
Return Values:
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.
Parameters:
tokenA
address
Address of the first token.
tokenB
address
Address of the second token.
Return Values:
pair
address
Address of the newly created Pair contract.
setController
Sets a new controller address. Can only be called by the current controller.
Parameters:
_controller
address
The new controller address.
becomeController
Allows the pending controller to become the new controller. Must be called by the pending controller.
open2public
Opens the factory to public creation of pairs. Must be called by the current controller.
Last updated