SuperformRouter
Introduction
SuperformRouter
calls Superform core contracts to deposit or withdraw from vaults listed on Superform. Integrators should note that functions have been split apart and optimized for each possible vault action, and users should be routed as such based on their intention.
Core Concepts
All routers must implement functions from BaseRouterImplementation
using the internal default implementation from BaseRouter
. The primary purpose of this router is to facilitate deposit and withdrawal operations.
Liquidity Request
The base request required for constructing all other data types through Superform is called LiqRequest
Name | Description |
---|---|
| bytes |
| address of the token the user is using or requesting. On deposits this is the user's starting token, and on withdrawals this is the token the user wants to receive on the appropriate |
| address of the token that is allowed to be used as an interim token on the destination chain on deposits by |
| uint8 representing the bridge being used. 1 = LiFi, 2 = Socket, 3 = SocketOneInch |
| uint64 representing the final destination chain for the liquidity in the |
| uint256 amount of native tokens that will be passed in the liquidity request (0 if native tokens are not being swapped or bridged) |
Superform Vault Data
LiqRequest
is used to create two base datatypes that will be referred to as SingleVaultSFData
and MultiVaultSFData
.
SingleVaultSFData
: datatype format for a single vault action
Name | Description |
---|---|
| uint256 |
| uint256 expected amount of token or vault in question (deposits = expected amount of token being received on destination chain, withdrawal = number of SuperPositions being burned) |
| 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) |
| uint256 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 |
|
|
| bytes permit2 data (0x if none) |
| bool to indicate if the transaction will have a swap on destination before depositing (always false for withdrawals) |
| 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) |
| address to be used on the destination chain to either refund the user if tokens are stuck or send vault shares if |
| address to be used on the source chain to receive SuperPositions if |
| bytes optional data depending on the Form |
MultiVaultSFData
: datatype format for a multi vault action
Name | Description |
---|---|
| uint256[] array of |
| uint256[] array of the expected amount of token or vault in question (deposits = expected amount of vault underlying token being received on destination chain, withdrawal = amount of SuperPositions being burned per |
| uint256[] array of the 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) |
| uint256[] array of the numbers 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 |
| array of |
| bytes permit2 data (0x if none) |
| bool[] array to indicate if the transaction will have a swap on destination before depositing (always false for withdrawal) |
| bool[] array to indicate if the user wants to send the respective ERC4626 to the receiver address (if true, user retains it, and doesn't get a SuperPosition) |
| address to be used on the destination chain to either refund the user if tokens are stuck or send vault shares if |
| address to be used on the source chain to receive SuperPositions if |
| bytes optional data depending on the Form |
Datatypes -> Functions
SingleVaultSFData
and MultiVaultSFData
consist of 6 specialized deposit and withdrawal functions each.
Deposit Functions
singleDirectSingleVaultDeposit
Deposit into a single vault using tokens on the same chain.
Example: Use tokens on Ethereum to deposit into a vault on Ethereum.
Name | Description |
---|---|
|
|
singleXChainSingleVaultDeposit
Deposit into a single vault on one chain with tokens from another chain.
Example: Use tokens on Ethereum to deposit into a vault on Avalanche.
Name | Description |
---|---|
| uint8 array indicating which AMBs to use for the given |
| uint64 destination EVM chain ID |
|
|
singleDirectMultiVaultDeposit
Deposit into multiple vaults one one chain with tokens on the same chain.
Example: Use tokens on Ethereum to deposit into three vaults on Ethereum.
Name | Description |
---|---|
| array of |
singleXChainMultiVaultDeposit
Deposit into multiple vaults on one chain with tokens from another chain.
Example: Use tokens on Ethereum to deposit into three vaults on Fantom.
Name | Description |
---|---|
| uint8 array indicating which AMBs to use for the given |
| uint64 destination EVM chain IDs |
| array of |
multiDstSingleVaultDeposit
Deposit into a single vault on multiple different chains with tokens from any chain.
Example: Use tokens on Ethereum to deposit into one vault on Base, one vault on Optimism, and one vault on Arbitrum.
Name | Description |
---|---|
| uint8 array of arrays indicating which AMBs to use for each chainId in |
| uint64 array of destination EVM chain IDs |
| array of |
multiDstMultiVaultDeposit
Deposit into multiple vaults on multiple different chains with tokens from any chain.
Example: Use tokens on Ethereum to deposit into two vaults on Base, one vault on Optimism, and three vaults on Arbitrum.
Name | Description |
---|---|
| uint8 array of arrays indicating which AMBs to use for each chainId in |
| uint64 array of destination EVM chain IDs |
| array of |
Withdraw Functions
singleDirectSingleVaultWithdraw
Withdraw tokens from a single vault when SuperPositions are the same chain.
Example: Withdraw from a vault on Ethereum when SuperPositions are held on Ethereum.
Name | Description |
---|---|
|
|
singleXChainSingleVaultWithdraw
Withdraw tokens from a single vault when SuperPositions are on a different chain.
Example: Withdraw from a vault on Ethereum when SuperPositions are held on Optimism.
Name | Description |
---|---|
| uint8 array indicating which AMBs to use for the given |
| uint64 destination EVM chain ID |
|
|
singleDirectMultiVaultWithdraw
Withdraw tokens from multiple vaults when SuperPositions are on the same chain.
Example: Withdraw from three vaults on Ethereum when SuperPositions are held on Ethereum
Name | Description |
---|---|
| array of |
singleXChainMultiVaultWithdraw
Withdraw tokens from multiple vaults on one chain when SuperPositions are on a different chain.
Example: Withdraw from three vaults on Ethereum when SuperPositions are held on Optimism
Name | Description |
---|---|
| uint8 array indicating which AMBs to use for the given |
| uint64 destination EVM chain IDs |
| array of |
multiDstSingleVaultWithdraw
Withdraw tokens from a single vault on multiple different chains when SuperPositions are on a single chain.
Example: Withdraw from one vault on Optimism, one vault on Arbitrum, and one vault on Ethereum, when SuperPositions are held on Ethereum.
Name | Description |
---|---|
| uint8 array of arrays indicating which AMBs to use for each chainId in |
| uint64 array of destination EVM chain IDs |
| array of |
multiDstMultiVaultWithdraw
Withdraw tokens from a multiple vaults on multiple different chains when SuperPositions are on a single chain.
Example: Withdraw from two vaults on Optimism, one vault on Arbitrum, and three vaults on Ethereum, when SuperPositions are held on Ethereum.
Name | Description |
---|---|
| uint8 array of arrays indicating which AMBs to use for each chainId in |
| uint64 array of destination EVM chain IDs |
| array of |
| array of |
PayMaster
Within every cross-chain function _forwardPayment
is called to send the required amount of tokens to a PayMaster contract to cover the cost of cross-chain transactions made by Keepers.
Last updated