fix: Bear defaults duplicated across Optimizer and LiquidityManager (#646)
Extract bear-mode default values (0, 3e17, 100, 3e17) into file-level constants in IOptimizer.sol so both Optimizer._bearDefaults() and LiquidityManager.recenter()'s catch block reference a single source of truth instead of independent hardcoded literals. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2778d6d5ba
commit
d3ff2cd0bf
3 changed files with 16 additions and 10 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import { IOptimizer, OptimizerInput } from "./IOptimizer.sol";
|
||||
import { IOptimizer, OptimizerInput, BEAR_CAPITAL_INEFFICIENCY, BEAR_ANCHOR_SHARE, BEAR_ANCHOR_WIDTH, BEAR_DISCOVERY_DEPTH } from "./IOptimizer.sol";
|
||||
import { Kraiken } from "./Kraiken.sol";
|
||||
import { Stake } from "./Stake.sol";
|
||||
|
||||
|
|
@ -212,12 +212,10 @@ contract Optimizer is Initializable, UUPSUpgradeable, IOptimizer {
|
|||
/**
|
||||
* @notice Safe bear-mode defaults returned when calculateParams exceeds its
|
||||
* gas budget or reverts.
|
||||
* @dev Values must stay in sync with the catch block in LiquidityManager.recenter()
|
||||
* ({capitalInefficiency:0, anchorShare:3e17, anchorWidth:100, discoveryDepth:3e17}).
|
||||
* Update both locations together if the safe defaults ever change.
|
||||
* @dev Constants defined in IOptimizer.sol, shared with LiquidityManager.recenter().
|
||||
*/
|
||||
function _bearDefaults() internal pure returns (uint256 capitalInefficiency, uint256 anchorShare, uint24 anchorWidth, uint256 discoveryDepth) {
|
||||
return (0, 3e17, 100, 3e17);
|
||||
return (BEAR_CAPITAL_INEFFICIENCY, BEAR_ANCHOR_SHARE, BEAR_ANCHOR_WIDTH, BEAR_DISCOVERY_DEPTH);
|
||||
}
|
||||
|
||||
// ---- Normalization helpers ----
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue