# How to Become a Mighty Strategist
<iframe width="560" height="315" src="https://www.youtube.com/embed/6og7NV7lzUk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
```
*Authors note: This is a transcription of a talk given by Facu Ameal at Eth Denver 2022*

**What’s a Strategist?**
Hello, everyone. I'm Facu from Yearn Finance. I'm pumped to be here and to be doing this workshop. This is going to be a high-level overview on how to create a new investment strategy for Yearn. And then afterwards we'll share a code so you can join office hours. Let's start from the beginning. What's a strategist? A strategist is just a big-brain guy or girl or whatever. We don't care. We encourage the anonymous community actually, you don't need to be a hardcore developer or anything. You need to understand how things work, how things connect. That's the most important thing. Programing and languages, you can learn them. That's not a problem at all.
**Vaults and Strategies? What’s that?**

So let's see what's a vault? A vault is just a container of tokens, like a piggy bank where you drop your tokens and those tokens are taken by the strategies.
Those are the ones that are going to be doing all the heavy lifting of the strategy. Those vaults are going to send the funds to the strategy which is going to invest those funds. It's going to collect the rewards and recycle them into the same token, compounding your investment. All the vaults run multiple strategies. That's an important thing to take into account because with $500 million you cannot deploy them all on the same place.
And we're also Keep3rs integrated. We decided to do the strategies in Solidity because you're able to inherit from other contracts, and that's important because you are going to see all the interactions between the strategy and the vault are already coded. So it's super simple to create a new strategy.They manage the accounting and invest, univest and recycle the rewards into "want token".
Also, they take care of harvest, they check the slippage and they keep the collateral ratio healthy. That's to say you can manage a CDP position. A collateralized position using a strategy per vault. And it's perfectly safe. So it's safer to do it this way than a user doing it manually.
Let's take a look at how it looks, a vault today. This is the yvUSDC. And as you can see, has lot of strategies, important things to take into account. All of them have different percentages. The strategist is the one who runs simulations and those simulations are the ones we decide how much percentage of capital all those strategies are going to get.

It's always different because it changes depending on the status of the underlying protocol. And the other important thing to take into account is that we have strategies with 0% capital allocation. They are ready to run, but right now they might not be profitable, its not the right moment to enable them.
**How do Vaults and Strategies interact?**
For me, the most important part, is to call the strategy. It's understanding how this whole system works. It has five parts, the keepers, which are the the the centralized bot network, they're going to run the harvest. The harvest is the function that collects and recycles the rewards. The vault, the strategy, the identify protocol. It can be any DEFI protocol, AAVE, Compound, whatever. An index, to exchange the tokens that you receive as rewards for the "want token", the token that the user deposited.
So the keeper is going to be monitoring a view function that's called the harvestTrigger. When it becomes true, it's going to execute the harvest function that harvestTrigger is important because we want to collect the rewards and recycle them when it's profitable to do so because in Ethereum gas costs are high. So we have to take that into account.
When it happens, what the strategy has to do is to claim the rewards and swap them. That's it. It's going to receive the "want token" is going to send the report to the vault because the strategy has to inform the vault what's going on with the underlying protocol to change the price per share. It's going to adjust the credit available.
And this is an important concept. The strategies are taking a loan. So we call it debt. The strategy has a debt with a vault that is got to return at some point. OK, that's just conceptual. Then it's going to adjust position, we're going to see what that does afterwards and send a success to the keeper and that's it.
Well, this is just like high level overview, let's see how how the process looks like. I'm going to do like a fast run through the non-technical parts and we're going to see more in depth the technical parts of the process.
**What do I need to write a Strategy?**
OK, first, what do you need? Basic stuff. Git, eth-brownie, ganache. It's what we use, the brownie mix repository.
This is actually a template that you can use and has a lot of work already done. On VS code, when I wrote my strategy, I had some programing experience. I only did cryptozombies on base level four, that was my solidity knowledge, pretty basic. So anyone can do it. I understood how things interacted at the vault and strategy level and I used a ton of willpower because you need to spend some time coding and then reviewing especially.
**Let’s write a Strategy**

Well, let's go for it. This is our process. We're super security oriented. So for us it's super important to actually test in test, and then test in prod. Both things are important. So we have a due diligence part with the strategy, you have to do an investigation of the underlying protocol and present a report so the security analysts can check it out and validate that everything is perfectly safe. It's like a mini-audit. Then you're going to code your strategy. Then it's going to go through a peer review, because we all know that audits take time and a lot of money. And then you go to an experimental website we have, that's the part we test in prod, then the core devs are going to review it.
Safe Farming Committee is going to review again, do its due diligence and it's going to give the green light to go to production.
**Due Diligence**
Let's go step by step. This is the due diligence process. You can check, I will just say some highlights about it, like the rug-ability section that it's not about the code, but about who is governing those contracts.
That's super important because when you check it, you see multisigs. So we tell the protocols, "hey, we need this to be changed", and they usually accept it and they're very, very glad to do it, so these are the things that we check before starting to code a strategy, it's nonsense to start coding a strategy, using an on-site protocol.
Prepare your environment
Basic stuff to start coding. First, the tools needed. You're going to eth-brownie and ganache. You've got use the brownie-strategy-mix template and clone your repo. That's basic stuff, super simple.

Well, where do you have to take a look, strategy.sol, is where all of the work is going to be done or a big part of it because tests are also important. Most of the stuff in the directions we already have package them and it's in the baseStrategy.sol so you don't have to take care of it, you only have to code the custom interactions with the protocol that you're going to farm.
**Strategy.sol**
Let's take a look at the three functions that you have to code. If you code these three functions, the strategy is going to work. You may need more to implement your custom protocol, but these are the three functions that you need. adjustPosition, is just going to invest the funds. So if it's a staking protocol, it's going to stake those funds. That's it. That funding parameter, it's how much it has to invest. liquidatePosition is going to do the reverse, its going to withdraw from the underlying protocol, or to liquidate the position if it's an LP or whatever. prepareReturn, thats where the heavy lifting happens. That's where you have to pay more attention and that where you have to calculate profit, losses and also free up assets when the vaults need to withdraw, because the principle is that every user has to be able to withdraw at any time, at any point in time. /Tests, test, test, test! That's super important for us because we cannot test in testnet, we need the protocol to be light. So you need to write tests, this is the repository, the brownie mix. We already have some basic tests all ready for you, so that you can use them. But this is a production strategy, it looks very different, so you have to spend a lot of time testing because it's going to be useful to not have any issues when you have real money in the vault. Well, this is almost the last step. Two peers, two strategists have to review your strategy. Then you have to choose a name, this is the fun part.
Choose a name and two emojis and go to experimental. This is a real vault that was an experimental some time ago. This is the part that we test in prod but we have a deposit limit just in case.
**Safe Farming Committee + Core Team Review**
Part of the procedure, I'm going to go fast over this, is the Safe Farming Committee. It's a committee of people that is assessing if the strategy is ready to go to production or not, is going to take into account the due diligence and also if the peer reviews and everything has been done. The core team review, it's reviewed by our security specialists.

They do an in-depth review of the strategy or what we do to do the process faster, if you're ready to review the protocol and it's a fork, we check the differences. We do a diff check. OK, you made it, you did the strategy and it's in production... but it's not done. Strategies need maintenance and monitoring.

**Stay and help manage the strategy**
We monitor the harvest, we monitor debt ratio, the APR and especially the state of the underlying protocol because if something changes, the strategy needs to adapt or we need to adapt it. So it's super important to stay and monitor.
That's all guys, and since the workshop is short, we're going to hold office hours in half an hour, this is our telegram group [QR code] for new strategies.
So if you scan it, you are going to join what we call the boarding school. The strategists are always there answering questions. So if you are building something and you have questions, that's the best place to do it , like 24/7. If you have any questions you can ask now also and then we can continue online. OK, one more thing I love POAPs, so if you came here, you can click that POAP, it's a really nice one. It's the first event that Yearn is sponsoring, so for us, it's a special one. So claim it. So have a nice one, thank you!