DstSwapper
Introduction
DstSwapper
is an access controlled contract which executes transaction data when tokens must be swapped on the destination chain before being deposited into a vault. This typically occurs when the vault being deposited into has little bridge liquidity in the underlying asset. In this case, the more liquid token is sent to the DstSwapper
contract rather than going directly to CoreStateRegistry.
Core Concepts
There are three stages in which DstSwapper
handles actions on the destination chain. It first tries to swap via processTx
or batchProcessTx
, if not successful, the transaction is marked as failed via updateFailedTx
or batchUpdateFailedTx
which means the intermediary tokens can be rescued by CoreStateRegistry.
processTx
The core function in DstSwapper
is processTx
. Used in single vault payloads, after validating that the provided data will send tokens to CoreStateRegistry, processTx
calls the designated bridge address with the provided transaction data via the onlySwapper
contract . This secures against txData
manipulation by off-chain route generation. processTx
will revert if the amount of the vault underlying token to be received was lower than what the user intended.
batchProcessTx
This function is used to swap tokens in multi vault payloads.
updateFailedTx
If processTx
doesn't go through successfully within a pre-determined time-frame (30 minutes being the default) transactions will be marked as failed via updateFailedTx
in a single vault payload.
batchUpdateFailedTx
If batchProcessTx
doesn't go through successfully within a pre-determined time-frame (30 minutes being the default) transactions will be marked as failed via batchUpdateFailedTx
in a multi vault payload.
processFailedTx
Once transactions are marked as failed by swapper, they can be rescued by the rescue/dispute process conducted in CoreStateRegistry.
Last updated