Merge pull request 'fix: Other clamped params lack named constants (#703)' (#725) from fix/issue-703 into master
This commit is contained in:
commit
93e3495252
2 changed files with 11 additions and 7 deletions
|
|
@ -20,10 +20,10 @@ struct OptimizerInput {
|
|||
interface IOptimizer {
|
||||
/**
|
||||
* @notice Returns the four liquidity parameters used by LiquidityManager.recenter().
|
||||
* @return capitalInefficiency Capital buffer level (0..1e18). CI=0 is safest.
|
||||
* @return anchorShare Fraction of non-floor ETH in anchor (0..1e18).
|
||||
* @return anchorWidth Anchor position width in tick units (uint24); max 100 ticks, enforced by LiquidityManager.
|
||||
* @return discoveryDepth Discovery liquidity density (0..1e18).
|
||||
* @return capitalInefficiency Capital buffer level (0..1e18, clamped to MAX_PARAM_SCALE). CI=0 is safest.
|
||||
* @return anchorShare Fraction of non-floor ETH in anchor (0..1e18, clamped to MAX_PARAM_SCALE).
|
||||
* @return anchorWidth Anchor position width in tick units (uint24); max 100 ticks (MAX_ANCHOR_WIDTH), enforced by LiquidityManager.
|
||||
* @return discoveryDepth Discovery liquidity density (0..1e18, clamped to MAX_PARAM_SCALE).
|
||||
*/
|
||||
function getLiquidityParams()
|
||||
external
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
|
|||
/// Any optimizer-returned value above this ceiling is silently clamped down.
|
||||
uint24 internal constant MAX_ANCHOR_WIDTH = 100;
|
||||
|
||||
/// @notice Upper bound (inclusive) for scale-1 optimizer parameters: capitalInefficiency,
|
||||
/// anchorShare, and discoveryDepth. Values above this ceiling are silently clamped.
|
||||
uint256 internal constant MAX_PARAM_SCALE = 10 ** 18;
|
||||
|
||||
/// @notice Immutable contract references
|
||||
address private immutable factory;
|
||||
IWETH9 private immutable weth;
|
||||
|
|
@ -224,10 +228,10 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
|
|||
try optimizer.getLiquidityParams() returns (uint256 capitalInefficiency, uint256 anchorShare, uint24 anchorWidth, uint256 discoveryDepth) {
|
||||
// Clamp parameters to valid ranges
|
||||
PositionParams memory params = PositionParams({
|
||||
capitalInefficiency: (capitalInefficiency > 10 ** 18) ? 10 ** 18 : capitalInefficiency,
|
||||
anchorShare: (anchorShare > 10 ** 18) ? 10 ** 18 : anchorShare,
|
||||
capitalInefficiency: (capitalInefficiency > MAX_PARAM_SCALE) ? MAX_PARAM_SCALE : capitalInefficiency,
|
||||
anchorShare: (anchorShare > MAX_PARAM_SCALE) ? MAX_PARAM_SCALE : anchorShare,
|
||||
anchorWidth: (anchorWidth > MAX_ANCHOR_WIDTH) ? MAX_ANCHOR_WIDTH : anchorWidth,
|
||||
discoveryDepth: (discoveryDepth > 10 ** 18) ? 10 ** 18 : discoveryDepth
|
||||
discoveryDepth: (discoveryDepth > MAX_PARAM_SCALE) ? MAX_PARAM_SCALE : discoveryDepth
|
||||
});
|
||||
|
||||
_setPositions(currentTick, params);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue