The Superform Protocol is a suite of non-upgradeable, non-custodial smart contracts that act as a central repository for yield and a router for users. It is modular, permissionless to list vaults, and enables intent-based transactions across chains that allow users to execute into an arbitrary number of tokens, chains, and vaults at once.
For DeFi protocols, it acts as an instant out-of-the-box distribution platform for ERC4626-compliant vaults. For users, it allows access to any vault listed on the platform from the chain and asset of their choice in a single transaction.
Core capabilities for protocols include:
Core capabilities for users include:
This repository includes all Superform contracts and can be split into two categories: Core and Periphery.
Core
contracts contain logic to move liquidity and data across chains along with maintaining roles in the protocolPeriphery
contracts contain the main touch-points for protocols and users to interface with and include helper contracts to ease 3rd party integrations.
├── script
├── security-review
├── src
├── crosschain-data
├── crosschain-liquidity
├── forms
├── interfaces
├── libraries
├── payments
├── settings
├── types
├── vendor
├── test
├── foundry.toml
└── README.md
script
contains deployment and utility scripts and outputs /script
security-review
contains information relevant to prior security reviews and the scope of bug bounties/security-review
src
is the source folder for all smart contract code/src
crosschain-data
implements the sending of messages from chain to chain via various AMBs /src/crosschain-data
crosschain-liquidity
implements the movement of tokens from chain to chain via bridge aggregators /src/crosschain-liquidity
forms
implements types of yield that can be supported on Superform and introduces a queue when they are paused /src/forms
interfaces
define interactions with other contracts /src/interfaces
libraries
define functions used across other contracts and error states in the protocol /src/libraries
payments
implements the handling and processing of payments for cross-chain actions /src/payments
settings
define, set, and manage roles in the Superform ecosystem /src/settings
types
define core data structures used in the protocol /src/types
vendor
is where all externally written interfaces reside /src/vendor
test
contains tests for contracts in src /test
We recommend visiting technical documentation at https://docs.superform.xyz.
SuperformRouter.sol
. For each deposit or withdraw function the user has to provide the appropriate "StateRequest" found in DataTypes.sol
DstSwapper.sol
. Similarly for withdraw actions, users can choose to receive a different token than the one redeemed for from the vault, but funds must go back directly to the user (i.e. no use of DstSwapper.sol
).SuperformFactory.sol
by calling createSuperform()
. Forms are code implementations that adapt to the needs of a given vault, currently all around the ERC-4626 Standard. Any user can wrap a vault into a Superform using the SuperformFactory but only the protocol may add new Form implementations.In this section we will run through examples where users deposit and withdraw into vault(s) using Superform.
SuperformRouter.sol
.directDepositIntoVault
to move tokens from the Superform into the vault.SuperformRouter.sol
.BridgeValidator.sol
and LiquidityHandler.sol
.AMBMessage
with the information about what is going to be deposited and by whom.CoreStateRegistry.sol
. This is done with the combination of a main AMB and a configurable number of proof AMBs for added security, a measure set via setRequiredMessagingQuorum
in SuperRegistry.sol
.PayMaster.sol
to cover the costs of cross-chain transactions and relayer payments. CoreStateRegistry.sol
. Assuming no swap was required in DstSwapper.sol
, at this step, assuming both the payload and proof have arrived, a keeper updates the messaged amounts to-be deposited with the actual amounts received through the liquidity bridge using updateDepositPayload
. The maximum number it can be updated to is what the user specified in StateReq.amount. If the end number of tokens received is below the minimum bound of what the user specified, calculated by StateReq.amount*(10000-StateReq.maxSlippage), the deposit is marked as failed and must be rescued through the rescueFailedDeposit
function to return funds back to the user through an optimistic dispute process. processPayload
. Here the deposit action is try-catched for errors. Should the action pass, a message is sent back to source acknowledging the action and mints SuperPositions to the user. If the action fails, no message is sent back, no SuperPositions are minted, and the rescueFailedDeposit
function must be used.SuperformRouter.sol
.directWithdrawFromVault
in the Superform, which redeems funds from the vault.SuperformRouter.sol
.AMBMessage
with the information about what is going to be withdrawn and by whom.CoreStateRegistry.sol
. This is done with the combination of a main AMB and a configurable number of proof AMBs for added security, a measure set via setRequiredMessagingQuorum
in SuperRegistry.sol
.PayMaster.sol
to cover the costs of cross-chain transactions and relayer payments. updateWithdrawPayload
to update the payload with transaction data. This can be done to reduce the chance of transaction data failure due to latency. processPayload
. Here the withdraw action is try-catched for errors. Should the action pass, the underlying obtained is bridged back to the user in the form of the desired tokens to be received. If the action fails, a message is sent back indicating that SuperPositions need to be re-minted for the user according to the original amounts that were burned. No rescue methods are implemented given the re-minting behavior on withdrawals. Step by step instructions on setting up the project and running it
foundryup -v nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9
foundryup -v nightly-ea2eff95b5c17edd3ffbdfc6daab5ce5cc80afc0
POLYGON_RPC_URL=
AVALANCHE_RPC_URL=
FANTOM_RPC_URL=
BSC_RPC_URL=
ARBITRUM_RPC_URL=
OPTIMISM_RPC_URL=
ETHEREUM_RPC_URL=
BASE_RPC_URL=
FANTOM_RPC_URL=
forge install
make ftest
to run tests against the contracts$ make ftest