Assessment reports>Awaken Swap>Threat Model>Module: AwakenSwapContract_Swap.cs

Module: AwakenSwapContract_Swap.cs

Function: SwapOutput SwapExactTokensForTokens(SwapExactTokensForTokensInput input)

Swaps an exact amount of input tokens for as many output tokens as possible, subject to a minimum output amount. The function ensures that the contract is initialized, checks the input parameters for validity, and performs the necessary operations to execute the token swap.

Inputs

  • input.AmountIn

    • Validation: Must be greater than zero.

    • Impact: Specifies the exact amount of input tokens to be swapped.

  • input.AmountOutMin

    • Validation: Must be greater than or equal to zero.

    • Impact: Ensures that the minimum acceptable amount of output tokens is specified.

  • input.Deadline

    • Validation: Must be greater than or equal to the current block time.

    • Impact: Ensures that the operation is performed within a valid time frame.

  • input.Path

    • Validation: Must contain valid token symbols for the swap path.

    • Impact: Defines the route for the token swap.

  • input.To

    • Validation: None.

    • Impact: Specifies the recipient of the output tokens.

  • input.Channel

    • Validation: Not explicitly validated in this function.

    • Impact: Specifies the channel for the swap.

Branches and code coverage (including function calls)

Intended branches

Negative behavior

Function call analysis

This function transfers tokens out via an external call to the configured TokenContract.

Function: SwapOutput SwapTokensForExactTokens(SwapTokensForExactTokensInput input)

Swaps tokens to receive an exact amount of output tokens, subject to a maximum input amount. The function ensures that the contract is initialized, checks the input parameters for validity, and performs the necessary operations to execute the token swap.

Inputs

  • input.AmountOut

    • Validation: Must be greater than zero.

    • Impact: Specifies the exact amount of output tokens to be received.

  • input.AmountInMax

    • Validation: Must be greater than zero.

    • Impact: Ensures that the maximum acceptable amount of input tokens is specified.

  • input.Deadline

    • Validation: Must be greater than or equal to the current block time.

    • Impact: Ensures that the operation is performed within a valid time frame.

  • input.Path

    • Validation: Must contain valid token symbols for the swap path.

    • Impact: Defines the route for the token swap.

  • input.To

    • Validation: None.

    • Impact: Specifies the recipient of the output tokens.

  • input.Channel

    • Validation: None.

    • Impact: Specifies the channel for the swap.

Branches and code coverage (including function calls)

Intended branches

Negative behavior

Function call analysis

This function transfers tokens out via an external call to the configured TokenContract.

Function: Empty SwapExactTokensForTokensSupportingFeeOnTransferTokens(SwapExactTokensForTokensSupportingFeeOnTransferTokensInput input)

Swaps an exact amount of input tokens for as many output tokens as possible, supporting tokens that have transfer fees. The function ensures that the contract is initialized, checks the input parameters for validity, performs the necessary operations to execute the token swap, and verifies the swap outcome.

Inputs

  • input.AmountIn

    • Validation: Must be greater than zero.

    • Impact: Specifies the exact amount of input tokens to be swapped.

  • input.AmountOutMin

    • Validation: Must be greater than or equal to zero.

    • Impact: Ensures that the minimum acceptable amount of output tokens is specified.

  • input.Deadline

    • Validation: Must be greater than or equal to the current block time.

    • Impact: Ensures that the operation is performed within a valid time frame.

  • input.Path

    • Validation: Must contain valid token symbols for the swap path.

    • Impact: Defines the route for the token swap.

  • input.To

    • Validation: None.

    • Impact: Specifies the recipient of the output tokens.

  • input.Channel

    • Validation: Not explicitly validated in this function.

    • Impact: Specifies the channel for the swap.

Branches and code coverage (including function calls)

Intended branches

Negative behavior

Function call analysis

This function transfers tokens out via an external call to the configured TokenContract.

Function: Empty SwapExactTokensForTokensSupportingFeeOnTransferTokensVerify(SwapExactTokensForTokensSupportingFeeOnTransferTokensVerifyInput input)

Verifies the outcome of a token swap that supports transfer fees. The function ensures that the contract is initialized, checks the input parameters for validity, verifies the sender, and confirms that the expected amount of output tokens was received.

Inputs

  • input.AmountBefore

    • Validation: Assumed valid as it is derived from the previous function call.

    • Impact: Used to calculate the difference in token balance before and after the swap.

  • input.AmountOutMin

    • Validation: Must be greater than or equal to zero.

    • Impact: Ensures the minimum acceptable amount of output tokens was received.

  • input.Symbol

    • Validation: Must be an existing symbol.

    • Impact: Specifies the token symbol being verified.

  • input.To

    • Validation: None.

    • Impact: Specifies the recipient of the output tokens.

Branches and code coverage (including function calls)

Intended branches

Negative behavior

Function call analysis

This function makes no external state-mutating calls.

Zellic © 2024Back to top ↑