Function: permitSwapAndBridge(address receivedToken, uint16 srcPoolId, uint16 dstPoolId, byte[1] dexId, PermitTransferFrom permit, SignatureTransferDetails transferDetails, byte[] sig, byte[] swapPayload, byte[] bridgePayload)
The function allows to swap with permit, bridge, and deposit to vaults using Stargate. Add check that receivedToken is equal to the last token in swap.
Inputs
receivedTokenConstraints: N/A.
Impact: Expected that this token is last in swap.
srcPoolIdConstraints:
router.swapreverts iffactory.getPool(_poolId)returns zero address.Impact: The ID of SRC pool.
dstPoolIdConstraints: The owner of the router should create and activate the chain path for
_dstChainIdand_dstPoolId. The_dstChainIdis constantARBITRUM_CHAIN_ID.Impact: The ID of DST pool.
dexIdConstraints: Revert if
dexIdis not 0x01, 0x02, 0x03, 0x04, or 0x05.Impact: The ID of the DEX that will be used.
permitConstraints: Checked inside the
permitTransferFromfunction.Impact: The permit data signed over by the owner.
transferDetailsConstraints: N/A.
Impact: The spender's requested transfer details for the permitted token.
sigConstraints: Checked inside the
permitTransferFromfunction.Impact: The signature to verify.
swapPayloadConstraints: N/A.
Impact: The data required for swap.
bridgePayloadConstraints: Is not verified.
Impact: Contain the data for ZapDest, expected address receiver,
uint256 vaultId, and addressvaultAddress.
Branches and code coverage (including function calls)
Intended branches
_swapBalanceris performed properly._swapUniswapV2is performed properly._swapUniswapV3is performed properly.SushiSwap is performed properly.
_swapWithCurveis performed properly.
Negative behavior
The invalid permit.
The invalid signature.
The
receivedTokenis not the last token in swap.The
receivedTokenis zero address.
Function call analysis
_swap(dexId,transferDetails.requestedAmount,swapPayload); -> otherFunction(args)What is controllable?
dexId,transferDetails.requestedAmount, andswapPayload.If return value controllable, how is it used and how can it go wrong? Returns the final number of tokens after the swap.
What happens if it reverts, reenters, or does other unusual control flow? Can revert if
dexIdis invalid --- also can revert if final amount will be less than minimum out amount.
_swapBalancer(swapPayload) -> balancerVault.call(swapPayload)What is controllable?
swapPayload.If return value controllable, how is it used and how can it go wrong? Returns the final number of tokens after the swap.
What happens if it reverts, reenters, or does other unusual control flow? Revert if swap failed.
_bridge(amountIn, fromToken, srcPoolId, dstPoolId, payload) -> IStargateRouter(stargateRouterEth).swapETHAndCall{value: msgValue}What is controllable?
amountIn,fromToken,srcPoolId,dstPoolId, andpayload.If return value controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters, or does other unusual control flow? Deposit funds to the
stargateEthVaultand callstargateRouter.swap. Will revert ifamountIn > msgValue.
_bridge(amountIn, fromToken, srcPoolId, dstPoolId, payload) -> IStargateRouter(stargateRouter).swap{value: msg.value}What is controllable?
amountIn,fromToken,srcPoolId,dstPoolId, andpayload.If return value controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters, or does other unusual control flow? No problem.