SuperformFactory

Introduction

SuperformFactory is used for adding vaults to Superform.

Core Concepts

The factory defines the logic for three actions

  1. Adding Forms: Forms are effectively yield adapters to support different types of opportunities on Superform. ERC4626Form is an adapter that supports standard ERC4626 vaults. Forms that are developed in the future can only be added by the ProtocolAdmin role.

  2. Creating Superforms: Anybody can permissionlessly create a Superform by adding vaults to Forms.

  3. Emergency Action: This exists as a circuit break, allowing EmergencyAdmin to pause deposits/withdrawals and BroadcastRegistry to send that message across chains.

A Superform is defined by a vault address, the Form which it is added to, and the EVM chain ID it is on.

Adding Forms

This function allows the ProtocolAdmin to add a Form implementation to Superform for a specified formId.

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

formImplementation_

address of the implementation contract

formImplementationId_

uint32 id to set the Form implementation to

Creating Superforms (Adding Vaults)

This function creates the Superform and returns the resulting superformId and Superform address.

function createSuperform(
    uint32 formImplementationId_,
    address vault_
) external override returns (uint256 superformId_, address superform_)
NameDescription

formImplementationId_

uint32 id of the Form implementation

vault_

address of the vault

Emergency Action

changeFormImplementationPauseStatus

This function allows the EmergencyAdmin to pause any deposits or withdrawals into any Form implementation if an exploit is suspected. If put into a paused state, no deposits can go through, and all withdrawals are sent to an EmergencyWithdrawal queue where withdrawals must be fulfilled by the EmergencyAdmin keeper which performs off-chain validations.

function changeFormImplementationPauseStatus(
        uint32 formImplementationId_,
        uint256 paused_,
        bytes memory extraData_
) external payable override onlyEmergencyAdmin
NameDescription

formImplementationId_

uint32 id of the Form implementation

paused_

bool that is True if the Form is paused, halting deposits and only allowing emergency withdrawals

extraData_

bytes extradata if broadcasting of the message is required

View Functions

Counts

getFormCount

This function returns the number of Forms that have been added to the specific chain.

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

getSuperformCount

This function returns the number of Superforms that have been created on the specific chain.

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

Forms

getFormImplementation

This function returns the address of a given Form implementation id.

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

formImplementationId_

uint32 id of the Form implementation

isFormImplementationPaused

This function returns if a Form id has been paused, triggering emergency-only withdrawal mode.

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

formImplementationId_

uint32 id of the Form implementation

Superforms

getSuperform

This function decodes any superFormId, regardless of the chain it was created on, into the Superform address, form id it was added to, and the chain id it was added on.

function getSuperform(uint256 superformId) 
    external pure override returns (
        address superform_, 
        uint32 formBeaconId_,
        uint64 chainId_)
NameDescription

superformId

uint256 superformId

getAllSuperformsFromVault

This function returns the superformIds and associated addresses given a vault address, if there are any. There can be multiple superformIds for any given vault because vaults can be added to multiple Forms.

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

vault_

Address of the vault to check

Last updated