Assessment reports>Y2K Finance>Threat Model>deposit

Function: deposit(uint256 assets, address receiver)

This deposits assets to mint shares in the contract.

Inputs

  • assets

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: The amount of assets to deposit.

  • receiver

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: The address to receive the minted shares.

Branches and code coverage (including function calls)

Intended branches

  • The function calculates the preview deposit amount from assets and ensures it is not zero.

  • The function transfers the assets from the caller to the contract.

  • The function mints shares for the receiver.

  • The function emits a Deposit event.

  • The function calls afterDeposit to perform any necessary postdeposit actions.

Negative behavior

  • The function reverts with ZERO_SHARES if the calculated shares are zero.

Function call analysis

  • asset.safeTransferFrom(msg.sender, address(this), assets)

    • What is controllable? msg.sender and assets.

    • If return value controllable, how is it used and how can it go wrong? This function call does not return a value.

    • What happens if it reverts, reenters, or does other unusual control flow? If the asset transfer fails, it will revert and the transaction will be rolled back.

  • _mint(receiver, shares)

    • What is controllable? receiver and shares.

    • 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? If the minting of shares fails, it will revert and the transaction will be rolled back.

  • afterDeposit(assets, shares)

    • What is controllable? assets and shares.

    • 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? If the afterDeposit function reverts, the entire function would revert.

Zellic © 2024Back to top ↑