Uniswap v3 LP Rebalancing System Development – Automate & Optimize

You open an ETH/USDC position on Uniswap v3 in the range $1800–$2200. ETH goes to $2500 — the position fully converts to USDC and stops earning fees. Without automatic rebalancing, you lose income due to fixed impermanent loss and missed fees. In practice, lack of automation reduces potential profit

Blockchain Development Services

Frequently Asked Questions

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1310
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1270
  • image_logo-advance_0.webp
    B2B Advance company logo design
    719
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    1012
  • image_logo-aider_0.webp
    AIDER company logo development
    955
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    1063

You open an ETH/USDC position on Uniswap v3 in the range $1800–$2200. ETH goes to $2500 — the position fully converts to USDC and stops earning fees. Without automatic rebalancing, you lose income due to fixed impermanent loss and missed fees. In practice, lack of automation reduces potential profit by up to 30% per month. Manual monitoring and recreating positions is a task for automation as soon as you have more than one position. Our team has DeFi experience and has implemented over 20 projects for LP position automation. Each contract undergoes internal audit (Slither, Mythril) and formal verification of key functions. We guarantee audited, secure code with a proven track record.

When and how to rebalance

Triggers for rebalancing

Main trigger approaches: price-based — triggers when price exits range (simple, but ignores fees); time-based — rebalancing every N hours (predictable gas costs, but unnecessary in flat market); fee-accumulation — when accumulated fees exceed gas cost for rebalancing (economically optimal, but harder to calculate). In practice, we use a combination: price-based as primary, fee-accumulation as a check of feasibility, reducing unnecessary rebalances by up to 20%.

Strategies for choosing a new range

  • Fixed width: new range ±N% from current price. For ETH/USDC N=10–20%, for stablecoin pairs 0.1–0.5%.
  • Volatility-adjusted width: width = k × ATR(period). In high volatility, range is wider; in low volatility, narrower. ATR is calculated off-chain. This strategy reduces IL by up to 50% compared to fixed width.
  • Asymmetric range: in a trend, range is shifted (e.g., [price×0.95, price×1.15]), requires trend detection via moving average.
Strategy When to use IL reduction vs fixed width
Fixed width Simple assets, low volatility Baseline
Volatility-adjusted High-volatility assets 50%
Asymmetric Trending market 30%

How to minimize impermanent loss during rebalancing?

Each rebalancing fixes current IL. In a sideways market, frequent rebalancing accumulates IL without sufficient fee income. A mandatory step is backtesting the strategy on historical data. For ETH/USDC on Arbitrum, we take data from Uniswap v3 subgraph over 6–12 months, simulate different strategies, and compare net APY after gas and IL. Optimal rebalancing frequency can save up to $50 per month on one position (depending on pool size and volatility).

Why gas optimization is critical?

One rebalancing operation includes collect(), decreaseLiquidity(), another collect(), swap to restore ratio, and mint() — total 4–5 transactions. Using multicall in NonfungiblePositionManager we can combine calls, reducing gas by up to 40% and eliminating state change risk between steps. Swap moves the price (slippage) and opens MEV for sandwich attacks. Protection: minAmountOut with allowed slippage 0.3–0.5% or using flash loans for atomic rebalancing. Gas optimization yields savings of $10–$30 per rebalance on Ethereum mainnet.

Keeper infrastructure

  • Chainlink Automation: contract implements AutomationCompatibleInterface with functions checkUpkeep (off-chain) and performUpkeep (on-chain). Payment in LINK, delay up to a few blocks.
  • Gelato Network: similar, with more flexible conditions and payment in native token.
  • Custom keeper bot: Node.js/TypeScript service. Cheaper but requires infrastructure.

How to choose a keeper network?

Keeper network Reliability Cost Setup complexity Gas savings vs custom bot
Chainlink Automation High (99.9%) Medium (LINK) Low 20% cheaper due to no infra
Gelato Network High (99.8%) Medium (native token) Low 15% cheaper
Custom bot Medium (99.5%) Low High Baseline

For production we use Chainlink Automation or Gelato. Custom bot as fallback. If custom off-chain computation is required before signing, Gelato is preferable — it allows off-chain calculations.

Rebalancer contract

interface IRebalancer { function rebalance( uint256 tokenId, int24 newLowerTick, int24 newUpperTick, uint256 minAmount0, uint256 minAmount1 ) external returns (uint256 newTokenId); function shouldRebalance(uint256 tokenId) external view returns (bool, int24, int24); } 

shouldRebalance is a view function for keeper checkUpkeep. Access to rebalance is restricted to owner or authorized keeper.

What's included

  1. Development of the rebalancer smart contract (Solidity 0.8.x)
  2. Implementation of range selection strategy (off-chain, TypeScript)
  3. Keeper network setup (Chainlink Automation / Gelato)
  4. Tests on mainnet fork (Foundry)
  5. Documentation for operation and monitoring
  6. Support for 30 days after deployment

Timeline estimates

Basic system for one position with Chainlink Automation — from 5 business days. The timeline may increase with complex strategies or integration with multiple pools. Want to discuss your project? Contact us — we'll help you choose the optimal strategy and stack. Get a consultation for your project.