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

Module: AwakenSwapContract_LP.cs

Function: AddLiquidityOutput AddLiquidity(AddLiquidityInput input)

Adds liquidity to a liquidity pool for a given pair of tokens. The function ensures that the contract is initialized, checks the input parameters for validity, and performs necessary transfers and minting of liquidity pool tokens.

Inputs

  • input.SymbolA

    • Validation: Must be an existing symbol for the first token.

    • Impact: Ensures that the symbol corresponds to a valid token to be paired.

  • input.SymbolB

    • Validation: Must be an existing symbol for the second token.

    • Impact: Ensures that the symbol corresponds to a valid token to be paired.

  • input.AmountADesired

    • Validation: Must be greater than zero.

    • Impact: Specifies the desired amount of the first token to add.

  • input.AmountBDesired

    • Validation: Must be greater than zero.

    • Impact: Specifies the desired amount of the second token to add.

  • input.AmountAMin

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

    • Impact: Ensures the minimum amount of the first token to add.

  • input.AmountBMin

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

    • Impact: Ensures the minimum amount of the second token to add.

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

    • Validation: Not null.

    • Impact: Specifies the recipient of the liquidity tokens.

  • input.Channel

    • Validation: Not explicitly validated in this function.

    • Impact: Specifies the channel for the liquidity tokens.

Branches and code coverage (including function calls)

Intended branches

Negative behavior

Function call analysis

This function makes no external state-mutating calls.

Function: RemoveLiquidityOutput RemoveLiquidity(RemoveLiquidityInput input)

Removes liquidity from a liquidity pool for a given pair of tokens. The function ensures that the contract is initialized, checks the input parameters for validity, and performs the necessary operations to remove liquidity and return the tokens to the user.

Inputs

  • input.SymbolA

    • Validation: Must be an existing symbol for the first token.

    • Impact: Ensures that the symbol corresponds to a valid token to be removed from the pool.

  • input.SymbolB

    • Validation: Must be an existing symbol for the second token.

    • Impact: Ensures that the symbol corresponds to a valid token to be removed from the pool.

  • input.LiquidityRemove

    • Validation: Must be greater than zero.

    • Impact: Specifies the amount of liquidity to be removed.

  • input.AmountAMin

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

    • Impact: Ensures the minimum amount of the first token to be returned.

  • input.AmountBMin

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

    • Impact: Ensures the minimum amount of the second token to be returned.

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

    • Validation: None.

    • Impact: Specifies the recipient of the returned tokens.

Branches and code coverage (including function calls)

Intended branches

Negative behavior

Function call analysis

This function performs the liquidity withdrawal by performing a transfer of the tokens A and B by invoking the configured TokenContract's transfer function.

Zellic © 2024Back to top ↑