Function: crossSwap(uint256 refId, address payable to, SrcInfos srcInfos, DstInfos dstInfos, Src1inch src1inch, Dst1inch dst1inch)
Handles the cross-chain swap via StarGate.
Inputs
refIdControl: Fully controlled by the caller.
Constraints: None — assumed to be unique but not enforced.
Impact: The reference ID of the transaction.
toControl: Fully controlled by the caller.
Constraints: None — assumed to be a valid address.
Impact: The address to send the bridged tokens to.
srcInfosControl: Fully controlled by the caller.
Constraints: Some of its parameters are checked to be valid.
Impact: The source information.
dstInfosControl: Fully controlled by the caller.
Constraints: Some of its parameters are checked to be valid.
Impact: The destination information.
src1inchControl: Fully controlled by the caller.
Constraints: Checked that
.swapRouteris notaddress(0).Impact: The
1inchrouter to use for the swap on the source chain.
dst1inchControl: Fully controlled by the caller.
Constraints: None at this level.
Impact: The
1inchrouter to use for the swap on the destination chain.
Branches and code coverage
Intended branches
Ensure that
dstInfos.chainIdis a valid chain ID. Currently not enforced.Ensure that
dstInfos.toToken != 0anddstInfos.toToken != sgInfo.sgETHs(dstInfos.chainId).Ensure that
srcInfos.bridgeTokencorresponds to thesgPoolIdsof the source chain.Ensure that
dstInfos.bridgeTokencorresponds to thesgPoolIdsof the destination chain.Ensure that
msg.valuecovers for the cross-chain swap if native tokens are used (srcInfos.fromToken == ETH_PLACEHOLDER_ADDR).Transfer the necessary
srcInfos.fromAmounttokens to this contract.Approve the
srcInfos.fromAmounttokens to thewooRouterin case they are to be swapped.Forward the bridge call over to the StarGate router.
Negative behavior
Should not be callable when the contract is paused. Enforced through the
whenNotPausedmodifier.Should not be reentrant. Enforced through the
nonReentrantmodifier.