fix: address PR #168 review findings in OptimizerV3Push3

- Add `require(averageTaxRate <= 1e18, "Invalid tax rate")` to match
  the existing `percentageStaked` guard and prevent silent acceptance
  of out-of-range values.
- Expand contract-level NatSpec with a @dev note clarifying this is an
  equivalence proof only: it intentionally exposes `isBullMarket` alone
  and is not a deployable upgrade (full optimizer interface missing).

All 15 Foundry tests pass (15 unit + fuzz).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-02-23 18:32:49 +00:00
parent 491c8f65b6
commit ca2022d83b

View file

@ -5,6 +5,10 @@ pragma solidity ^0.8.19;
* @title OptimizerV3Push3
* @notice Auto-generated from optimizer_v3.push3 via Push3Solidity transpiler.
* Implements the same isBullMarket logic as OptimizerV3.
* @dev This contract is an equivalence proof, not a deployable upgrade.
* It intentionally exposes only `isBullMarket` and does NOT implement
* the full optimizer interface (e.g. `getLiquidityParams`). Wiring it
* into the proxy upgrade path would require completing that interface first.
*/
contract OptimizerV3Push3 {
/**
@ -18,6 +22,7 @@ contract OptimizerV3Push3 {
uint256 averageTaxRate
) public pure returns (bool bull) {
require(percentageStaked <= 1e18, "Invalid percentage staked");
require(averageTaxRate <= 1e18, "Invalid tax rate");
uint256 taxrate = uint256(averageTaxRate);
uint256 staked = uint256(((percentageStaked * 100) / 1000000000000000000));
bool b33;