Function: exit(uint256 flashloanAmount, uint256 repayAmount, uint256 decollateralizeAmount, SwapPayload swapPayload, uint256 maxLTV)

This is an underlying implementation to exit the position by initiating a flash loan then returning the borrowed asset.

Inputs

  • flashloanAmount

    • Control: Full.

    • Constraints: None.

    • Impact: Amount to flash loan.

  • repayAmount

    • Control: Full.

    • Constraints: None.

    • Impact: Amount of borrowed asset to return (remove debt).

  • decollateralizeAmount

    • Control: Full.

    • Constraints: None.

    • Impact: Amount of collateral to remove from the borrow pool.

  • swapPayload

    • Control: Full.

    • Constraints: None.

    • Impact: The payload for the swap (swap information, in this case probably wstETH <--> WETH/ETH)

  • maxLTV

    • Control: Full.

    • Constraints: None.

    • Impact: Unused.

Branches and code coverage (including function calls)

Intended branches

  • Initiates a flash loan.

  • Handles zero flashloanAmount.

Negative behavior

  • Cannot be called by nonwhitelist senders.

  • Reverts in case of LTV being above limit.

  • Does not execute in case of Stop guard.

Function call analysis

  • initiateFlashLoan(flashloanAmount, abi.encode(FlashLoanContextType.EXIT, abi.encode(ctx)))

    • What is controllable? flashLoanAmount and ctx.

    • What happens if it reverts, reenters, or does other unusual control flow? Cannot reenter due to reentrancy guard.

    • If return value is controllable, how is it used and how can it go wrong: Discarded.

Zellic © 2024Back to top ↑