Function: optIn(ERC20 strategy, FlywheelCore flywheel)

  1. Performs the check that userGaugeflywheelId is not already set for msg.sender and corresponds to the strategy and flywheel addresses.

  2. Performs the check that the strategy address is trusted gauge.

  3. Performs the check that the Flywheel contract was actually deployed over the bribesFactory.

  4. Accrues rewards for the msg.sender on a strategy.

  5. Increases the whole amount of flywheelStrategyGaugeWeight[strategy][flywheel] by the current user balance allocated to the strategy.

  6. Adds the flywheel address to the array userGaugeFlywheels[msg.sender][strategy].

  7. Adds the index of flywheel from userGaugeFlywheels to the userGaugeflywheelId[msg.sender][strategy][flywheel].

Inputs

  • strategy

    • Constraints: The address should be a trusted gauge.

    • Impact: For this strategy address, the boostedTotalSupply value will be increased; further, this value will be used to accumulate global rewards on a strategy.

  • flywheel

    • Constraints: The contract should be deployed over the bribesFactory.

    • Impact: The contract that manages token rewards. It distributes reward streams across various strategies and distributes them among the users of these strategies.

Branches and code coverage (including function calls)

Intended branches

  • The userGaugeflywheelId != 0 after the call.

  • The flywheelStrategyGaugeWeight incremented.

Negative behavior

  • Double optIn for the same strategy and flywheel.

  • The strategy is not a gauge.

  • The untrusted Flywheel contract.

Function call analysis

  • flywheel.accrue(strategy, msg.sender)

    • What is controllable? flywheel and strategy.

    • 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 reverted, the user will not be able to optIn and the user’s balance will not be able to take into account total supply.

  • bHermesGauges(owner()).getUserGaugeWeight(msg.sender, address(strategy))

    • What is controllable? strategy.

    • If return value controllable, how is it used and how can it go wrong? Return the user's allocated weight to that gauge (strategy).

    • What happens if it reverts, reenters, or does other unusual control flow? No problem --- just view function.

Zellic © 2025Back to top ↑