DexFactoryVariables ​
_deployers ​
mapping(address => bool) _deployers
deployer can deploy new Dex Pool contract owner can add/remove deployer. Owner is deployer by default.
_globalAuths ​
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 ​
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 ​
uint256 _totalDexes
total no of dexes deployed by the factory only addresses that have deployer role or owner can deploy new dex pool.
_dexDeploymentLogics ​
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 ​
constructor(address owner_) internal
DexFactoryEvents ​
LogDexDeployed ​
event LogDexDeployed(address dex, uint256 dexId)
Emitted when a new dex is deployed.
Parameters ​
Name | Type | Description |
---|---|---|
dex | address | The address of the newly deployed dex. |
dexId | uint256 | The id of the newly deployed dex. |
LogSetDeployer ​
event LogSetDeployer(address deployer, bool allowed)
Emitted when the deployer is modified by owner.
Parameters ​
Name | Type | Description |
---|---|---|
deployer | address | Address whose deployer status is updated. |
allowed | bool | Indicates whether the address is authorized as a deployer or not. |
LogSetGlobalAuth ​
event LogSetGlobalAuth(address globalAuth, bool allowed)
Emitted when the globalAuth is modified by owner.
Parameters ​
Name | Type | Description |
---|---|---|
globalAuth | address | Address whose globalAuth status is updated. |
allowed | bool | Indicates whether the address is authorized as a deployer or not. |
LogSetDexAuth ​
event LogSetDexAuth(address dexAuth, bool allowed, address dex)
Emitted when the dexAuth is modified by owner.
Parameters ​
Name | Type | Description |
---|---|---|
dexAuth | address | Address whose dexAuth status is updated. |
allowed | bool | Indicates whether the address is authorized as a deployer or not. |
dex | address | Address of the specific dex related to the authorization change. |
LogSetDexDeploymentLogic ​
event LogSetDexDeploymentLogic(address dexDeploymentLogic, bool allowed)
Emitted when the dex deployment logic is modified by owner.
Parameters ​
Name | Type | Description |
---|---|---|
dexDeploymentLogic | address | The address of the dex deployment logic contract. |
allowed | bool | Indicates whether the address is authorized as a deployer or not. |
DexFactoryCore ​
constructor ​
constructor(address owner_) internal
validAddress ​
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 ​
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 ​
Name | Type | Description |
---|---|---|
deployer_ | address | The address to be set as deployer. |
allowed_ | bool | A boolean indicating whether the specified address is allowed to deploy dexes. |
setGlobalAuth ​
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 ​
Name | Type | Description |
---|---|---|
globalAuth_ | address | The address to be set as global authorization. |
allowed_ | bool | A boolean indicating whether the specified address is allowed to update any dex config. |
setDexAuth ​
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 ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the dex for which the authorization is being set. |
dexAuth_ | address | The address to be set as dex authorization. |
allowed_ | bool | A boolean indicating whether the specified address is allowed to update the specific dex config. |
setDexDeploymentLogic ​
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 ​
Name | Type | Description |
---|---|---|
deploymentLogic_ | address | The address of the dex deployment logic contract to be set. |
allowed_ | bool | A boolean indicating whether the specified address is allowed to deploy new type of dex. |
spell ​
function spell(address target_, bytes data_) external returns (bytes response_)
Spell allows owner aka governance to do any arbitrary call on factory
Parameters ​
Name | Type | Description |
---|---|---|
target_ | address | Address to which the call needs to be delegated |
data_ | bytes | Data to execute at the delegated address |
isDeployer ​
function isDeployer(address deployer_) public view returns (bool)
Checks if the provided address (deployer_
) is authorized as a deployer.
Parameters ​
Name | Type | Description |
---|---|---|
deployer_ | address | The address to be checked for deployer authorization. |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | bool | Returns true if the address is a deployer, otherwise false . |
isGlobalAuth ​
function isGlobalAuth(address globalAuth_) public view returns (bool)
Checks if the provided address (globalAuth_
) has global dex authorization privileges.
Parameters ​
Name | Type | Description |
---|---|---|
globalAuth_ | address | The address to be checked for global authorization privileges. |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | bool | Returns true if the given address has global authorization privileges, otherwise false . |
isDexAuth ​
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 ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the dex to check. |
dexAuth_ | address | The address to be checked for dex authorization privileges. |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | bool | Returns true if the given address has dex authorization privileges for the specified dex, otherwise false . |
isDexDeploymentLogic ​
function isDexDeploymentLogic(address dexDeploymentLogic_) public view returns (bool)
Checks if the provided (dexDeploymentLogic_
) address has authorization for dex deployment.
Parameters ​
Name | Type | Description |
---|---|---|
dexDeploymentLogic_ | address | The address of the dex deploy logic to check for authorization privileges. |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | bool | Returns true if the given address has authorization privileges for dex deployment, otherwise false . |
DexFactoryDeployment ​
implements DexFactory deploy dex related methods.
_deploy ​
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 ​
Name | Type | Description |
---|---|---|
bytecode_ | bytes | The bytecode of the contract to be deployed. |
Return Values ​
Name | Type | Description |
---|---|---|
address_ | address | Returns the address of the deployed contract. |
deployDex ​
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 ​
Name | Type | Description |
---|---|---|
dexDeploymentLogic_ | address | The address of the dex deployment logic contract. |
dexDeploymentData_ | bytes | The data to be used for dex deployment. |
Return Values ​
Name | Type | Description |
---|---|---|
dex_ | address | Returns the address of the newly deployed dex. |
getDexAddress ​
function getDexAddress(uint256 dexId_) public view returns (address dex_)
Computes the address of a dex based on its given ID (dexId_
).
Parameters ​
Name | Type | Description |
---|---|---|
dexId_ | uint256 | The ID of the dex. |
Return Values ​
Name | Type | Description |
---|---|---|
dex_ | address | Returns the computed address of the dex. |
isDex ​
function isDex(address dex_) public view returns (bool)
Checks if a given address (dex_
) corresponds to a valid dex.
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The dex address to check. |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | bool | Returns true if the given address corresponds to a valid dex, otherwise false . |
totalDexes ​
function totalDexes() external view returns (uint256)
Returns the total number of dexes deployed by the factory.
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | Returns 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 ​
constructor(address owner_) public