Cross-chain Deposit
Last updated
Was this helpful?
Last updated
Was this helpful?
The user selects a vault to deposit into, a funding token, and the amount to deposit into the vault
User requests routes from the Superform API
User selects a route
User approves permit2
contract for funding token (if needed)
Atomic phase
Once the request is initiated, the tokens may be swapped to the target vault's underlying token if the funding token differs from the underlying. The swap can be performed before the bridge, on the source chain, or after the bridge, on the destination chain. Swaps will be performed on the chain with the best execution
Transit phase (non-atomic)
In no particular order
Updater Keeper calls updateDepositPayload
to finalize amount of tokens received before the deposit is processed
Atomic phase
Processor Keeper calls processPayload
to trigger the deposit into the vault
This triggers xChainDepositIntoVault
and tokens are deposited into the target vault via the target vault’s Superform
contract
Vault shares are minted to target vault’s Superform
Transit phase (non-atomic)
Atomic phase
Payload is validated
User calls singleXChainSingleVaultDeposit
. The function sends the funding token and data containing desired bridge/swap route and end states (chain, vault) to . The function parameters are complex; therefore, using the Superform API to generate valid function parameters is suggested
bridges the tokens via the bridge route selected in the first step
generates a payload and proof with the singleVaultSFData
and calls dispatchPayload
to send them via the AMBs specified in initial request. This payload contains instructions that will use on the destination chain for how to process the incoming tokens
sends the cross-chain payment to the contract on the source chain
Payload is received by on the destination chain
Payload proof is received by on the destination chain
Liquidity/tokens are received by on the destination chain
ALTERNATIVELY: Tokens are received by dstSwapper
. dstSwapper
Keeper will call processTx
which will swap the the bridged tokens and send them to
Destination generates an acknowledgement payload and proof and calls dispatchPayload
to send them back to the source chain with the same AMBs used in the initial request. In this payload the exact amount of vault shares minted will be sent back to the source chain so the equivalent amount of can be minted to the depositing user
Acknowledgment payload is received by on the source chain
Acknowledgement payload proof is received by on the source chain
processor calls processPayload
are minted to the user