Skip to content

DexFactoryVariables ​

_deployers ​

solidity
mapping(address => bool) _deployers

deployer can deploy new Dex Pool contract owner can add/remove deployer. Owner is deployer by default.

_globalAuths ​

solidity
mapping(address => bool) _globalAuths

global auths can update any dex pool config. owner can add/remove global auths. Owner is global auth by default.

_dexAuths ​

solidity
mapping(address => mapping(address => bool)) _dexAuths

dex auths can update specific dex config. owner can add/remove dex auths. Owner is dex auth by default. dex => auth => add/remove

_totalDexes ​

solidity
uint256 _totalDexes

total no of dexes deployed by the factory only addresses that have deployer role or owner can deploy new dex pool.

_dexDeploymentLogics ​

solidity
mapping(address => bool) _dexDeploymentLogics

dex deployment logics for deploying dex pool These logic contracts hold the deployment logics of specific dexes and are called via .delegatecall inside deployDex(). only addresses that have owner can add/remove new dex deployment logic.

constructor ​

solidity
constructor(address owner_) internal

DexFactoryEvents ​

LogDexDeployed ​

solidity
event LogDexDeployed(address dex, uint256 dexId)

Emitted when a new dex is deployed.

Parameters ​

NameTypeDescription
dexaddressThe address of the newly deployed dex.
dexIduint256The id of the newly deployed dex.

LogSetDeployer ​

solidity
event LogSetDeployer(address deployer, bool allowed)

Emitted when the deployer is modified by owner.

Parameters ​

NameTypeDescription
deployeraddressAddress whose deployer status is updated.
allowedboolIndicates whether the address is authorized as a deployer or not.

LogSetGlobalAuth ​

solidity
event LogSetGlobalAuth(address globalAuth, bool allowed)

Emitted when the globalAuth is modified by owner.

Parameters ​

NameTypeDescription
globalAuthaddressAddress whose globalAuth status is updated.
allowedboolIndicates whether the address is authorized as a deployer or not.

LogSetDexAuth ​

solidity
event LogSetDexAuth(address dexAuth, bool allowed, address dex)

Emitted when the dexAuth is modified by owner.

Parameters ​

NameTypeDescription
dexAuthaddressAddress whose dexAuth status is updated.
allowedboolIndicates whether the address is authorized as a deployer or not.
dexaddressAddress of the specific dex related to the authorization change.

LogSetDexDeploymentLogic ​

solidity
event LogSetDexDeploymentLogic(address dexDeploymentLogic, bool allowed)

Emitted when the dex deployment logic is modified by owner.

Parameters ​

NameTypeDescription
dexDeploymentLogicaddressThe address of the dex deployment logic contract.
allowedboolIndicates whether the address is authorized as a deployer or not.

DexFactoryCore ​

constructor ​

solidity
constructor(address owner_) internal

validAddress ​

solidity
modifier validAddress(address value_)

validates that an address is not the zero address

DexFactoryAuth ​

Implements Dex Factory auth-only callable methods. Owner / auths can set various config values and can define the allow-listed deployers.

setDeployer ​

solidity
function setDeployer(address deployer_, bool allowed_) external

Sets an address (deployer_) as allowed deployer or not. This function can only be called by the owner.

Parameters ​

NameTypeDescription
deployer_addressThe address to be set as deployer.
allowed_boolA boolean indicating whether the specified address is allowed to deploy dexes.

setGlobalAuth ​

solidity
function setGlobalAuth(address globalAuth_, bool allowed_) external

Sets an address (globalAuth_) as a global authorization or not. This function can only be called by the owner.

Parameters ​

NameTypeDescription
globalAuth_addressThe address to be set as global authorization.
allowed_boolA boolean indicating whether the specified address is allowed to update any dex config.

setDexAuth ​

solidity
function setDexAuth(address dex_, address dexAuth_, bool allowed_) external

Sets an address (dexAuth_) as allowed dex authorization or not for a specific dex (dex_). This function can only be called by the owner.

Parameters ​

NameTypeDescription
dex_addressThe address of the dex for which the authorization is being set.
dexAuth_addressThe address to be set as dex authorization.
allowed_boolA boolean indicating whether the specified address is allowed to update the specific dex config.

setDexDeploymentLogic ​

solidity
function setDexDeploymentLogic(address deploymentLogic_, bool allowed_) public

Sets an address as allowed dex deployment logic (deploymentLogic_) contract or not. This function can only be called by the owner.

Parameters ​

