1. A Need For S̶p̶e̶e̶d̶ Automation
If you’ve ever taken a ride on the DeFi roller coaster , you’re probably aware that high yield opportunities in respected projects and protocols are short lived. There was a time when tech savvy users and degen investors could exploit these financial opportunities manually, but with the advent of big players and institutional investment in crypto, there is a pressing need for preparing ahead by having the tools ready to execute the strategy as soon as it becomes profitable. And that’s what automation is all about.
For this project, automation takes the form of highly abstracted smart contracts: elaborate pieces of code imprinted with the knowledge to exploit DeFi strategies as fast as you hit deposit.
1.1 Use Case: Delta Neutral Vaults
To illustrate the potential of the system designed, this case study is going to focus on one type of DeFi strategy, considered “Delta Neutral”.
1.1.1 What Is A Delta Neutral Strategy
A Delta Neutral strategy is defined as one that takes into account multiple positions (assets investment possibilities) whose response to market variations of the price is of different sign and compensates mutually, making the overall variation (delta) of the strategy neutral with respect to the market variations. The hypothesis of the delta neutral strategy often comes with assumptions on the market, and how much it can actually vary, meaning that these strategies have a context in which they work as expected.
In this case, the strategy consists in depositing an asset of stable value in a lending protocol, and using it as collateral for a loan of an asset considered unstable. The unstable asset provides access to higher risk investments with higher yields, and after some time, when the investment is done, the user collects the profits generated with the borrowed assets, paying back its debt, and getting its stable tokens back. Provided that the variation in price (delta) is not such that the borrow position gets liquidated, the market variations in price did not affect the investment substantially.
2. Why Standard
The proliferation of Vaults to handle users’ assets in DeFi has led to the need for standardisation in the field; with the introduction of EIP-4626, a token standard for tokenised vaults was defined. But standardisation is not just about agreeing to do something in the same way. It also brings the possibility of abstracting above layers, knowing always that the higher ones can speak to what’s underneath in the same way, no matter the complex logics lying beneath.
Rather Labs’ Modular Standard Vaults take advantage of this abstraction by separating the logics of its vaults in layers of increasing complexity. In layer 1, one can find vaults that know how to handle specific protocols, whereas in layer 2, complex financial strategies are implemented. This means one can invest in one or more of the vaults of the underlying layer.
3. Why Modular
Among each layer, every vault is treated modularly and categorised in “families” of protocols. For instance, a vault that knows how to interact with the Aave protocol belongs to the same “family” as a Compound vault, both being lending vaults. As such, they’re interchangeable for any higher layer vault that uses any lending protocol for its strategy. Moreover, forks of these projects (projects that use the same codebase) can be interacted with just as easily; CREAM finance, a fork of Compound, can be used with a Compound vault, with some parameter adjustments.
4. A Composable Solution
Rather Labs’ Modular Standard Vaults take a composable approach. What does this mean? Every kind of vault, be it a layer 1 or 2, comes with an “Implementation” and a “Factory” smart contract. When a user wishes to exploit a strategy (say, a Delta Neutral strategy) investing a given token (USDC, stable) using given underlying protocols (CREAM finance and SushiSwap on Polygon), all it needs to do is ask such layer 2 Factory (Delta Neutral Factory) whether or not there is a specific smart contract for a layer 2 vault with such parameters. In case there isn’t, the Factory can instantiate a gas efficient proxy smart contract for this layer 2 vault, whose function is solely storing the needed variables in memory, while for the logic it always turns to the original implementation of this strategy’s contract. For this, the Clones library by OpenZeppelin is used.
Below the surface, the layer 2 Factories work in the same way with the layer 1s: checking the existence of a vault for a specific protocol and asset to invest, and if there isn’t a new clone proxy is deployed.
5. Delve Deeper Into The Code
At Rather Labs we’re excited to share our work with the community, and we believe that when knowledge like this is spread, everyone grows. That’s why we’ve made this development open source and available in this repo.
You can also check an implementation of the smart contracts deployed on Polygon, and interact with them through the Polygonscan interface using the following links:
- SushiStakingLogic: 0x47727894a06C009ca106dCE208F9889BB8d45593
- SushiStakingVaultImplementation: 0x53ddc20060329da7af3ea721938f379165947336
- SushiStakingVaultFactory: 0xd13F69353A410420c0aD7B74507fD88DA35927D2
- CompoundLendingVaultImplementation: 0xa7501f2847797C8942A5c8972b6E7D13f4Ad475F
- CompoundLendingVaultFactory: 0x3cae80e6ba30c4b5b2f5d5213078ad1516651de6
- DeltaNeutralVaultImplementation: 0xe303a2d4255946f2e58f0fbb789dd2fb44334e4c
- DeltaNeutralVaultFactory: 0x8e3ae5cb3e0f20b469f6ff34707ccb76dcf172db
Rather Labs’ PoCs
This article is written in the context of a series of Proof of Concept projects being developed by the Rather Labs Team. Using an approach of fast iterations for market validation, the aim is to explore new technologies and share knowledge publicly with the community.
The cycle of work comprises 1 to 2 weeks in which the project is designed, developed, and published. The time constraint is one of the most important challenges of each iteration, so that’s why it should be noted that none of the content and code produced is in its final form. Everything is still in the works, but we love to share the updates with you!
About Rather Labs.
Rather Labs is a Blockchain Technical partner who provides the blockchain expertise along with the partner intensity founders need.
Rather Labs is committed to work alongside our clients as a technical partner, providing insights, technical design, engineering team management, recommendations, maintenance and technology projection.
The company is led by co-founders which have been involved in blockchain projects in finance, real state, gaming, and other industries for years.