Development of a rebalancing system for LP positions in Uniswap v3

A position in a narrow range quickly goes idle: fees stop accruing, and manually shifting the boundaries eats up team time. We develop a turnkey LP rebalancing system — for your pool, risk limits, and exit rules. Time out of range is reduced many times over, and decisions are made according to pre-agreed logic.

Blockchain Development Services

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1365
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

LP Rebalancing: Where Exactly the Position Breaks

The Uniswap v3 pool earns only within a specified price range: as long as the price stays within the boundaries, fees accrue and capital works with high density.

As soon as the price breaks the upper or lower bound of the range, the position stops being active — liquidity remains in the pool but turns into a single asset, and fee collection stops.

Then what is rarely considered at entry comes into play: impermanent loss is fixed not at the moment of closing, but precisely when the price leaves the range. The position no longer earns fees but continues to bear price risk.

Liquidity idling is not a pause but a direct deduction from profitability: every hour outside the range is a loss of fees that neighboring positions in the same pool have taken.

A narrow price range amplifies both sides. Capital density in it is higher, income per unit invested is greater — that's why it's attractive.

But the width of the range and the frequency of its break are inversely related: the narrower the range, the smaller the price movement needed for the position to stop collecting fees.

Manual control is limited by speed. While the owner notices the exit from the range, checks the chart, and signs the transaction, the price has already moved several steps, and the new boundary is set based on an outdated point.

The cycle repeats: exit, idle time, resetting to the previous level, exit again — profitability is eaten up by idle time and position shifting.

We analyze how this is addressed: recalculating boundaries based on volatility, limiting the frequency of resets, and controlling losses during shifts.

System Effect: Fees, Idle Time, Failure Classes

A position in Uniswap v3 earns fees only while the price is within the specified range — the rest of the time it brings nothing.

Therefore, we measure the effect of the rebalancing system not by 'instant profitability' but by operational metrics: how much time the position spent in range, how quickly it returned to work, how many fees it collected, and which failure classes disappeared.

Below is a checklist that shows the system is actually working, not just pushing transactions.

  • Share of time in the working range. Before implementation, the position stayed within the boundaries about half of the calendar time: the price went out of range, and the decision to rebuild was made manually. After implementation, the metric stays around 75–85% — this is the main part of the gain.
  • Idle time. Manual resolution of a knocked-out position took from half an hour to several hours, and during all that time fee collection was at zero. The automatic cycle of rebuilding boundaries returns the position to work within minutes.
  • Fee collection. Accrual occurs only within the range, so every minute of idle time is a direct shortfall. The metric is calculated as the share collected from the theoretical maximum with continuous presence in range.
  • Range shift. The width of boundaries adjusts to current volatility: in a calm market, the range narrows and provides denser liquidity; during sharp movements, it widens — the position is knocked out less often and requires rebuilding less frequently.
  • Eliminated failure classes. Gone are missed price shifts, a 'stuck' position without gas, rebuilding boundaries based on outdated quotes, and duplicate transactions during parallel runs. Only predictable network-level failures remain.
  • Position profitability. We compare it with two baselines: passive holding of the same assets and a position abandoned out of range. The difference shows the contribution of automation itself, not market movement.

LP Rebalancing Options: Comparison of Operating Modes

Concentrated liquidity provides increased fee income only while the price remains within the specified range.

As soon as it breaks the boundary, the position turns into a one-sided asset and stops earning — that's why the position maintenance mode affects the result more than the size of capital.

How the Modes Differ

The choice here is a trade-off between the speed of reaction to price movement and maintenance costs. Below are three approaches typically chosen based on one's risk profile.

Option When Suitable Limitations
Manual range shift Calm market, large position, an operator ready to monitor price Reaction delay and human factor; each rebuild incurs network fees and risk of entering the wrong direction
Automatic threshold triggers Active market, need for operation without weekends and night shifts The trigger threshold is tuned to volatility: narrow leads to frequent rebuilds and rising costs, wide leads to long idle time out of range
Hybrid: scheduled shift plus emergency exit Positions where idle time out of range is especially costly Requires a reliable price source and clear separation of operator and automation rights

