Assessment reports>Odos>Threat Models>swapCompact

Function: swapCompact()

This function allows the caller to perform a swap, encoding the details of the operation to be performed in a more efficient fashion than the plain swap function.

The function directly decodes inputs from calldata, ultimately building the same arguments supplied to swap. Space efficiency is achieved by packing the data as well as by allowing an efficient representation of zero addresses and use of addresses taken from a predefined list of addresses (which can be updated by the contract owner).

Branches and code coverage (including function calls)

Intended branches

  • getAddress correctly handles compact zero addresses.

  • getAddress correctly handles addresses to be taken from the predefined list.

  • getAddress correctly handles full addresses.

  • Performs a swap using ETH as input.

  • Performs a swap using a token as input.

Negative behaviour

  • Execution is reverted if inputAmount does not match the message value.

  • Execution reverts if inputToken == outputToken.

  • Execution reverts if the minimum output amount is zero.

  • Execution reverts if the minimum output is less than the quote output.

  • Execution reverts if the output is too low (slippage).

Function call analysis

  • rootFunction -> _swapApproval

    • What 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.

Zellic © 2024Back to top ↑