ModuleFactory
Inherits: MakinaXContext, AccessManagedUpgradeable, IModuleFactory
Constants
MAX_FEE_RATE
Full scale value for fee rates.
uint256 private constant MAX_FEE_RATE = 1e18;State Variables
isMakinaXModule
Module => Whether the module was deployed by this factory.
mapping(address module => bool isModule) public isMakinaXModule;Parameters
| Name | Type | Description |
|---|---|---|
| module | address |
Returns
| Name | Type | Description |
|---|---|---|
| isModule | bool |
defaultProvider
Provider enforced by default on modules deployed through the free path.
address public defaultProvider;Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
defaultSwapFeeRate
Swap fee rate enforced by default on modules deployed through the free path, 1e18 = 100%.
uint256 public defaultSwapFeeRate;Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
freeDeployment
Whether free module deployment is currently enabled.
bool public freeDeployment;Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
Functions
constructor
constructor(address _registry) MakinaXContext(_registry);Parameters
| Name | Type | Description |
|---|---|---|
| _registry | address |
initialize
function initialize(
address initialAuthority,
address initialDefaultProvider,
uint256 initialDefaultSwapFeeRate,
bool initialFreeDeployment
) external initializer;Parameters
| Name | Type | Description |
|---|---|---|
| initialAuthority | address | |
| initialDefaultProvider | address | |
| initialDefaultSwapFeeRate | uint256 | |
| initialFreeDeployment | bool |
createModule
Deploys a new MakinaXModule clone with caller-provided service parameters.
Restricted to authorized deployers.
function createModule(
IMakinaXModule.MakinaXModuleInitParams calldata params,
IMakinaXModule.MakinaXModuleServiceParams calldata serviceParams,
bytes32 salt,
bytes32 referralKey
) external restricted returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| params | IMakinaXModule.MakinaXModuleInitParams | The strategy and risk initialization parameters for the MakinaXModule. |
| serviceParams | IMakinaXModule.MakinaXModuleServiceParams | The protocol-controlled service initialization parameters. |
| salt | bytes32 | The salt used for deterministic deployment of the module clone. |
| referralKey | bytes32 | The referral key associated with the module creation. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address | The address of the newly deployed MakinaXModule. |
createModuleFree
Deploys a new MakinaXModule clone, with service parameters enforced by the factory.
Callable by anyone while free deployment is enabled.
function createModuleFree(IMakinaXModule.MakinaXModuleInitParams calldata params, bytes32 salt, bytes32 referralKey)
external
returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| params | IMakinaXModule.MakinaXModuleInitParams | The strategy and risk initialization parameters for the MakinaXModule. |
| salt | bytes32 | The caller-scoped salt used for deterministic deployment of the module clone. |
| referralKey | bytes32 | The referral key associated with the module creation. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address | The address of the newly deployed MakinaXModule. |
setDefaultProvider
Sets the provider enforced on free deployment.
function setDefaultProvider(address newDefaultProvider) external restricted;Parameters
| Name | Type | Description |
|---|---|---|
| newDefaultProvider | address | The new default provider address. |
setDefaultSwapFeeRate
Sets the swap fee rate enforced on free deployment.
function setDefaultSwapFeeRate(uint256 newDefaultSwapFeeRate) external restricted;Parameters
| Name | Type | Description |
|---|---|---|
| newDefaultSwapFeeRate | uint256 | The new default swap fee rate, 1e18 = 100%. |
setFreeDeployment
Enables or disables free module deployment.
function setFreeDeployment(bool enabled) external restricted;Parameters
| Name | Type | Description |
|---|---|---|
| enabled | bool | True to enable free deployment, false to disable it. |
_createModule
Internal logic to deploy and initialize a new MakinaXModule clone.
function _createModule(
IMakinaXModule.MakinaXModuleInitParams calldata params,
IMakinaXModule.MakinaXModuleServiceParams memory serviceParams,
bytes32 salt,
bytes32 referralKey
) private returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| params | IMakinaXModule.MakinaXModuleInitParams | |
| serviceParams | IMakinaXModule.MakinaXModuleServiceParams | |
| salt | bytes32 | |
| referralKey | bytes32 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
_setDefaultProvider
Internal setter for the default provider.
function _setDefaultProvider(address newDefaultProvider) internal;Parameters
| Name | Type | Description |
|---|---|---|
| newDefaultProvider | address |
_setDefaultSwapFeeRate
Internal setter for the default swap fee rate.
function _setDefaultSwapFeeRate(uint256 newDefaultSwapFeeRate) internal;Parameters
| Name | Type | Description |
|---|---|---|
| newDefaultSwapFeeRate | uint256 |
_setFreeDeployment
Internal setter for free deployment.
function _setFreeDeployment(bool enabled) internal;Parameters
| Name | Type | Description |
|---|---|---|
| enabled | bool |
_checkFeeRate
Performs sanity check on a fee rate.
function _checkFeeRate(uint256 rate) internal pure;Parameters
| Name | Type | Description |
|---|---|---|
| rate | uint256 |