Forms

Introduction

Forms are intermediaries for deposit and withdrawal actions to and from vaults on Superform. All Form implementations must adhere to the BaseForm interface and may override available virtual functions for added functionality from the standard deposit/withdraw functionality.

When vaults are added to Forms they create Superforms.

Currently the only Form type supported is for the ERC4626 standard. Superform Labs has started development of a Timelock Form and a KYCDAO form which could be added by at a later date. The community is strongly encouraged to develop their own Forms to support more yield types on Superform.

Core Concepts

Deposit and Withdraw

Interaction with Superforms happens through the four implemented external functions in BaseForm. They are split by same-chain (only accessible by SuperformRouter) and crosschain access (only accessible by CoreStateRegistry). These specific functions are implemented in individual Form implementations.

Information to perform actions is encapsulated in the form of a struct through InitSingleVaultData (actions are performed on a per vault basis):

InitSingleVaultData

struct InitSingleVaultData {
    uint256 payloadId;
    uint256 superformId;
    uint256 amount;
    uint256 outputAmount;
    uint256 maxSlippage;
    LiqRequest liqData;
    bool hasDstSwap;
    bool retain4626;
    address receiverAddress;
    bytes extraFormData;
}
Name
Description

payloadId

uint256 id of the payload from the source chain (generated in SuperformRouter)

superformId

uint256 id of the Superform to perform the action on

amount

uint256 of the expected amount of token or vault in question (deposits = expected amount of token being received on destination chain, withdrawal = number of SuperPositions being burned)

outputAmount

uint256 expected amount of outputs from the deposit/redeem action (deposits = expected amount of vault shares being received on destination chain, withdrawal = expected amount of tokens being received)

maxSlippage

uint256 number from 0 to 10000 indicating acceptable slippage in bps (i.e. 10000 = 100% slippage) to go from input token to output token, which could include both bridging and swapping

liqData

bytes data contains liquidity information for swapping/bridging from forms (see SuperformRouter)

hasDstSwap

bool to indicate if the route has a swap on the destination chain

retain4626

bool to indicate if the user wants to send the ERC4626 to the receiver address (if true, user receives ERC4626 shares instead of being minted SuperPositions)

receiverAddress

address to refund the user on the destination chain if tokens are stuck

receiverAddressSP

address to mint SuperPositions so on the source chain

extraFormData

bytes reserved for future use

directDepositIntoVault

This function is called if depositing into a vault using tokens on the same chain as the vault.

Name
Description

singleVaultData_

Takes the form of InitSingleVaultData (represented above)

srcSender_

address of the user making the action

xChainDepositIntoVault

This function is called if depositing into a vault using tokens on a different chain than the vault.

Name
Description

singleVaultData_

Takes the form of InitSingleVaultData (represented above)

srcSender_

address of the user making the action

srcChainId_

uint64 id of the originating chain for the action

directWithdrawFromVault

This function is called if withdrawing SuperPositions that are held on the same chain as the vault.

Name
Description

singleVaultData_

Takes the form of InitSingleVaultData (represented above)

srcSender_

address of the user making the action

xChainWithdrawFromVault

This function is called if withdrawing SuperPositions that are held on a different chain than the vault.

Name
Description

singleVaultData_

Takes the form of InitSingleVaultData (represented above)

srcSender_

address of the user making the action

srcChainId_

uint64 id of the originating chain for the action

Emergency Queue

This function is called by Forms when they are paused by the EmergencyAdmin. These requests are made by the EmergencyQueue.

name

receiverAddress_

address to send tokens back to

amount_

uint256 amount to refund

View Functions

superformYieldTokenName

This function returns a standardized name for the Superform (using the vault name).

superformYieldTokenSymbol

This function returns a standardized symbol for the Superform (using the vault symbol).

formImplementationId

This function returns the associated Form which the vault has been added to.

getStateRegistryId

This function returns the associated state registry for the Form which the vault has been added to.

getVaultAddress

This function returns the address of the vault.

getVaultAsset

This function returns the address of the underlying for the vault.

getVaultName

This function returns the name of the vault.

getVaultSymbol

This function returns the symbol of the vault.

getVaultDecimals

This function returns the decimals of the vault.

getPricePerVaultShare

This function calls convertToAssets correcting for vault decimals.

getVaultShareBalance

This function returns the balance of vault shares within the Superform.

getTotalAssets

This function returns the total balance of underlying tokens deposited into the vault.

getPreviewPricePerVaultShare

This function calls previewRedeem on vault with the correct number of decimals.

previewDepositTo

This function calls convertToShares on vault with the specified number of assets_.

previewWithdrawFrom

This function calls previewWithdraw on vault with the specified number of assets_.

previewRedeemFrom

This function calls previewRedeem on vault with the specified number of shares_.

Last updated

Was this helpful?