Skip to content
LogoLogo

ModuleFactory

Git Source

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

NameTypeDescription
moduleaddress

Returns

NameTypeDescription
isModulebool

defaultProvider

Provider enforced by default on modules deployed through the free path.

address public defaultProvider;

Returns

NameTypeDescription
<none>address

defaultSwapFeeRate

Swap fee rate enforced by default on modules deployed through the free path, 1e18 = 100%.

uint256 public defaultSwapFeeRate;

Returns

NameTypeDescription
<none>uint256

freeDeployment

Whether free module deployment is currently enabled.

bool public freeDeployment;

Returns

NameTypeDescription
<none>bool

Functions

constructor

constructor(address _registry) MakinaXContext(_registry);

Parameters

NameTypeDescription
_registryaddress

initialize

function initialize(
        address initialAuthority,
        address initialDefaultProvider,
        uint256 initialDefaultSwapFeeRate,
        bool initialFreeDeployment
    ) external initializer;

Parameters

NameTypeDescription
initialAuthorityaddress
initialDefaultProvideraddress
initialDefaultSwapFeeRateuint256
initialFreeDeploymentbool

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

NameTypeDescription
paramsIMakinaXModule.MakinaXModuleInitParamsThe strategy and risk initialization parameters for the MakinaXModule.
serviceParamsIMakinaXModule.MakinaXModuleServiceParamsThe protocol-controlled service initialization parameters.
saltbytes32The salt used for deterministic deployment of the module clone.
referralKeybytes32The referral key associated with the module creation.

Returns

NameTypeDescription
<none>addressThe 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

NameTypeDescription
paramsIMakinaXModule.MakinaXModuleInitParamsThe strategy and risk initialization parameters for the MakinaXModule.
saltbytes32The caller-scoped salt used for deterministic deployment of the module clone.
referralKeybytes32The referral key associated with the module creation.

Returns

NameTypeDescription
<none>addressThe address of the newly deployed MakinaXModule.

setDefaultProvider

Sets the provider enforced on free deployment.

function setDefaultProvider(address newDefaultProvider) external restricted;

Parameters

NameTypeDescription
newDefaultProvideraddressThe new default provider address.

setDefaultSwapFeeRate

Sets the swap fee rate enforced on free deployment.

function setDefaultSwapFeeRate(uint256 newDefaultSwapFeeRate) external restricted;

Parameters

NameTypeDescription
newDefaultSwapFeeRateuint256The new default swap fee rate, 1e18 = 100%.

setFreeDeployment

Enables or disables free module deployment.

function setFreeDeployment(bool enabled) external restricted;

Parameters

NameTypeDescription
enabledboolTrue 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

NameTypeDescription
paramsIMakinaXModule.MakinaXModuleInitParams
serviceParamsIMakinaXModule.MakinaXModuleServiceParams
saltbytes32
referralKeybytes32

Returns

NameTypeDescription
<none>address

_setDefaultProvider

Internal setter for the default provider.

function _setDefaultProvider(address newDefaultProvider) internal;

Parameters

NameTypeDescription
newDefaultProvideraddress

_setDefaultSwapFeeRate

Internal setter for the default swap fee rate.

function _setDefaultSwapFeeRate(uint256 newDefaultSwapFeeRate) internal;

Parameters

NameTypeDescription
newDefaultSwapFeeRateuint256

_setFreeDeployment

Internal setter for free deployment.

function _setFreeDeployment(bool enabled) internal;

Parameters

NameTypeDescription
enabledbool

_checkFeeRate

Performs sanity check on a fee rate.

function _checkFeeRate(uint256 rate) internal pure;

Parameters

NameTypeDescription
rateuint256