The trigger threshold and rebuild frequency are tuned to the specific pair and holding horizon: we calculate them based on historical volatility and only then embed them in the configuration. Describe your task — we'll come back with an estimate and plan for the chosen mode.

Implementation Stages: From Position Audit to System Handover

Rebalancing a liquidity position in a concentrated range on Uniswap v3 is not a single button but a loop that must be configured, tested, and handed over.

The order of work is fixed: skip the pool audit — thresholds will be set for code convenience rather than the volatility profile, and the system will start rebuilding on every noise.

  1. Pool audit. Fee tier, volume distribution by price levels, depth at boundaries, history of price exiting the range. We calculate whether rebuilding covers slippage and network fees.

  2. Loop design. Where we get the price and position state from, where keys are stored, who signs operations, what to do when sources diverge. The output is a scheme and a list of failure scenarios.

  3. Threshold setup. Range width, exit and re-entry triggers, minimum step, and limit on rebuild frequency. Separately — protection against 'sawtooth' when price fluctuates near the range boundary.

  4. Test run. First on historical data, then on a limited volume. We compare the calculation with reality: how much slippage and fees consumed, whether the signals matched expectations.

  5. Launch. Gradual activation with volume and frequency limits, alerts for deviations. For the first days, an engineer reviews each trigger and adjusts settings.

  6. System handover. Accesses, configuration documentation, incident response regulations, boundaries beyond which our help is needed. Then we provide support: adjusting thresholds as the market changes.

Access Policies, Schemes, and Documentation: What You Keep

The project is delivered not as a demonstration of a working scenario but as a set of artifacts your team can use to maintain the system without us.

Below is what is transferred to the client along with the code: configurations, schemes, and regulations describing not only normal operation but also behavior during failure.

  • Access control — role matrix: who changes range parameters, who only views statistics, who signs transactions. Rights are granted on a least-privilege basis, and every action is logged.
  • Roles and keys — signing key storage scheme: separate key per environment, hardware storage or secret service, rotation and revocation procedure in case of compromise.
  • Integration schemes — diagrams of connections with the network node, price feed, pool, and notification service: what data flows in each direction and what happens if a source becomes unavailable.
  • Strategy configurations — target position share, range width, deviation threshold for rebalancing, fee and slippage limits, check intervals.
  • Response regulations — procedures for quote divergence, stuck transaction, sharp price movement, and node failure, with trigger thresholds and responsible parties.
  • Documentation — architecture description, entry points, environment variables, instructions for local launch and running the strategy on historical data.
  • Recovery plan — how to roll back configuration to a previous one, withdraw liquidity manually, and verify the integrity of state backups.

Case Study: How We Reduced Time Out of Range and Lost Fees

A managed pool on a pair with medium volatility was run manually for some time: the range was set by intuition, and the position was checked between other tasks.

Outside the working range, the position stops collecting fees and fully turns into a single asset — if the price reverses, this fixes a loss that cannot be compensated.

Pre-change measurements gave an unpleasant picture: share of time in range — 58%, median reaction to boundary exit — about 40 minutes, lost fees — 31% of potential.

What We Changed

We wrote a service that monitors price and liquidity distribution in Uniswap v3 and pre-calculates the next range.

Rebuilding happens in a single transaction: withdraw the remainder, if necessary swap to the desired proportion, set a new range — capital does not hang out of the market between steps.

We calculate the range depth from current volatility, not from a 'nice' round level, so in a calm market the position lives longer and pays for rebuilding less often.

We separately addressed chatter. Rebalancing triggers only when the price has moved beyond the boundary by a confirmed distance and the volatility estimate is above the threshold — otherwise noise moves the position every hour, and build costs and slippage eat up collected fees.

Thresholds were selected on historical data: we ran several market regimes and kept values at which the number of rebuilds is minimal and time in range does not sag.

Metrics After

Share of time in range increased from 58% to 94%. Median reaction to boundary exit decreased from 40 minutes to ~2 minutes — position recovery now fits into one price move, not the end of the day.

Lost fees decreased from 31% to 7% of potential, number of rebuilds — a third fewer than with rebalancing on every boundary crossing.

Some losses do not disappear completely: in a sharp one-sided trend, no logic will keep the position in range; there, only drawdown limitation and partial capital withdrawal work.

