Fraction Protocol

DiamondFactory

Factory for creating and configuring Tokenizer Platform instances based on the EIP-2535 diamond architecture. This process involves deploying a diamond proxy instance (see FractionalizationDiamond.sol), adding appropriate facets via the diamondCut operation, and initializing the associated storage of the diamond proxy.

_This contract supports Meta Transactions (see EIP-2771).

NOTE:

  • This factory can also be used to create and configure Staking Platforms._

factoryOwner

address factoryOwner

The owner of this contract.

InvalidZeroAddress

error InvalidZeroAddress()

Thrown when the zero address is provided as input.

NotFactoryOwner

error NotFactoryOwner(address invalidAccount)

Thrown when the caller is not the owner of this contract.

CannotUpdateToSameForwarder

error CannotUpdateToSameForwarder()

Thrown when the provided address for Forwarder is the same as the current one in changeTrustedForwarder().

ArrayLengthMismatch

error ArrayLengthMismatch(uint256 selectorsLength, uint256 dataLenght)

Thrown when the lengths of initSelectors and initData do not match in _deployAndInitializeDiamond().

TrustedForwarderChanged

event TrustedForwarderChanged(address oldForwarder, address newTrustedForwarder)

Emitted at changeTrustedForwarder().

FactoryOwnershipTransferred

event FactoryOwnershipTransferred(address oldOwner, address newOwner)

Emitted at transferFactoryOwnership().

DiamondDeployedAndInitialized

event DiamondDeployedAndInitialized(address diamondAddress, address admin, address owner)

Emitted at deployAndInitializeDiamond() and deployAndInitializeDiamondWithOwnershipTransfer().

constructor

constructor(address owner_, address trustedForwarder_) public

Constructor.

Emits a {FactoryOwnershipTransferred} and a {TrustedForwarderChanged} event.

Parameters

NameTypeDescription
owner_addressThe address to be granted ownership of this contract (i.e., DiamondFactory.sol).
trustedForwarder_addressThe address to set as the designated trusted Forwarder (see EIP-2771).

changeTrustedForwarder

function changeTrustedForwarder(address newTrustedForwarder) external

Replaces the current trusted Forwarder with a new one.

_See EIP-2771.

Emits a {TrustedForwarderChanged} event._

Parameters

NameTypeDescription
newTrustedForwarderaddressThe address of the new trusted Forwarder.

transferFactoryOwnership

function transferFactoryOwnership(address newFactoryOwner) external

Transfers ownership of this contract to newFactoryOwner.

Emits a {FactoryOwnershipTransferred} event.

Parameters

NameTypeDescription
newFactoryOwneraddressThe address to be granted ownership of this contract.

deployAndInitializeDiamond

function deployAndInitializeDiamond(struct IERC2535DiamondCutInternal.FacetCut[] facetCuts, bytes4[] initSelectors, bytes[] initData, address admin) external returns (address diamondAddr)

Creates and configures a Tokenizer Platform instance.

_This function deploys a FractionalizationDiamond.sol instance, adds the specified facets (facetCuts), initializes the diamond's associated storage using the provided initSelectors and initData, and assigns admin as the administrator of the newly created Tokenizer Platform.

Emits the following events:

  • {DiamondDeployedAndInitialized}
  • {DiamondCut} (see DiamondWritableInternal.sol)
  • {AccessControlInitialized} and {AdminChanged} (see AccessControlFacet.sol)
  • {OwnershipTransferred} (see Diamond OwnableInternal.sol)

IMPORTANT:

  • The owner of the deployed Diamond is this contract (DiamondFactory.sol).
  • The admin of a Tokenizer Platform is distinct from the owner of the associated FractionalizationDiamond.sol (diamond proxy) and does not have the same privileges. For details, see SolidStateDiamond.sol and SafeOwnable.sol.
  • Do not provide the initialization selector of AccessControlFacet in initSelectors.
  • Do not provide the initialization data for init function of AccessControlFacet in initData._

Parameters

NameTypeDescription
facetCutsstruct IERC2535DiamondCutInternal.FacetCut[]See IERC2535DiamondCutInternal.FacetCut (The targeted Facets to add).
initSelectorsbytes4[]Selectors of init functions of Facets (exclude the init selector of AccessControlFacet).
initDatabytes[]Encoded data for initialization (exclude the init data for init function of AccessControlFacet).
adminaddressThe account to be assigned as the administrator of the created Tokenizer Platform.

Return Values

NameTypeDescription
diamondAddraddressThe address of the deployed diamond proxy.

deployAndInitializeDiamondWithOwnershipTransfer

function deployAndInitializeDiamondWithOwnershipTransfer(struct IERC2535DiamondCutInternal.FacetCut[] facetCuts, bytes4[] initSelectors, bytes[] initData, address admin, address newOwner) external returns (address diamondAddr)

Creates and configures a Tokenizer Platform instance and transfers ownership to the specified owner.

_This function deploys a FractionalizationDiamond.sol instance, adds the specified facets (facetCuts), initializes the diamond's associated storage using the provided initSelectors and initData, assigns admin as the administrator of the newly created Tokenizer Platform and transfers ownership of the diamond proxy to owner.

Emits the following events:

  • {DiamondDeployedAndInitialized}
  • {DiamondCut} (see DiamondWritableInternal.sol)
  • {AccessControlInitialized} and {AdminChanged} (see AccessControlFacet.sol)
  • {OwnershipTransferred} (see Diamond OwnableInternal.sol)

IMPORTANT:

  • The owner of the deployed Diamond will be the newOwner account.
  • The admin of a Tokenizer Platform is distinct from the owner of the associated FractionalizationDiamond.sol (diamond proxy) and does not have the same privileges. For details, see SolidStateDiamond.sol and SafeOwnable.sol.
  • The admin and newOwner can be the same account.
  • Do not provide the initialization selector of AccessControlFacet in initSelectors.
  • Do not provide the initialization data for init function of AccessControlFacet in initData._

Parameters

NameTypeDescription
facetCutsstruct IERC2535DiamondCutInternal.FacetCut[]See IERC2535DiamondCutInternal.FacetCut (The targeted Facets to add).
initSelectorsbytes4[]Selectors of init functions of Facets (exclude the init selector of AccessControlFacet).
initDatabytes[]Encoded data for initialization (exclude the init data for init function of AccessControlFacet).
adminaddressThe account to be assigned as the administrator of the created Tokenizer Platform.
newOwneraddressThe account to be granted ownership of the deployed diamond proxy.

Return Values

NameTypeDescription
diamondAddraddressThe address of the deployed diamond proxy.

_deployAndInitializeDiamond

function _deployAndInitializeDiamond(struct IERC2535DiamondCutInternal.FacetCut[] facetCuts, bytes4[] initSelectors, bytes[] initData, address admin) internal returns (address diamondAddr)

Internal version of deployAndInitializeDiamond().

Called by deployAndInitializeDiamond() and deployAndInitializeDiamondWithOwnershipTransfer().

Parameters

NameTypeDescription
facetCutsstruct IERC2535DiamondCutInternal.FacetCut[]See IERC2535DiamondCutInternal.FacetCut.
initSelectorsbytes4[]Selectors of init functions of Facets.
initDatabytes[]Encoded data for initialization.
adminaddressThe account to be assigned as the administrator of the created Tokenizer Platform.

Return Values

NameTypeDescription
diamondAddraddressThe address of the deployed diamond proxy.