Assessment reports>Ethena>Threat Models>stakeWithPermit

Function: stakeWithPermit(uint256 eUSDIn, uint256 minStakedeUSDOut, address beneficiary, uint256 deadline, uint8 v, byte[32] r, byte[32] s)

Allows users to stake their eUSD tokens using a permit signature.

Inputs

  • eUSDIn

    • Constraints: Not zero --- should be at least MIN_INITIAL_STAKE during the first stake.

    • Impact: The amount of eUSD tokens to stake.

  • minStakedeUSDOut

    • Constraints: N/A.

    • Impact: The minimum amount of stakedeUSD tokens to receive.

  • beneficiary

    • Constraints: N/A.

    • Impact: The beneficiary of the stakedeUSD tokens.

  • deadline

    • Constraints: N/A.

    • Impact: The deadline for the permit signature.

  • v

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

    • Impact: The v value of the permit signature.

  • r

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

    • Impact: The r value of the permit signature.

  • s

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

    • Impact: The s value of the permit signature.

Branches and code coverage (including function calls)

Intended branches

  • Stake 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

  • stakeWithPermit -> eUSD.permit(_msgSender(), address(this), eUSDIn, deadline, v, r, s)

    • External/Internal? External.

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

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

  • stakeWithPermit -> _stake(eUSDIn, minStakedeUSDOut, beneficiary)

    • External/Internal? Internal.

    • Argument control? eUSDIn, minStakedeUSDOut, and beneficiary.

    • Impact: N/A.

Zellic © 2024Back to top ↑