Assessment reports>WOOFi Swap>Threat Model>crossSwap

Function: crossSwap(uint256 refId, address payable to, SrcInfos srcInfos, DstInfos dstInfos, Src1inch src1inch, Dst1inch dst1inch)

Handles the cross-chain swap via StarGate.

Inputs

  • refId

    • Control: Fully controlled by the caller.

    • Constraints: None — assumed to be unique but not enforced.

    • Impact: The reference ID of the transaction.

  • to

    • Control: Fully controlled by the caller.

    • Constraints: None — assumed to be a valid address.

    • Impact: The address to send the bridged tokens to.

  • srcInfos

    • Control: Fully controlled by the caller.

    • Constraints: Some of its parameters are checked to be valid.

    • Impact: The source information.

  • dstInfos

    • Control: Fully controlled by the caller.

    • Constraints: Some of its parameters are checked to be valid.

    • Impact: The destination information.

  • src1inch

    • Control: Fully controlled by the caller.

    • Constraints: Checked that .swapRouter is not address(0).

    • Impact: The 1inch router to use for the swap on the source chain.

  • dst1inch

    • Control: Fully controlled by the caller.

    • Constraints: None at this level.

    • Impact: The 1inch router to use for the swap on the destination chain.

Branches and code coverage

Intended branches

  • Ensure that dstInfos.chainId is a valid chain ID. Currently not enforced.

  • Ensure that dstInfos.toToken != 0 and dstInfos.toToken != sgInfo.sgETHs(dstInfos.chainId).

  • Ensure that srcInfos.bridgeToken corresponds to the sgPoolIds of the source chain.

  • Ensure that dstInfos.bridgeToken corresponds to the sgPoolIds of the destination chain.

  • Ensure that msg.value covers for the cross-chain swap if native tokens are used (srcInfos.fromToken == ETH_PLACEHOLDER_ADDR).

  • Transfer the necessary srcInfos.fromAmount tokens to this contract.

  • Approve the srcInfos.fromAmount tokens to the wooRouter in 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 whenNotPaused modifier.

  • Should not be reentrant. Enforced through the nonReentrant modifier.

Zellic © 2024Back to top ↑