Liquidity Management on Uniswap v3

Gelato Team

Mar 29, 2023

Summary

  • Active management of DeFi positions is a necessary and inevitable way of developing competitive investment opportunities.

  • Cetra Finance combines the biggest building blocks of DeFi: AMMs, DEXes, and lending protocols to bring institution-like market making on-chain.

  • Gelato Automate controls the rebalancing of Cetra’s delta-neutral chambers by moving UniV3 ranges, swapping funds between pools, borrowing to hedge, and protecting against liquidations while ensuring efficient capital usage.

AMMs and CLMMs

Automated Market Makers (AMMs) have become a proven standard of DeFi market-making, offering robust, reliable, and capital-efficient liquidity in a permissionless manner.

However, “automated” refers to how trade price and slippage are calculated via formulas, not to a fully passive strategy. With Concentrated Liquidity Market Makers (CLMMs), pioneered by Uniswap v3, liquidity providers must actively manage positions. Concentrated ranges can increase fee returns but require constant monitoring to avoid impermanent loss or inactive liquidity.

The Problems

  • Market Risk: Liquidity providers may deposit into high-APR pools but still lose value in USD terms if token prices fall.

  • Complexity: Providing liquidity in CLMM pools requires frequent range adjustments and decisions on optimal ranges, making it time-consuming and costly.

  • Impermanent Loss Management: IL has a non-linear payoff, unlike linear hedging tools like perpetuals and borrowing. This requires active hedging and frequent readjustments as asset prices move.

Existing Solutions

Many DeFi funds manage LP risk by running private calculations and manually rebalancing or using custom scripts. CeDeFi companies may find this acceptable, but it lacks decentralization. A growing number of asset managers now use decentralized protocols with automated execution.

Cetra Finance Use Case

Cetra is an open-source Market-Neutral Market Maker that enables users to provide liquidity in Uniswap v3 pools with deposits and yields denominated in USD stablecoins.

Strategy contracts deposit stablecoins as collateral into Aave and borrow volatile tokens to provide liquidity. Gelato Automate tracks liquidity ranges, Loan-to-Value (LTV) ratios, and hedge deviations, rebalancing as needed.

Deposit Flow and Structure

Cetra strategies use only lending protocols and UniV3 pools. Strategy math is hardcoded in smart contracts, ensuring correct proportions across liquidity ranges, LTV, and hedges.

Deposit flow structure

Gelato Automate

With Gelato, Cetra automates all position management. For example, in a WETH/USDC pool:

  • The rebalance function has no call restrictions; anyone can trigger it when conditions are met.

function performUpkeep(bytes calldata) external override {
    (bool upkeepNeeded, ) = checkUpkeep("");
    if (!upkeepNeeded) {
        revert ChamberV1__UpkeepNotNeeded();
    }
    rebalance();
}

Checker for rebalance conditions:

function checkUpkeep(bytes memory) 
    public view override 
    returns (bool upkeepNeeded, bytes memory) 
{
    (uint256 tokenPool, ) = calculateCurrentPoolReserves();
    if (tokenPool == 0) {
        return (true, "0x0");
    }

    uint256 _currentLTV = currentLTV();
    uint256 _currentHedgeDev = currentHedgeDev();
    upkeepNeeded =
        (_currentLTV >= s_maxLTV ||
         _currentLTV <= s_minLTV ||
         _currentHedgeDev > s_hedgeDev) &&
        (s_totalShares != 0);
    return (upkeepNeeded, "0x0");
}

Here, the checker ensures conditions are met before executing the rebalance. This pairing of conditions and execution guarantees safety and efficiency.

Conclusion

DeFi is built on transparency and trustlessness. Cetra demonstrates how complex, manager-driven financial strategies can be decentralized and automated using Gelato Automate, ensuring robustness and efficiency without human intervention.

Learn more about Cetra Finance:

Twitter | Website | Documentation

About Gelato

Gelato is the Web3 Cloud Platform empowering developers to build automated, gasless, and off-chain-aware Layer 2 chains and smart contracts. Over 400+ projects trust Gelato to execute millions of transactions in DeFi, NFTs, and gaming.

  • Gelato RaaS: Deploy ZK or OP L2 chains with native Account Abstraction and Gelato middleware baked in.

  • Web3 Functions: Connect smart contracts to off-chain data & computation with decentralized cloud functions.

  • Automate: Automate smart contracts with reliable, decentralized execution.

  • Relay: Enable reliable, scalable gasless transactions through an easy-to-use API.

  • Account Abstraction SDK: Built with Safe to combine Gelato's gasless infrastructure with secure multisig wallets.

Subscribe to our newsletter and follow Gelato on Twitter for updates.
Want to help build the future of Web3? Explore open positions and apply here.

Ready to build?

Start with a testnet, launch your mainnet in days, and scale with industry-leading UX.

Ready to build?

Start with a testnet, launch your mainnet in days, and scale with industry-leading UX.

Ready to build?

Start with a testnet, launch your mainnet in days, and scale with industry-leading UX.

Ready to build?

Start with a testnet, launch your mainnet in days, and scale with industry-leading UX.