NameTypeDescription
deploymentLogic_addressThe address of the dex deployment logic contract to be set.
allowed_boolA boolean indicating whether the specified address is allowed to deploy new type of dex.

spell ​

solidity
function spell(address target_, bytes data_) external returns (bytes response_)

Spell allows owner aka governance to do any arbitrary call on factory

Parameters ​

NameTypeDescription
target_addressAddress to which the call needs to be delegated
data_bytesData to execute at the delegated address

isDeployer ​

solidity
function isDeployer(address deployer_) public view returns (bool)

Checks if the provided address (deployer_) is authorized as a deployer.

Parameters ​

NameTypeDescription
deployer_addressThe address to be checked for deployer authorization.

Return Values ​

NameTypeDescription
[0]boolReturns true if the address is a deployer, otherwise false.

isGlobalAuth ​

solidity
function isGlobalAuth(address globalAuth_) public view returns (bool)

Checks if the provided address (globalAuth_) has global dex authorization privileges.

Parameters ​

NameTypeDescription
globalAuth_addressThe address to be checked for global authorization privileges.

Return Values ​

NameTypeDescription
[0]boolReturns true if the given address has global authorization privileges, otherwise false.

isDexAuth ​

solidity
function isDexAuth(address dex_, address dexAuth_) public view returns (bool)

Checks if the provided address (dexAuth_) has dex authorization privileges for the specified dex (dex_).

Parameters ​

NameTypeDescription
dex_addressThe address of the dex to check.
dexAuth_addressThe address to be checked for dex authorization privileges.

Return Values ​

NameTypeDescription
[0]boolReturns true if the given address has dex authorization privileges for the specified dex, otherwise false.

isDexDeploymentLogic ​

solidity
function isDexDeploymentLogic(address dexDeploymentLogic_) public view returns (bool)

Checks if the provided (dexDeploymentLogic_) address has authorization for dex deployment.

Parameters ​

NameTypeDescription
dexDeploymentLogic_addressThe address of the dex deploy logic to check for authorization privileges.

Return Values ​

NameTypeDescription
[0]boolReturns true if the given address has authorization privileges for dex deployment, otherwise false.

DexFactoryDeployment ​

implements DexFactory deploy dex related methods.

_deploy ​

solidity
function _deploy(bytes bytecode_) internal returns (address address_)

_Deploys a contract using the CREATE opcode with the provided bytecode (bytecode_). This is an internal function, meant to be used within the contract to facilitate the deployment of other contracts._

Parameters ​

NameTypeDescription
bytecode_bytesThe bytecode of the contract to be deployed.

Return Values ​

NameTypeDescription
address_addressReturns the address of the deployed contract.

deployDex ​

solidity
function deployDex(address dexDeploymentLogic_, bytes dexDeploymentData_) external returns (address dex_)

Deploys a new dex using the specified deployment logic dexDeploymentLogic_ and data dexDeploymentData_. Only accounts with deployer access or the owner can deploy a new dex.

Parameters ​

NameTypeDescription
dexDeploymentLogic_addressThe address of the dex deployment logic contract.
dexDeploymentData_bytesThe data to be used for dex deployment.

Return Values ​

NameTypeDescription
dex_addressReturns the address of the newly deployed dex.

getDexAddress ​

solidity
function getDexAddress(uint256 dexId_) public view returns (address dex_)

Computes the address of a dex based on its given ID (dexId_).

Parameters ​

NameTypeDescription
dexId_uint256The ID of the dex.

Return Values ​

NameTypeDescription
dex_addressReturns the computed address of the dex.

isDex ​

solidity
function isDex(address dex_) public view returns (bool)

Checks if a given address (dex_) corresponds to a valid dex.

Parameters ​

NameTypeDescription
dex_addressThe dex address to check.

Return Values ​

NameTypeDescription
[0]boolReturns true if the given address corresponds to a valid dex, otherwise false.

totalDexes ​

solidity
function totalDexes() external view returns (uint256)

Returns the total number of dexes deployed by the factory.

Return Values ​

NameTypeDescription
[0]uint256Returns the total number of dexes.

FluidDexFactory ​

creates Fluid dex protocol dexes, which are interacting with Fluid Liquidity to deposit / borrow funds. Dexes are created at a deterministic address, given an incrementing dexId (see getDexAddress()). Dexes can only be deployed by allow-listed deployer addresses.

Note the deployed dexes start out with no config at Liquidity contract. This must be done by Liquidity auths in a separate step, otherwise no deposits will be possible. This contract is not upgradeable. It supports adding new dex deployment logic contracts for new, future dexes.

constructor ​

solidity
constructor(address owner_) public