What to Do If the Position Has Already Gone Out of Range?

Exiting the range happens not at the moment of touching the boundary but when the current price stops falling within the interval set at opening. Liquidity then stops collecting fees and fully remains in a single asset — at the most unfavorable point of movement.

Therefore, the first step is not a restart but capturing the state: how far the price has moved from the boundary, how long it has been out of range, and what the volatility was in that window.

If the price returns inside on its own, the position earns again, and rebuilding the range would only lock in losses from slippage and network fees.

A restart is justified for a sustained exit: a reversal within one recalculation interval occurs noticeably less often than continuation of movement in the same direction.

The procedure for a confirmed exit is as follows: withdraw liquidity, bring the pair to the target ratio, calculate the new width from actual volatility, and open the position again with a tick step corresponding to the pool's fee tier in Uniswap v3.

We take the width from realized volatility over the window, not by eye: a narrow range gives more fees but exits the range every few hours, and each restart eats up accumulated fees.

Next is a feasibility assessment: expected fee income in the new range over the expected time in it versus the cost of restart, i.e., network fees and slippage during exchange.

If rebuilding pays off within one cycle with a margin greater than volatility over that time — we restart. If not, the range is widened or the placement logic itself changes; otherwise, automatic LP rebalancing will spin the position at a loss.

Common Technical Doubts Before Starting

Automatic rebalancing is a stream of decisions: when to shift the range, how to react to price leaving the boundary, what to do when data from sources diverges.

Mistakes here cost not 'inconvenience' but loss of liquidity and unnecessary rebuilds, so engineering doubts should be resolved before launch. Below are the questions clients ask most often.

How is the maximum loss limited if the strategy makes a mistake?

At the design stage, hard limits are set: maximum drawdown per position, loss limit per rebalance, and daily limit on the number of rebuilds.

When any threshold is reached, the strategy does not 'pull' the range manually but stops, moves liquidity to a neutral state, and logs the reason for stopping.

Separately, it calculates whether rebuilding pays for itself: if the expected effect is less than the operation cost, it is not executed — this protects against a series of small shifts that eat up the position.

Does the contractor get access to funds?

No. We use a non-custodial scheme: private keys remain with you, the service only forms the transaction and passes it for signing — without your confirmation, the operation will not go to the network.

If a fully automatic mode is needed, an operator wallet with limited rights is deployed: it can change range boundaries but cannot withdraw funds to an external address. Rights are enforced in the contract, not in agreements.

What happens if an external price source provides incorrect data?

A signal is considered valid only if it is confirmed by several independent sources and is not outdated. If divergence exceeds a set threshold or data is delayed, orders are not sent at all — the strategy switches to observation mode and waits for stabilization.

Such behavior is more important than speed: a missed range shift costs less than rebuilding on a false signal.

Can the consequences of an automation failure be rolled back?

Each operation is idempotent and first goes through a test loop with real market conditions. There is a manual stop, a log of all decisions with justification, and the ability to return the position to its original boundaries.

Logs are stored so that a complete picture can be reconstructed: which signal arrived, which threshold triggered, what exactly was sent to the network.

Describe your scenario — we'll come back with an estimate and plan: which thresholds we set, how access is arranged, and what goes into the test loop before the first live transaction.

Let's Discuss the Task: We'll Build a Scheme for Your Pool

To come back with an estimate rather than generalities, we need context on your positions: network and pool address, current range, position size, and the horizon for which you are willing to hold it.

This is enough to calculate the share of time out of range and the volume of missed fees relative to switching costs.

What you will get in response:

  • a map of the current position: how often the price exits the range boundaries and how much time the position idles without fees;
  • calculation of trigger thresholds and range width for your horizon and pool liquidity;
  • LP rebalancing logic: range shift triggers, behavior during sharp price movements, and protection against triggering on market noise;
  • execution and access scheme: where keys are stored, who signs transactions, what limit on switching costs;
  • launch procedure — run on historical data, work at small size, then full position volume;
  • staged work plan with points where you decide to continue or change approach, and scenarios where the mechanics do not protect.

Describe the task in whatever form you have it: trade export, parameter table, or simply pool characteristics. We'll discuss requirements and come back with a task estimate and work plan for your positions.