Bridge Validators
Introduction
BridgeValidator
is an abstract contract with transaction verification logic that specific validator contracts must inherit to move liquidity on Superform. It ensures that submitted transaction data has the intended bridging outcome and was not corrupted in generation or in the process of transmitting through the Superform API. Superform's ProtocolAdmin
may add more bridge validators to allow for more sources of liquidity.
Core Concepts
There are two core validation mechanisms all bridge validators must implement:
validateReceiver
: Where TxData is validated to the intended receivervalidateTxData
: Where TxData is validated to against the amount of input token, destination chain, and receiver
Along with three core decoding mechanisms:
decodeAmountIn
: WhereTxData
is decoded to return the amount of the input token for both direct and cross chain actionsdecodeDstSwap
: Where same-chain swapTxData
is decoded to return the input token and amountdecodeSwapOutputToken:
Where same-chain swapTxData
is decoded to return the output token
validateReceiver
This function validates the receiver's address based on the provided transaction data and intended receiver.
txData_
bytes transaction data to be executed
receiver_
address of the intended receiver of the tokens after transaction data is executed
validateTxData
This function performs multiple checks on the transaction data provided to ensure proper behavior. These checks are implemented on a case-by-case basis depending on the bridge infrastructure being integrated.
txData_
bytes transaction data to be executed
srcChainId_
uint64 EVM chain id of where the funds originate from
dstChainId_
uint64 EVM chain id of the target chain of the action
liqDstChainId_
uint64 EVM chain id of where the funds are going. On deposits its where the Superform is located, on withdrawals it can be any arbitrary EVM chain id supported by the bridge
deposit_
bool where true if the action is a deposit, false if it is a withdrawal
superform_
address of the Superform
srcSender_
address of the user sending the transaction on the source chain
liqDataToken_
address of the token being swapped
liqDataInterimToken_
address of the token that can be used as an intermediary token on the destination chain
decodeAmountIn
This function returns the decoded minAmount
expected to be received post bridging/swapping actions. This is used in multiple places in core contracts, notably in Router implementations.
txData_
bytes transaction data to decode minAmount
from
genericSwapDisallowed_
bool to represent if generic swaps are not allowed
decodeDstSwap
This function returns the necessary information for processing swaps on the destination chain, the amount of the expected output token and address. This is used in DstSwapper.
txData_
bytes transaction data
decodeSwapOutputToken
This function returns the neccessary information for figuring out the final token address to be received after a swap. This is used in direct action validation in ERC4626Form.
txData_
bytes transaction data
Last updated