Function: swapMulti(inputTokenInfo[] inputs, outputTokenInfo[] outputs, uint256 valueOutMin, byte[] pathDefinition, address executor, uint32 referralCode)
Swaps multiple tokens or ETH in a single atomically using approval. Slippage is controlled by giving each output a weight and defining a valueOutMin that defines a lower limit for the weighted sum of all output tokens.
Inputs
inputsControl: Arbitrary.
Constraints: The sum of all
inputs[i].amountInmust be equal tomsg.valuein the case of ETH. Cannot have duplicate sources.Impact: Decides token addresses to swap from, the amounts to swap, and the receiver.
outputsControl: Arbitrary.
Constraints: Cannot be equal to any of the input token addresses (arbitrage) or have duplicates of destinations.
Impact: Specifies the output tokens, receiver, and
relativeValue— which is a weighting for slippage calculations.
valueOutMinControl: Arbitrary.
Constraints: Must be larger than 0.
Impact: Decides the minimum value the token owner will allow with respect to slippage.
pathDefinitionControl: Arbitrary.
Constraints: None.
Impact: Passed to the executor — determines the operation to be executed.
executorControl: Arbitrary.
Constraints: None.
Impact: Determines the address of the executor to be invoked.
referralCodeControl: Arbitrary.
Constraints: None.
Impact: Referral code used for statistics and referral fees.
Branches and code coverage (including function calls)
Intended branches
Performs a swap using ETH as input.
Performs a swap using a token as input.
Performs a swap using multiple tokens/ETH as input.
Negative behavior
Execution is reverted if
inputshas ETH but amount does not matchmsg.value.Execution is reverted if there are duplicate source tokens.
Execution is reverted if there are any input and output tokens that are equal (arbitrage).
Execution is reverted if slippage limit
valueOutMinis exceeded (slippage).Execution is reverted if slippage limit is set too low.
Function call analysis
rootFunction -> _swapMultiApprovalWhat is controllable? All arguments.
If return value controllable, how is it used and how can it go wrong? Not used.
What happens if it reverts, reenters, or does other unusual control flow? Reverts are propagated upwards; reentrancy is a potential concern, but slippage checks mitigate that.