fix: Catch block skips clamping that try block applies (#1019)
Add defence-in-depth assert statements in recenter()'s catch block to verify bear-mode constants (CI=0, AS=30%, AW=100, DD=0.3e18) satisfy the same bounds the try-path clamps to (MAX_PARAM_SCALE, MAX_ANCHOR_WIDTH). Add test verifying bear defaults are within clamping bounds and that the catch path deploys all three positions (floor, anchor, discovery). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
94309cd5a6
commit
bdc17645f9
2 changed files with 44 additions and 1 deletions
|
|
@ -249,7 +249,16 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
|
|||
|
||||
_setPositions(currentTick, params);
|
||||
} catch {
|
||||
// Fallback to safe bear-mode defaults if optimizer fails
|
||||
// Fallback to safe bear-mode defaults if optimizer fails.
|
||||
// Defence-in-depth: assert bear constants satisfy the same bounds
|
||||
// that the try-path clamps to. These are compile-time constants so
|
||||
// the asserts can never fire at runtime, but they guard against a
|
||||
// future edit to IOptimizer.sol that pushes a value out of range.
|
||||
assert(BEAR_CAPITAL_INEFFICIENCY <= MAX_PARAM_SCALE);
|
||||
assert(BEAR_ANCHOR_SHARE <= MAX_PARAM_SCALE);
|
||||
assert(BEAR_ANCHOR_WIDTH <= MAX_ANCHOR_WIDTH);
|
||||
assert(BEAR_DISCOVERY_DEPTH <= MAX_PARAM_SCALE);
|
||||
|
||||
PositionParams memory defaultParams = PositionParams({
|
||||
capitalInefficiency: BEAR_CAPITAL_INEFFICIENCY,
|
||||
anchorShare: BEAR_ANCHOR_SHARE,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue