PulseStrategyModule
The PulseStrategyModule
defines the mechanisms for executing different strategic approaches in managing liquidity positions. It encapsulates the logic for Original, Lazy Syncing, Lazy Ascending, and Lazy Descending strategies, each tailored to specific market dynamics.
Errors
InvalidParams()
: Indicates the input parameters for a strategy or operation are invalid or out of acceptable bounds.InvalidLength()
: Signifies an incorrect array length, typically related to strategy parameters or market data inputs.
Enums
StrategyType
StrategyType
Identifies the strategy applied to manage and rebalance liquidity positions:
Original
: This is the classic strategy where the position is actively managed within an interval[tickLower, tickUpper]
. If the market tick moves outside an interval[tickLower + tickNeighborhood, tickUpper - tickNeighborhood]
, a rebalance is triggered to center the position as closely as possible to the current tick, maintaining the same width. This ensures the position remains effectively aligned with the market.LazySyncing
: Supports active position management within the[tickLower, tickUpper]
interval, with rebalancing actions triggered under two scenarios:If the
current tick
<tickLower
, rebalance to a new position closest to the current tick on the right side, with the same width.If the
current tick
>tickUpper
, rebalance to a new position closest to the current tick on the left side, with the same width. This strategy aims to realign the position with the market with minimal adjustments.
LazyAscending
: Similar to LazySyncing but specifically focuses on ascending market conditions. If the current tick is less thantickLower
, it does not trigger a rebalance. Rebalancing is considered only when the market moves upwards beyond thetickUpper
, aiming to catch upward trends without reacting to downward movements.LazyDescending
: Opposite to LazyAscending, this strategy caters to descending market conditions. If the current tick is greater thantickUpper
, it does not prompt a rebalance. The strategy focuses on rebalancing when the market descends belowtickLower
, aiming to manage downward trends without reacting to upward movements.
Structs
StrategyParams
StrategyParams
Defines the parameters required to execute the specified strategy, including the strategy type, tick neighborhood, tick spacing, and interval width.
Fields:
strategyType
: Specifies the strategy to be applied.tickNeighborhood
: The range around ticks considered for rebalancing decisions.tickSpacing
: The spacing of ticks within the AMM pool, relevant to the strategy's operational logic.width
: The desired width of the position's price interval post-rebalance.
Functions
Q96()
Q96()
Returns: The constant value of
2^96
, utilized in fixed-point arithmetic operations across strategies.
calculateTarget(int24 tick, int24 tickLower, int24 tickUpper, StrategyParams memory params)
calculateTarget(int24 tick, int24 tickLower, int24 tickUpper, StrategyParams memory params)
Calculates the target position for rebalancing based on current market conditions, existing position bounds, and the selected strategy.
Parameters:
tick
: Current market tick, representing the instantaneous price level.tickLower
: Lower bound tick of the existing position.tickUpper
: Upper bound tick of the existing position.params
: Encapsulated strategy parameters guiding the rebalance logic.
Returns:
isRebalanceRequired
: Indicates whether the current market state and strategy parameters necessitate a rebalance.target
: Provides details of the target position post-rebalance, including new tick bounds and liquidity distribution.
Logic:
The function dynamically assesses the need for rebalancing based on the
StrategyType
selected and the current market tick's position relative to the existing liquidity interval. It then calculates the optimal target position parameters to realign the position with the chosen strategy and prevailing market conditions.
Last updated