Function: _handleERC20Received(uint256 refId, address to, address toToken, address bridgedToken, uint256 bridgedAmount, uint256 minToAmount, Dst1inch dst1inch)
Handles received ERC-20 tokens via StarGate.
Inputs
refIdControl: Fully controlled by calling function.
Constraints: None.
Impact: The reference ID of the transaction.
toControl: Fully controlled by calling function.
Constraints: None.
Impact: The address to send the bridged tokens to.
toTokenControl: Fully controlled by calling function.
Constraints: Checked whether it is the
bridgedToken.Impact: The token to send to the
toaddress.
bridgedTokenControl: Fully controlled by calling function.
Constraints: Checked whether it is the
toToken.Impact: The token that was bridged.
bridgedAmountControl: Fully controlled by calling function.
Constraints: None. Assumed to be correctly forwarded by StarGate.
Impact: The amount of the bridged token.
minToAmountControl: Fully controlled by calling function.
Constraints: None. Assumed that checks are performed in the
wooRouter.Impact: The minimum amount of the
toTokento receive.
dst1inchControl: Fully controlled by calling function.
Constraints: None. Checked that it is not
address(0).Impact: The
1inchrouter to use for the swap.
Branches and code coverage
Intended branches
Check that
realToAmountis greater thanminToAmount. Currently not checked.If
toTokenis the same asbridgedToken, transfer the bridged amount to thetoaddress.If
toTokenis not the same asbridgedToken, swap the bridged token to thetoToken, specifying thetoaddress as the recipient.If either of the swaps did not succeed, transfer the bridged amount of tokens directly to the
toaddress.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.