Function: _handleERC20Received(uint256 refId, address to, address toToken, address bridgedToken, uint256 bridgedAmount, uint256 minToAmount, Dst1inch dst1inch)
Handles received ERC-20 tokens via StarGate.
Inputs
refId
Control: Fully controlled by calling function.
Constraints: None.
Impact: The reference ID of the transaction.
to
Control: Fully controlled by calling function.
Constraints: None.
Impact: The address to send the bridged tokens to.
toToken
Control: Fully controlled by calling function.
Constraints: Checked whether it is the
bridgedToken
.Impact: The token to send to the
to
address.
bridgedToken
Control: Fully controlled by calling function.
Constraints: Checked whether it is the
toToken
.Impact: The token that was bridged.
bridgedAmount
Control: Fully controlled by calling function.
Constraints: None. Assumed to be correctly forwarded by StarGate.
Impact: The amount of the bridged token.
minToAmount
Control: Fully controlled by calling function.
Constraints: None. Assumed that checks are performed in the
wooRouter
.Impact: The minimum amount of the
toToken
to receive.
dst1inch
Control: Fully controlled by calling function.
Constraints: None. Checked that it is not
address(0)
.Impact: The
1inch
router to use for the swap.
Branches and code coverage
Intended branches
Check that
realToAmount
is greater thanminToAmount
. Currently not checked.If
toToken
is the same asbridgedToken
, transfer the bridged amount to theto
address.If
toToken
is not the same asbridgedToken
, swap the bridged token to thetoToken
, specifying theto
address as the recipient.If either of the swaps did not succeed, transfer the bridged amount of tokens directly to the
to
address.Ensure that adequate approvals are performed before calling the swap functions.
Ensure that approvals are removed after the swap is performed.
Negative behavior
The source address of the cross-chain transaction should be a WooCrossChainRouter on the source chain; this is currently not enforced at any level.
Caller should be the StarGate router. This is enforced at calling function level.