Do you even Tokenized Strategy?

It is a great honor to be the lead developer of Yearn V3 during its launch. But I am far from the first or only dev to contribute to the concept or the code of what we are attempting to build.

When I took over V3 from the legend Mr. jmonteer himself, building something that all of DeFi can use to create the next generation of yield aggregators with, was firmly set as the goal. The vision to commoditize what Yearn does, in order to be the underlying infrastructure of all on-chain capital allocation is what has been the driving force behind our design from before I made my first pull request.

At the heart of any yield aggregator, no matter the number behind the V, the majority of value is derived from its ability to have robust, secure and efficient code that can integrate with the rest of DeFi to generate the yield users are looking for.

At Yearn that job is given to our strategies, and is what this article is focused on.

Since it's conception, V3 was built to be fully ERC-4626 compatible through-and-through. Both the vaults and strategies were to have the 4626 interface in order to improve composability across the board.

So, when I took over V3 development much of the work on the Vaults had been completed and my first main focus was on revamping the heavy lifters of the system, the strategies.

It's not much but its honest work

For a quick refresher, or just a fresher for those that don't pay attention, in V2 we have "Vaults" and we have "Strategies". Users deposit into the vault and the vault would allocate those funds amongst an array of strategies.

The vault handles the deposits and withdraws for users, as well as tasks like minting shares and handling accounting. It's job is to be the immovable object, that protects users funds from the unstoppable force of the dark forest of femboys.

The strategies then do the work of deploying the underlying token into a specific protocol to earn yield. Their job is to be adaptive to the current market and handle the specifics of whatever protocol they are deploying funds into.

In V2 each strategy had a trusted relationship with one specific vault. The vault was the only one who could deposit or withdraw from that strategy. And the strategy is worthless without its special little vault.

You can think of it as your classic monogamous relationship, minus the evergrowing hatred of your life partner.

This design has many benefits and is a secure and flexible way to deploy capital.

However, as a child of divorce myself, it seemed like there are some obvious potential pitfalls. And if we want to continue to build a more open, permissionless and composable system it doesn't quite match that goal so well.

We want DeFi to be more of a free lovin, kombucha sippen, Phish t-shirt wearin, polyamorous type of vibe.

Introducing Tokenized Strategies.

One of the biggest updates from V2 => V3 is the introduction of what we call "Tokenized Strategies".

They serve the same purpose as their V2 counterparts. To earn that sweet, sweet yield. But function entirely different.

In V3 each strategy is now its own stand alone, fully ERC-4626 compliant vault!

These free spirited strategies don't need no vault.

They handle their own accounting, mint and burn their own shares, and are able to handle deposits not only from any number of different multi strategy "allocator" vaults, but also any other EOA, multi-sig or rando that wants to slip in, maybe just for one block or for all eternity.

This means we got strategies that are vaults. Vaults that are strategies. And red hot levels of composability never before seen in the history of distributed ledger technology.

Now, due to its

uninhibited nature this new setup can sometimes feel a bit like listening to a TikTok video of some zoomer explaining what their gender identify is. The language gets confusing.

So bear with me a little.

But for the sake of this article, as well as future communication in relation to V3, when we refer to a "strategy", it means a 4626 compliant vault that has one specific protocol it integrates with to earn yield, built as a Tokenized Strategy. And when we refer to something as just a "vault" or "allocator vault", it is in reference to a V2 style vault, that has multiple strategies added to it, that it distributes funds amongst.

But the TLDR here is everything is now a vault.

With this new design, developers are now free to design their strategies to participate in all sorts of wet and wild experimentation that their old fashioned V2 elders would never approve of.

Maybe you want a strategy that never settles down with any one depositor and is open to anyone that wants to take it for a swing?

Sometimes, there is that one special vault in your life you know is the most important. But hey, you're not one to say no to good time to help pump that TVL.

You wanna manage an allocator vault, but may still be a little strategy curious? No problem, with everything 4626 compatible its okay to be vault-fluid and plug that bad boy right into someone else's allocator as a strategy itself.

Or perhaps, your the more traditional type, and know there's one vault that's the only one for you.

Whatever your style, we don't judge.

And its all now possible with just a few lines of code.

I said co-De!

But how?

In order to allow for strategists to be as free and promiscuous as possible with their vision, while also making sure the base logic is robust and feature rich we needed to think a little outside of the box.

One of the main limitations we run into is contract size. The EVM enforces a contract size limit since EIP-170 of 24 KB. And despite the recent plea of DeFi's CEO to increase this limit, it seems unlikely to happen any time soon.

