Assessment reports>Ethena>Threat Models>unstakeWithPermit

Function: unstakeWithPermit(uint256 steUSDIn, uint256 mineUSDOut, address beneficiary, uint256 deadline, uint8 v, byte[32] r, byte[32] s)

Allows users to withdraw their staked eUSD tokens using a permit signature.

Inputs

  • steUSDIn

    • Constraints: Should not be zero.

    • Impact: The amount of steUSD tokens to unstake.

  • mineUSDOut

    • Constraints: N/A.

    • Impact: The minimum acceptable amount of eUSD tokens to receive.

  • beneficiary

    • Constraints: N/A.

    • Impact: The beneficiary of the eUSD tokens.

  • deadline

    • Constraints: N/A.

    • Impact: The deadline for the permit signature.

  • v

    • Constraints: Must be valid secp256k1 signature from the owner account over EIP-712--formatted function arguments.

    • Impact: The v value of the permit signature.

  • r

    • Constraints: Must be valid secp256k1 signature from the owner account over EIP-712--formatted function arguments.

    • Impact: The r value of the permit signature.

  • s

    • Constraints: Must be valid secp256k1 signature from the owner account over EIP-712--formatted function arguments.

    • Impact: The s value of the permit signature.

Branches and code coverage (including function calls)

Intended branches

  • Unstake tokens successfully with signature.

Negative behavior

  • The contract call is reverted when the signature is expired.

  • The contract call is reverted when the signer is not the owner or address(0).

Function call analysis

  • unstakeWithPermit -> stakedeUSD.permit(_msgSender(), address(this), steUSDIn, deadline, v, r, s)

    • External/Internal? External.

    • Argument control? steUSDIn, deadline, v, r, and s.

    • Impact: Sets steUSDIn as allowance of the address(this) account over _msgSender() account's WETH10 token, given _msgSender() account's signed approval.

  • unstakeWithPermit -> _unstake(steUSDIn, mineUSDOut, beneficiary)

    • External/Internal? Internal.

    • Argument control? steUSDIn, mineUSDOut, and beneficiary.

    • Impact: N/A.

Zellic © 2024Back to top ↑