BLOG — Use cases
Cetra

Cetra

·

427 days ago

Liquidity Management on Uniswap v3

Cetra Finance Use Case: Automatic Rebalancing

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: moves the UniV3 range to always cover collateral, active price and swap funds between pools, and to borrow to ensure proper hedging, liquidation protection, and effective capital usage

AMMs and CLMMs

The Automated Market Makers (AMMs) bonding curve design has become a time-proven standard of DeFi market-making. With years of iterations, it has emerged as a robust, reliable, and capital-efficient way of creating liquidity sources in a permissionless manner.

But don’t let the name confuse you: “automated” doesn’t mean you can look away entirely. It’s automated in a very special sense — trade price and slippage are calculated by a predefined formula that is mainly dependent on pool reserves and swap amounts.

The Concentrated Liquidity Market Makers (CLMM) mechanism is the evolution of AMMs, popularized by Uniswap v3. While the main concepts intuitively follow AMMs, things have become even less automated for investors (liquidity providers). The ability to manage the liquidity range gave us a big strength of leveraging liquidity to receive relatively more fees, but imposed responsibility of watchful tracking positions not only to handle increased impermanent loss but to receive any fees.

The Problems

  • The first and most understandable problem is market risk. You can invest tokens in a 3-digit APR liquidity pool and leave with less in USD terms because of the price fall of the underlying tokens.

  • The second is the complexity and even expense of providing liquidity into CLMM pools: not only do you need to regularly make range-adjusting transactions, but also to decide what is the suitable range.

  • The third and the most specific is impermanent loss management. The most widespread hedging instruments in DeFi: perpetual futures and borrowing protocols, have linear payoffs. However, impermanent loss has a non-linear nature and cannot be perfectly hedged. That forces anyone who wants to control it to hedge the risk actively, readjusting the amount of hedging exposure with the change of underlying asset prices.

Existing Solutions

The most obvious way of managing mentioned LP risks is to implement all calculation logic privately, and execute rebalancing manually or use custom scripts to call needed contracts. This method is frequently used by DeFi asset management funds and might be acceptable for CeDeFi companies.

However, there is a growing amount of DeFi asset management projects using decentralized protocols with automated task execution functionality.

Cetra Finance Use Case

Cetra is an open-source Market-Neutral Market Maker protocol that allows users to provide liquidity in Uniswap V3 pools with deposits and yield nominated in USD stablecoins.

Strategies’ contracts deposit stablecoins as collateral to Aave and borrow needed volatile tokens to be locked as liquidity.

Liquidity range, Loan-To-Value (LTV) ratio, and hedge are then tracked and managed by Gelato.

Deposit Flow and Overall Structure

As said before, only the lending protocol and UniV3 pool are used. Strategies’ math is coded in the contract to have all the cash flows in the right proportion concerning liquidity range, LTV, and current hedge deviation.

Gelato Automate

This is how Cetra Gelato-fies all the position management on an example of a pool with one volatile token (WETH/USDC).

  • The main rebalance function has no call restrictions, as rebalancing is always welcome if the needed conditions are met.
function performUpkeep(bytes calldata /* performData */) external override {
       (bool upkeepNeeded, ) = checkUpkeep("");
       if (!upkeepNeeded) {
           revert ChamberV1__UpkeepNotNeeded();
       }
       rebalance();
   }

  • Checker for rebalance conditions:
function checkUpkeep(
        bytes memory /* checkData */
    )
        public
        view
        override
        returns (bool upkeepNeeded, bytes memory /* performData */)
    {
        {
            (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");}

In the current design, the checker and executable functions are essentially the same thing, as the last can be called only when the first allows it.

Conclusion

Web3 and especially DeFi are created with trustlessness and transparency at their heart.

Cetra shows how complex financial strategies traditionally associated with managers’ involvement can be implemented in a robust, reliable, and efficient way with the use of Gelato’s automation service.

Learn more about Cetra Finance:

Twitter

Website

Documentation

About Gelato

Gelato is a Web3 Cloud Platform empowering developers to create automated, gasless, and off-chain-aware Layer 2 chains and smart contracts. Over 400 web3 projects rely on Gelato for years to facilitate millions of transactions in DeFi, NFTs, and gaming.

  • Gelato RaaS: Deploy your own tailor-made ZK or OP L2 chains in a single click with native Account Abstraction and all Gelato middleware baked in.

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

  • Automate: Automate your smart contracts by executing transactions automatically in a reliable, developer-friendly & decentralized manner.

  • Relay: Give your users access to reliable, robust, and scalable gasless transactions via a simple-to-use API.

  • Account Abstraction SDK: Gelato has partnered with Safe, to build a fully-fledged Account Abstraction SDK, combining Gelato's industry's best gasless transaction capabilities, with the industry's most secure smart contract wallet.

Subscribe to our newsletter and turn on your Twitter notifications to get the most recent updates about the Gelato ecosystem! If you are interested in being part of the Gelato team and building the future of the Internet browse the open positions and apply here.

Cetra

Cetra

· Cetra Finance

·