Comment on page
Forms
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.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):struct InitSingleVaultData {
uint256 payloadId;
uint256 superformId;
uint256 amount;
uint256 maxSlippage;
LiqRequest liqData;
bool hasDstSwap;
bool retain4626;
address receiverAddress;
bytes extraFormData;
}
Name | Description |
---|---|
payloadId | |
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) |
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 | |
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 |
extraFormData | bytes reserved for future use |
This function is called if depositing into a vault using tokens on the same chain as the vault.
function directDepositIntoVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_
) external payable override onlySuperRouter returns (uint256 dstAmount)
Name | Description |
---|---|
singleVaultData_ | Takes the form of InitSingleVaultData (represented above) |
srcSender_ | address of the user making the action |
This function is called if depositing into a vault using tokens on a different chain than the vault.
function xChainDepositIntoVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_,
uint64 srcChainId_
) external override onlyCoreStateRegistry returns (uint256 dstAmount)
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 |
function directWithdrawFromVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_
) external override onlySuperRouter returns (uint256 dstAmount)
Name | Description |
---|---|
singleVaultData_ | Takes the form of InitSingleVaultData (represented above) |
srcSender_ | address of the user making the action |
This function is called if withdrawing SuperPositions that are held on a different chain than the vault.
function xChainWithdrawFromVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_,
uint64 srcChainId_
) external override onlyCoreStateRegistry returns (uint256 dstAmount)
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 |
This function is called by
Forms
when they are paused by the EmergencyAdmin
. These requests are made by the EmergencyQueue.function emergencyWithdraw(
address srcSender_,
address refundAddress_,
uint256 amount_
) external override onlyEmergencyQueue
name | Text |
---|---|
srcSender_ | address of the user that should be refunded |
refundAddress_ | address to send tokens back to |
amount_ | uint256 amount to refund |
superformYieldTokenName
This function returns a standardized name for the
Superform
(using the vault name).function superformYieldTokenName() external view virtual override returns (string memory)
superformYieldTokenSymbol
This function returns a standardized symbol for the
Superform
(using the vault symbol).function superformYieldTokenSymbol() external view virtual override returns (string memory)
This function returns the associated
Form
which the vault has been added to. function formImplementationId() external view virtual override returns (uint32)
This function returns the associated state registry for the
Form
which the vault has been added to.function getStateRegistryId() external view virtual override returns (uint8)
This function returns the address of the vault.
function getVaultAddress() public view virtual override returns (address)
This function returns the address of the underlying for the vault.
function getVaultAsset() public view virtual override returns (address)
getVaultName
This function returns the name of the vault.
function getVaultName() public view virtual override returns (string memory)
getVaultSymbol
This function returns the symbol of the vault.
function getVaultSymbol() public view virtual override returns (string memory)
getVaultDecimals
This function returns the decimals of the vault.
function getVaultDecimals() public view virtual override returns (uint256)
getPricePerVaultShare
This function calls
convertToAssets
correcting for vault decimals.function getPricePerVaultShare() public view virtual override returns (uint256)
getVaultShareBalance
This function returns the balance of vault shares within the
Superform
.function getVaultShareBalance() public view virtual override returns (uint256)
getTotalAssets
This function returns the total balance of underlying tokens deposited into the vault.
function getTotalAssets() public view virtual override returns (uint256)
getPreviewPricePerVaultShare
This function calls
previewRedeem
on vault with the correct number of decimals.function getPreviewPricePerVaultShare() public view virtual override returns (uint256)
previewDepositTo
This function calls
convertToShares
on vault with the specified number of assets_
.function previewDepositTo(uint256 assets_) public view virtual override returns (uint256)
previewWithdrawFrom
This function calls
previewWithdraw
on vault with the specified number of assets_
.function previewWithdrawFrom(uint256 assets_) public view virtual override returns (uint256)
previewRedeemFrom
This function calls
previewRedeem
on vault with the specified number of shares_
.function previewRedeemFrom(uint256 shares_) public view virtual override returns (uint256)
Last modified 15d ago