SuperformFactory

Git Source

Inherits: ISuperformFactory

Author: Zeropoint Labs.

SPDX-License-Identifier: Apache-2.0

A secure, and easily queryable central point of access for all Superforms on any given chain,

State Variables

SYNC_IMPLEMENTATION_STATUS

bytes32 constant SYNC_IMPLEMENTATION_STATUS = keccak256("SYNC_IMPLEMENTATION_STATUS");

CHAIN_ID

uint64 public immutable CHAIN_ID;

xChainPayloadCounter

uint256 public xChainPayloadCounter;

superRegistry

ISuperRegistry public immutable superRegistry;

formImplementations

all form beacon addresses

address[] public formImplementations;

superforms

all superform ids

uint256[] public superforms;

formImplementation

If formImplementationId is 0, formImplementation is not part of the protocol

mapping(uint32 formImplementationId => address formBeaconAddress) public formImplementation;

formImplementationPaused

mapping(uint32 formImplementationId => bool paused) public formImplementationPaused;

vaultToSuperforms

mapping(address vault => uint256[] superformIds) public vaultToSuperforms;

vaultToFormImplementationId

mapping(address vault => uint256[] formImplementationId) public vaultToFormImplementationId;

vaultFormImplCombinationToSuperforms

mapping(bytes32 vaultFormImplementationCombination => uint256 superformIds) public vaultFormImplCombinationToSuperforms;

Functions

onlyEmergencyAdmin

modifier onlyEmergencyAdmin();

onlyProtocolAdmin

modifier onlyProtocolAdmin();

constructor

constructor(address superRegistry_);

Parameters

NameTypeDescription
superRegistry_addressthe superform registry contract

addFormImplementation

allows an admin to add a Form implementation to the factory

function addFormImplementation(
    address formImplementation_,
    uint32 formImplementationId_
)
    public
    override
    onlyProtocolAdmin;

Parameters

NameTypeDescription
formImplementation_addressis the address of a form implementation
formImplementationId_uint32is the id of the form implementation (generated off-chain and equal in all chains)

createSuperform

save the newly added address in the mapping and array registry

function createSuperform(
    uint32 formImplementationId_,
    address vault_
)
    public
    override
    returns (uint256 superformId_, address superform_);

Parameters

NameTypeDescription
formImplementationId_uint32is the form implementation we want to attach the vault to
vault_addressis the address of the vault

Returns

NameTypeDescription
superformId_uint256is the id of the created superform
superform_addressis the address of the created superform

changeFormImplementationPauseStatus

Same vault and beacon can be used only once to create superform

instantiate the superform.

this will always be unique because all chainIds are unique

Mapping vaults to formImplementationId for use in Backend

function changeFormImplementationPauseStatus(
    uint32 formImplementationId_,
    bool paused_,
    bytes memory extraData_
)
    external
    payable
    override
    onlyEmergencyAdmin;

Parameters

NameTypeDescription
formImplementationId_uint32is the id of the form implementation
paused_bool
extraData_bytesis optional & passed when broadcasting of status is needed

stateSyncBroadcast

broadcast the change in status to the other destination chains

function stateSyncBroadcast(bytes memory data_) external payable override;

Parameters

NameTypeDescription
data_bytesis the cross-chain superform id

getFormImplementation

this function is only accessible through broadcast registry

function getFormImplementation(uint32 formImplementationId_) external view override returns (address);

Parameters

NameTypeDescription
formImplementationId_uint32is the id of the form implementation

Returns

NameTypeDescription
<none>addressformImplementation_ is the address of the form implementation

isFormImplementationPaused

returns the paused status of form implementation

function isFormImplementationPaused(uint32 formImplementationId_) external view override returns (bool);

Parameters

NameTypeDescription
formImplementationId_uint32is the id of the form implementation

Returns

NameTypeDescription
<none>boolpaused_ is the current paused status of the form formImplementationId_

getAllSuperformsFromVault

Reverse query of getSuperform, returns all superforms for a given vault

function getAllSuperformsFromVault(address vault_)
    external
    view
    override
    returns (uint256[] memory superformIds_, address[] memory superforms_);

Parameters

NameTypeDescription
vault_addressis the address of a vault

Returns

NameTypeDescription
superformIds_uint256[]is the id of the superform
superforms_address[]is the address of the superform

getSuperform

returns the address of a superform

function getSuperform(uint256 superformId_)
    external
    pure
    override
    returns (address superform_, uint32 formImplementationId_, uint64 chainId_);

Parameters

NameTypeDescription
superformId_uint256is the id of the superform

Returns

NameTypeDescription
superform_addressis the address of the superform
formImplementationId_uint32is the id of the form implementation
chainId_uint64is the chain id

getAllSuperforms

Returns all Superforms

function getAllSuperforms()
    external
    view
    override
    returns (uint256[] memory superformIds_, address[] memory superforms_);

Returns

NameTypeDescription
superformIds_uint256[]is the id of the superform
superforms_address[]vaults_ is the address of the vault

getFormCount

returns the number of forms

function getFormCount() external view override returns (uint256 forms_);

Returns

NameTypeDescription
forms_uint256is the number of forms

getSuperformCount

returns the number of superforms

function getSuperformCount() external view override returns (uint256 superforms_);

Returns

NameTypeDescription
superforms_uint256is the number of superforms

_broadcast

interacts with broadcast state registry to broadcasting state changes to all connected remote chains

function _broadcast(bytes memory message_, bytes memory extraData_) internal;

Parameters

NameTypeDescription
message_bytesis the crosschain message to be sent.
extraData_bytesis the amb override information.

_syncFormPausedStatus

is a part of broadcasting / dispatching through factory state registry

ambIds are validated inside the broadcast state registry

broadcastParams if wrong will revert in the amb implementation

synchronize paused status update message from remote chain

function _syncFormPausedStatus(bytes memory message_) internal;

Parameters

NameTypeDescription
message_bytesis the crosschain message received.