Cargo Protocol

Published:

the backstage of the blockchain project from a developer's perspective

Description of the idea

The idea of the project was to create an Auto-Compounder, an on-chain asset management protocol for LP Tokens where rewards were automatically reinvested to achieve the highest possible compound interest rate.

From the user's perspective, we tried to achieve simplicity. Users just chose which token they wanted to deposit, and the protocol found the best possible investment strategy with the highest compound interest rate. In the background, the smart contracts swapped users' funds into a matched pair of tokens and injected that pair into a pool as a liquidity provider, minting LP tokens in return. The LP tokens are stored in the smart contract, and the user receives Protocol Custom Tokens representing his share in the pool. The user could safely leave his deposit unattended. Meanwhile, a bot collected the accumulated rewards, swapped them, and reinvested them into the most profitable pool. The main goal was to increase return on investment, which was successful because the mechanism changed it from linear to logarithmic.

.

As the project proceeded, we came across an idea to integrate with the Moola Lending Platform (AAVE Protocol), a non-custodial liquidity protocol that democratizes access to yield and credit. Using Moola, we pushed the project further by giving the user more customization to their investments by taking out an over-collateralized loan and paying it back with the collected rewards from Auto-compounder. 

We could offer a financial pillow to the users by collecting and redistributing the rewards depending on their risk factor and strategy, but only to a particular risk point.

Meanwhile, our analysts conducted market research and decided to shift our focus to a newer version of Uniswap Protocol - V3, due to the protocol's debut on Celo Blockchain.

Uniswap V3 Protocol introduced new features we used to achieve better capital efficiency for the protocol.

Uniswap

Uniswap is a leading DEX protocol that initially runs on the Ethereum blockchain. It's the world's second-largest cryptocurrency project by market capitalization, which makes it compatible with all ERC-20 tokens and infrastructure.

Nowadays, the newest version of Uniswap (V3) is working on a couple of significant chains like Ethererum, Polygon, Optimism, Arbitrum, and CELO. Still, most of the competitor's DEX's are using the Uniswap Protocol V2. 

As for now, the Uniswap v3 has about ~5.5x more liquidity than Binance, according to the published research made by Uniswap.

https://uniswap.org/blog/uniswap-v3-dominance

Uniswap v2 vs. v3

Uniswap V3 was an evolutionary-improved DEX protocol that maximized the return for traders and liquidity providers with concentrated liquidity, minimized the price slippage, and provided improved Autorouting.

Unlike Uniswap V2, where each liquidity provider received an amount of LP token according to their proportion to the total liquidity added, the v3 positions are now represented by NFTs.

This liquidity representation causes it to be nonfungible. 

Previous versions of Uniswap (V2) distributed liquidity along a price curve ranging from 0 to infinity. The disadvantage of this strategy was that the majority of the liquidity was never used in many pools because it was placed outside the price range in which the token pair was most often traded.

Liquidity providers can now concentrate and deploy their liquidity within whichever price range they wish, so each position has a customizable set of parameters that determines its value and rewards, bringing better capital efficiency.

Integration with Uniswap: Cargo + Celo + GUNI + Uniswap v3

Our premise was to create an automated, low-gas cost tool that manages, automates, and optimizes concentrated liquidity. So the first version of the Cargo protocol after the switching from Ubeswap was using the Nonfungible Position Manager from Uniswap V3 to create and manage positions in liquidity pools. This solution required a lot of gas by starting, and closing positions due to each action's NFT burn & creation process.

At this point, we came across the G-Uni Protocol, which enabled the creation of managed position pools on Uniswap v3's, and we used it as a layer at Cargo. G-Uni Pools can bypass the minting process of the NFT's by directly injecting the liquidity to the Uniswap pool and generating a 32-bit position ID representing the position itself. This solution significantly optimized the protocol due to saving gas consumption. By adjusting the reinvestment frequency and the spread of the positions, we can create different management strategies for users.

The strategies can also protect us from reinvesting earned fees when the gas cost of the calling function is higher than the reward. 

The diagram shows the whole flow of the protocol.

The user is investing in one of the Cargo Pools (the money goes through the Cargo Service contract, an interface between Guni Pool and Cargo Protocol. The G-Uni Pool is providing liquidity in Uniswap V3 and returning a position ID) on top of that, we are generating a Token for the user itself to represent his position.

Lesson learned

The most challenging yet fun part was the securitization of the protocol. Especially in the blockchain world, security is critical because even while blockchain produces a tamper-proof ledger of transactions, smart contract code can have vulnerabilities and is not always immune to different types of attacks. But at Neti, we are (very focused on the security layer and work with varying companies of audit which back check the code.?)

Summary

Building this piece of software was an exciting journey, but we haven't done it alone, so we would like to say "thank you guys" to the support team from Uniswap..

The project's development was a fascinating adventure for us. We had the opportunity to leverage our knowledge about the protocols and create unique opportunities for investors by combining them all into one simple product. Have we made some mistakes? For sure! But it's not about don't making mistakes, but about learning from them and do not repeat them in the future! Building blockchain and especially DeFi solutions are very often a kind of R&D work, so verifying different ideas is a natural part of the development process. 

Finally, we have built a solution that makes us proud of our work. Of course, they can and should be further developed ... but this is a story for a completely different article. ‍

Latest posts

Browse all posts