Integration with Gamma Strategies (Liquidity Management)
A Uniswap v3 position in ±5% range from current price earns 10-20x more fees than a full-range position, but exits the range on first serious market move. After exiting, LP stops earning and sits in 100% of one token. Gamma Strategies solves this with automatic rebalancing — vault contracts managing Uniswap v3 position and repositioning range as needed. Integration with Gamma lets you add managed liquidity to your protocol without building your own rebalancer.
What to Know Before Integration
Hypervisor: Gamma's Interface
Gamma wraps Uniswap v3 position in Hypervisor contract — ERC-20 token representing share in managed position. User calls deposit(uint256 deposit0, uint256 deposit1, address to, address from, uint256[4] minIn), receives Hypervisor LP tokens. minIn[4] — slippage protection: minimum accepted amounts of both tokens.
Main integration mistake: ignoring minIn. Passing [0, 0, 0, 0] makes deposit execute at any slippage — user gets fewer shares than expected. On volatile market, significant losses. Correct approach: fetch current ratio via getTotalAmounts(), calculate minIn with 0.5-1% tolerance, pass to deposit.
Rebalance Timing and Impermanent Loss
Gamma rebalances by vault strategy — usually when price exits range or significant volatility change. Rebalance happens via rebalance(int24 _baseLower, int24 _baseUpper, int24 _limitLower, int24 _limitUpper, address _feeRecipient, Rebalance calldata swapConfig) called by Gamma keeper.
For integrating protocol: position NAV can momentarily decrease at rebalance due to swap costs. If user redeems at that moment — exits at temporarily reduced price. Monitoring via Rebalance events lets you warn users.
Visor → Gamma: Versions and Deprecated Contracts
Gamma went through versions. Old Visor Hypervisor contracts on Ethereum had vulnerability in emergencyWithdraw without proper access control — 2022 exploit cost $3.4M. Current contracts are audited and use UniProxy for deposit routing with whitelist checks. On integrating, ensure using current addresses from official Gamma registry, not hardcoded old addresses.
Technical Implementation of Integration
On-Chain: Deposit via UniProxy
Recommended path — via UniProxy.deposit(), not directly to Hypervisor. UniProxy checks:
- Hypervisor is in Gamma whitelist
- Deposit ratio matches current position composition
- Applies automatic split: if user deposits only token0, UniProxy swaps part to token1 via Uniswap v3 and deposits in correct ratio
IUniProxy(UNIPROXY).deposit(
amount0, amount1,
msg.sender, // recipient of LP tokens
hypervisorAddress,
minAmounts // [min0, min1, minShares0, minShares1]
);
Approve needed on UniProxy address, not Hypervisor — common error causing revert.
Off-Chain: APR Calculation and Monitoring
Gamma provides REST API for current Hypervisor data: GET /hypervisor/{address}/basicStats — TVL, APR, fee APR, total amounts. Sufficient for dashboard integration.
For precise on-chain calculation: Hypervisor.getPrice() returns current sqrtPriceX96, getTotalAmounts() — current token0/token1 amounts. Shares → underlying via (shares * totalAmounts) / totalSupply.
The Graph subgraph from Gamma — https://api.thegraph.com/subgraphs/name/gammastrategies/gamma — provides historical rebalancing and fee collection data.
Development Process
Analytics (1 day). Determine needed Hypervisor vaults for target pairs and chains. Gamma supports Ethereum, Polygon, Arbitrum, Optimism, BSC.
Development (2-3 days). Smart contract integration via UniProxy, frontend hooks for deposit/withdraw/APR, fork mainnet tests.
Monitoring. Alerts on Rebalance events (temporary NAV dip), whitelist status monitoring (theoretically can change by Gamma governance).
Timeline Estimates
Basic integration with one Hypervisor vault — 2-3 days. Full UI with multi-pair, APR display and rebalance notifications — 4-6 days.
Cost calculated after analyzing integration requirements.







