DstSwapper
Inherits: IDstSwapper, ReentrancyGuard
Author: Zeropoint Labs.
SPDX-License-Identifier: Apache-2.0
handles all destination chain swaps.
State Variables
superRegistry
ISuperRegistry public immutable superRegistry;
CHAIN_ID
uint64 public immutable CHAIN_ID;
NATIVE
address constant NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
swappedAmount
mapping(uint256 payloadId => mapping(uint256 index => uint256 amount)) public swappedAmount;
Functions
onlySwapper
modifier onlySwapper();
onlyEmergencyAdmin
modifier onlyEmergencyAdmin();
constructor
constructor(address superRegistry_);
Parameters
Name | Type | Description |
---|---|---|
superRegistry_ | address | Superform registry contract |
receive
receive enables processing native token transfers into the smart contract.
liquidity bridge fails without a native receive function.
receive() external payable;
processTx
would interact with liquidity bridge contract to process multi-tx transactions and move the funds into destination contract.
function processTx(
uint256 payloadId_,
uint256 index_,
uint8 bridgeId_,
bytes calldata txData_
)
public
override
onlySwapper
nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
payloadId_ | uint256 | represents the id of the payload |
index_ | uint256 | represents the index of the superformid in the payload |
bridgeId_ | uint8 | represents the id of liquidity bridge used |
txData_ | bytes | represents the transaction data generated by liquidity bridge API. |
batchProcessTx
validates the bridge data
to enter the if-else case of the bridge validator loop
get the address of the bridge to send the txData to.
approve the bridge to spend the approvalToken_.
execute the txData_.
execute the txData_.
updates swapped amount
emits final event
function batchProcessTx(
uint256 payloadId_,
uint256[] calldata indices,
uint8[] calldata bridgeIds_,
bytes[] calldata txData_
)
external
override
onlySwapper;
Parameters
Name | Type | Description |
---|---|---|
payloadId_ | uint256 | represents the array of payload ids used |
indices | uint256[] | |
bridgeIds_ | uint8[] | represents the array of ids of liquidity bridges used |
txData_ | bytes[] |
_getFormUnderlyingFrom
function _getFormUnderlyingFrom(uint256 payloadId_, uint256 index_) internal view returns (address underlying_);
emergencyWithdrawToken
EMERGENCY_ADMIN ONLY FUNCTION.
allows admin to withdraw lost tokens in the smart contract.
function emergencyWithdrawToken(address tokenContract_, uint256 amount_) external onlyEmergencyAdmin;
Parameters
Name | Type | Description |
---|---|---|
tokenContract_ | address | address of the token contract |
amount_ | uint256 | amount of tokens to withdraw |
emergencyWithdrawNativeToken
note: transfer the token from address of this contract note: to address of the user (executing the withdrawToken() function)
EMERGENCY_ADMIN ONLY FUNCTION.
allows admin to withdraw lost native tokens in the smart contract.
function emergencyWithdrawNativeToken(uint256 amount_) external onlyEmergencyAdmin;
Parameters
Name | Type | Description |
---|---|---|
amount_ | uint256 | amount of tokens to withdraw |
Structs
ProcessTxVars
struct ProcessTxVars {
address finalDst;
address to;
address underlying;
uint256 expAmount;
}