ERC-4626 is no small standard. It comes with quite a bit of functionality and rules that need to be followed and conformed to, that all take up crucial space in a contract that uses it. And that’s without even beginning to consider extra functionality like profit and loss accounting, emergency functionality, or safe words.

For reference our V3 multi strategy allocator vaults are over 23 KB with no strategy specific logic.

When it comes to the EVM, size really does matter...

Alright, that's probably enough with the innuendos.

All of this base code, not only takes up crucial space that is needed for a strategists specific vision, but is also expensive to deploy, causes state bloat and is an extra security risk every time someone goes to deploy their own version.

So what’s a red cartoon pig to do?

Well, we developed a novel immutable proxy pattern that all Tokenized Strategies use in order to outsource all of the redundant and high risk code to one central implementation contract. This implementation contract only needs to be deployed once on each chain and will manage storage, and standardized logic for every Tokenized Strategy deployed on that chain!

Now I know what your thinking.

"Did he just say the P word?"

"I thought Yearn was better than that!"

"Banteg is gonna be pissed!"

And while that last one may be true, I assure you this ain't your daddy's proxy contract. These are completely non-upgradable, and have all non-traditional storage handled entirely by the implementation. Which means devs do not have to know or care how it works when building their own version.

Strategists simply inherit a BaseStrategy, that is less than 1 KB, that handles all communication with the implementation and are left with only a few simple functions to implement themselves, and able to handle their own storage just as any other contract would.

This design means it is now possible to build, deploy and run your own fully permissionless, ERC-4626 compliant vault with only 3 lines of code!

Can your vault do that?

Tell Me More

Well, if you made it here through the rampant sexualization of a code base, talk of smart contract design and far too many mentions of the term "ERC", you're probably a giant fucking nerd and should really log off and go for a walk or something...

Seriously.

But, since we both know that's not gonna happen, let's talk about the most pressing question on everyone's mind.

"How do I get my own Tokenized Strategy?"

Great question!

Due to the old-timey relationship that V2 strategies had with their vault counterparts, as well as the proverbial gates that were wrapped around those vaults, it was not particularly easy to become a Yearn strategist in the past.

Lucky for you I somehow managed to Trojan horse my way in and am now ready to blow up the gates behind me.

Since strategies can now live on their own with no vault needed, anyone can build, test and run their own V3 strategy with not as much as an 'atta boy' from any Yearn contributors.

All you need to get started is a can-do attitude, some elbow grease, and our one of a kind pre-built Tokenized Strategy Mix template repos!

These mixes are built so all you need to do is clone the repo locally to start building out your idea today!

But wait, there's more!

While, it is possible to build a strategy with only 3 lines of code, obviously most ideas will need more. This is why we have also developed a suite of optional "periphery" contracts that can be used in or alongside your strategy for increased functionality.

If you act now, all these periphery contracts come at no extra charge!

There is a Health Check contract to make it safer to run higher risk strategies that utilize things such as leverage with no extra code needed.

There are swapper contracts to inherit that make integrating with DEX's like Uniswap V3 as simple as one line of code.

There's Report Triggers, to easily manage your strategies profit cycles and keeper integrations.

And much much more!

Why wait? All this could be yours!

Building strategies as permissionless vaults comes with its own set of challenges and risks that didn't exist in V2. But the simplicity and abstraction of the base functionality of the Tokenized Strategy design, makes it the easiest and safest way for anyone to bring their idea to life. And by default have it be fully compatible with the rest of DeFi, including Yearn managed multi strategy vaults.

And with Yearn devs standing by, eager to help, there's never been a better time than now to build your own!

We hope to see an abundance of minxy strategies mixing it up on chain in the future, built by a wide array of strategists.

Each competing on different trade offs and features. Giving allocator vault managers an abundance of options based on their own liquidity needs, risk tolerance and yield-orientation.

The time, money and effort it takes to build your own ERC-4626 vault from the ground up is massive.

Trust me. We built multiple. Don't do it.

So rather than spending your time learning about the 4626 inflation attack and how to mitigate it. Just spend that time writing the next best lender-borrower.

Instead of spending $100k on an audit. Spend a tiny fraction of that to deploy your new extra small Tokenized Strategy.

In place of trying to figure out the proper rounding differences and expected return values of previewWithdraw and previewReedem, just go outside and touch some grass for gods sake, cause you would have finished your strategy weeks ago if you just used the Tokenized Strategy standard.

And the next time your in the middle of 72 tweet thread explaining some new "yield alpha" that requires you to do 45 individual transactions.

Just say,

"Do you even Tokenized Strategy?

Subscribe to Schlag
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.