Technical Overview
Concentrated Active Liquidity Management (CALM)
Last updated
Concentrated Active Liquidity Management (CALM)
Last updated
The architectural flow of the CALM solution seamlessly unfolds through the Uniswap v3 NFT staking on Flow AI, encompassing a series of key features:
Users have the flexibility to enter multiple staking contracts and allocate positions according to their preferences within each staking contract. CALM streamlines this process by presenting users with a comprehensive list of available NFT options based on their currently connected wallet, allowing for efficient and customized management of their positions.
The CALM system stores user stakes, ensuring precision and accuracy in the distribution of staking rewards.
The system forfeits the user's NFT to obtain its underlying tokens, a pivotal feature that serves as the foundation for optimization by addressing two crucial tasks:
Voiding Low and No-Profit Deposited Positions: By forfeiting a user's NFT to acquire its underlying tokens, the system efficiently identifies and eliminates low and non-profitable positions.
Reducing Costs of Adjusting Pool Position's Price Range: The conversion of NFTs into underlying tokens results in a decreased number of positions to manage. This reduction, in turn, minimizes the costs associated with further adjustments to a pool position's price range. The system's streamlined approach not only enhances efficiency but also contributes to a more cost-effective and sustainable staking experience.
The CALM system, in its optimized state, consolidates assets from deposited NFTs into a single Uniswap v3 pool position. This strategic enhancement involves determining the optimal price range for the position during the deposit process, defined by the following parameters:
Lower price tick
Upper price tick
The CALM system applies a set of principles to determine the values of these price range parameters:
Narrower ranges yield increased earnings from fees and rewards. However, this strategy comes with a higher susceptibility to incurring divergent losses, particularly in high-volatility environments.
In contrast, during low-volatility conditions, narrower ranges tend to outperform, generating higher fees and benefiting from an elevated fee multiplier. This performance advantage is achieved while experiencing minimal divergent losses, making narrow ranges particularly effective in more stable market conditions.
Hence, it is always recommended to employ a narrow range for more stable token pairs. In such instances, specifying a wide range is unnecessary for several compelling reasons:
The predominant trading activity occurs within the most concentrated range, making narrow ranges more aligned with market dynamics.
Widening the range inevitably diminishes the amount of liquidity provided, potentially compromising the efficiency of the position.
For less stable token pairs, two distinct options warrant consideration. On one hand, opting for narrow ranges maximizes fees, leveraging the benefits of higher fee earnings. On the other hand, selecting wide ranges signifies increased participation in trading activity, offering an alternative strategy for managing positions in more volatile markets.
Considering the potential of divergent losses, the forthcoming generalized options may include the following scenarios:
A. High Fees, Occurring Infrequently: Fees are high but are accrued relatively rarely since most swaps take place outside the specified price ticks - for narrow ranges.
B. Low Fees, Permanent Accrual: Fees are low but are accrued permanently as most swaps happen within the specified price ticks - for wide ranges.
C. High Fees, Permanent Accrual: Fees are high and are accrued permanently because most swaps occur within the specified price ticks - for wide ranges.
D. Low Fees, Occurring Infrequently: Fees are low and are accrued relatively rarely since most swaps take place outside the specified price ticks - for narrow ranges.
High
A
C
Low
D
B
Options C and D are deemed unlikely occurrences, requiring extreme market conditions that stem from either a significant decrease in volatility (C case) or an adverse event (D case). Therefore, as previously mentioned, the primary focus will center on options A and B. However, it's crucial for strategy A to closely resemble option C, as this alignment is a key optimization goal.
Each option is influenced by a divergent loss factor. In volatile pairs, the probability of experiencing divergent losses tends to be 100%, with the magnitude of these losses varying. It is upon the user's responsibility to judiciously determine withdrawal timings, with long positions recommended for wide-range scenarios and short positions suitable for narrow-range situations.
As the range narrows, the probability of significant losses increases. The impact of divergent loss can be mitigated through trading fees, where narrow-range positions, characterized by higher fees, aim to offset this effect. The relatively low frequency of fee accrual in narrow-range positions can partially or fully compensate for the loss amount. To address this, Uniswap v3 NFT staking on Flow AI strategically selects pools with the highest trading volume and large TVL. However, in the long run, it is anticipated that the higher fees associated with a narrower range may unlikely outweigh the impact of divergent loss.
Contrastingly, wide-range positions aim to counteract the impact of divergent loss through lower fees. The wider the range, the lower the fees; however, wider ranges are more likely to incur larger swap amounts. Consequently, the overall gain from trading fees in wide-range scenarios may surpass the outcomes of narrower positions. In the long term, the accrued savings from mitigating divergent loss are anticipated to outweigh the higher fees associated with narrower ranges.
Both narrow and wide-range options start at the current price level. The system computes optimal values for the lower and upper ticks, thereby establishing a position range.
The income derived from trading fees is determined by the formula:
Where Q
represents the quantity of swaps, P
denotes the fee level, and N
is contingent on the position range, ceteris paribus.
In Uniswap v3, the price range is determined by ticks, integral to the tick "validation" mechanism. This mechanism governs the initialization of ticks, dictating that both the lower and upper limits of the range adhere to tick indices. The best price (lower, upper) is identified first, followed by the selection of the most suitable tick.
For simplicity, the initial version of Uniswap v3 NFT staking on Flow AI adopts a minimalist approach to define price ranges for positions, characterized by the following key features:
Centrality of Current Price: Both for volatile and stable pairs, the system designates the current price as the center of the range.
Uniform Spread in Both Directions: For both volatile and stable pairs, a uniform spread extends in both directions, towards both the lower tick and the upper tick.
Varied Spread Values: The spread value for volatile pairs is greater than that of stable pairs, reflecting the greater flexibility required in the face of market fluctuations.
Example:
Consider a WETH-USDC pool with a current price of 1500 USDC for 1 WETH. Deemed volatile, the spread is set at 5%. Consequently, the resulting price range is [1425; 1575].
The liquidity calculation within Uniswap v3 incorporates several distinctive features:
Symmetric Price Range Extension:
It is feasible to extend the symmetric price range, such as ±10% from the current price, up to a certain threshold without impacting the overall liquidity amount. Notably, this extension applies exclusively to the shift of the upper tick.
Dynamic Liquidity:
The liquidity amount undergoes changes in response to fluctuations in the price of an asset, whether it increases or decreases while maintaining a constant spread within a symmetric price range.
The Uniswap v3 NFT staking on Flow AI incorporates the adjustment of position price ranges, recognizing the dynamic nature of asset prices following each swap. The protocol undertakes adjustments in response to significant price shifts, such as a 10% change. While frequent adjustments can incur substantial gas costs, Flow AI's management of a single position per pool presents a gas-efficient alternative, contributing to the overall profitability for both Flow AI and its users.
In the initial iteration, the adjustment of the position price range is carried out with simplicity and efficiency:
The range undergoes modification when the current price shifts into the tenth percentage of the given price range (both lower and upper).
The range spread rate remains constant after an adjustment.
Example: Considering a WETH-USDC pool with a current price of 1570 USDC for 1 WETH and a price range of [1425; 1575], the system recalculates the range based on the current price, resulting in a new range of [1491.5; 1648.5].
A more advanced version of Uniswap v3 NFT staking on Flow AI introduces a flexible implementation of the price range adjustment, expanding the triggers for rebalancing and enabling admins to specify trigger parameters for each pool. The extended list of triggers includes:
Automated position rebalance based on the price.
Automated position rebalance based on the assets' ratio.
Automated position rebalance based on time.
Price-based Trigger:
Admins can define a level of price deviation that prompts the adjustment of the main pool position price range.
The degree of deviation is applied separately to the lower and upper price shift.
The system checks asset prices every 5 seconds (modifiable) and, if the price exceeds the specified degree, evaluates the price's arithmetic mean for the next 5 minutes (modifiable and pool-specific). A rebalance is triggered if the mean falls beyond the specified degree.
Assets Ratio-based Trigger:
Admins can define a pool position composition state that triggers the adjustment of the main pool position price range.
The system monitors the ratio of assets every 5 seconds (modifiable) and evaluates the arithmetic mean of the dominating asset's pool share for the next 5 minutes (modifiable and pool-specific). A rebalance occurs if the mean exceeds the specified trigger value.
Time-based Trigger:
Admins can specify the frequency of the main pool position price range adjustment without price or asset ratio checks.
All triggers derive the new price range from the current price at the moment of rebalancing. Triggers are mutually exclusive, allowing only one type of trigger per pool.
As price changes in a pool alter the token ratio in a user's position, Uniswap v3 NFT staking on Flow AI relies on swaps to rebalance the token ratio. Excess of a dominating asset is sold, and an additional amount of the lacking token is acquired at the current price. It's important to note that these swaps are not limit orders and are executed at the current market price.
Initial Mechanism
The system adopts a transparent and equitable approach to distributing accrued trading fees, channeling 100% of these earnings back to depositors within the same staking contract. This ensures that the rewards generated by a specific pool, such as ARB-WETH, are exclusively distributed to ARB-WETH stakers only.
Equalized Staking Profitability
User positions are inherently equal in terms of staking profitability, as each individual deposit is aggregated into a unified position governed by the protocol. This unification ensures a level playing field for all participants, aligning with the principles of fairness and impartiality.
Proportional Yield Based on Staking Share
A depositor's personal yield is contingent on the share they possess in the overall staking. The system distributes rewards in proportion to users' investments, with both staking total and staking shares derived from the liquidity amount. This precision in reward distribution hinges on periodic estimations of shares, adaptable based on events occurring within the staking contract.
Periodic Estimation of Shares
Periodic estimation of shares becomes necessary as the staking landscape evolves, influenced by events within the staking contract. The frequency of these estimations is determined by the occurrence of specific events, ensuring that the share accurately reflects the current state of the staking positions. This adaptability is crucial in maintaining precise and up-to-date reward distribution principles.
Crediting Accrued Rewards
Accrued rewards are credited to users in tandem with specific actions, aligning with the compound necessities. These actions include:
Deposit: When a deposit is made into the current staking.
Withdrawal: At the moment a user announces a withdrawal from the current staking.
Claim: When a user claims rewards from the current staking.
Periodic System Updates
The system updates the amount of rewards to be distributed before initiating a new period. The commencement of a new period accounts for all active positions, followed by a refresh of the list of active positions. This approach ensures that the staking incentives are dispensed fairly, accounting for changes in the scope and quantity of positions within the staking.
A secondary mechanism coming soon
Compounding for Increased Staking Profitability
The system employs a compounding mechanism for rewards, strategically designed to enhance staking profitability continuously. Compounding is initiated for all accrued rewards within a specified period, ensuring that the entirety of rewards is consistently reinvested back into the staking. This perpetual reinvestment optimizes capital efficiency, guaranteeing a continuous stream of incentives for participants.
Compounding Triggers
Compounding is triggered in response to specific events, ensuring a seamless integration with the staking dynamics. The events that prompt compounding include:
Deposit: Occurs when a deposit is made into the current staking.
Withdrawal: Activated at the moment a user announces a withdrawal from the current staking.
Claim: Initiated when a user claims rewards from the current staking.
Separate Position for Fee Accumulation
All fees generated are gathered within their separate position, functioning as an addition to the primary staking pool that aggregated the initial stakers' deposits. The compounding process takes place within the scope of this auxiliary NFT.
Users have the flexibility to claim their staking rewards at their convenience. Flow AI introduces a nominal fee (10%) for each claim, and this fee is directed towards the revenue-sharing contract dedicated to the lockers.
While all staking rewards undergo periodic compounding to optimize profitability, users retain the option to claim their accrued rewards. This claiming process is similar to a withdrawal operation, but despite the similarities, the processes of claiming and withdrawing are different.
Maintaining User Shares and Claim Data:
Given the dynamic nature of user participation, where individuals can join and depart over time, it is imperative to retain accurate information about their current shares within the system. This preservation of data is crucial to ensuring fair reward distribution, preventing the inadvertent allocation of current rewards to newcomers during compounding events triggered by additional depositors.
Storage of Claim Data
The solution incorporates a mechanism for storing data pertaining to claims for each position. This record-keeping serves multiple purposes, including:
User Information and Progress: Keeping users informed about their accrued benefits and the progress of their staking journey.
Internal Statistical Analysis: Facilitating internal statistical analysis by leveraging historical claim data, enabling the system to derive insights and optimize its operations based on past user interactions.
Users can opt to withdraw their funds independently from their rewards. While a withdrawal request can be submitted at any time, the funds remain locked in staking for an additional 7 days. After this waiting period, the position becomes unstaked and claimable, and users can obtain their assets in one of three forms:
LP Token (NFT): Users can receive the same underlying assets they initially provided, presented in the form of an LP token (NFT).
NFT Creation: The protocol generates a new position in the same pool for the ex-depositor, and the claimed assets are allocated to this position. The NFT is then transferred to the user's wallet.
Single Underlying Asset: The protocol executes a swap to retrieve the claimed liquidity as a single underlying asset, allowing users to select the asset based on their preferences.
In all cases, a portion of liquidity is withdrawn from a Uniswap v3 pool, specifically from the position governed by the protocol. Throughout the waiting period, the requested liquidity continues to contribute to the pool, although users do not accrue additional rewards during this time. The income generated during the waiting period is distributed among existing stakers, enhancing their APY.
Users have the option to reverse a withdrawal request and return to the staking pool at any point within the 7-day waiting period. Upon reversal, they resume accruing rewards from the moment of the decision change.
Withdrawal vs. Claiming:
Comparison of key characteristics between withdrawal and claiming operations:
Withdrawal
In a position’s entirety
None
Claim
Limited to accrued rewards
10%
While the withdrawal operation offers the possibility of obtaining the entirety of funds within a specific timeframe, the immediate availability of funds is impeded by the amount and the protocol's imposed fee. Notably, withdrawing all assets from a position also includes the claim of all available rewards, leading to a fee based on the portion of funds constituted by these rewards.