DAI Vault from @iearnfinance

🐵User
🏦Vaults v2
🧑‍🤝‍🧑Governance (🗳️Voting+✒️MultiSig)
💰Treasury
🦄UniswapV2Router02 @UniswapProtocol
🏦IronBank @CreamdotFinance
👻Flashloans @AaveAave, @dydxprotocol
💱Lend/Borrow @compoundfinance
🧠Strategist
🤖Keeper

h/t @arbingsam
🧵👇
This thread has 2 explanations:

1. For the average Joe.
2. For techies

Feel free to read whatever you want and drop any questions that you may have in the thread.

Let's start with the average Joe explanation.
Average Joe Explanation:

Till now the way the strategies have been working is by interacting with other protocols as if it was a user (like you 😊).

So, the strategy is just like a 🐳 who has a lot of funds and has nice "tricks" to maximize profits.
Basically, these strategies didn't have much advantage over a whale (both are interacting with the protocols as external users).

But now things are changing.

The protocols are not working separately, they are working together.
So now these strategies (whitelisted with IronBank) can ask protocols like @CreamdotFinance (IronBank) for loans without putting up ANY collateral 🤯

See here for details on lending/borrowing rates for different assets: https://docs.cream.finance/iron-bank/iron-bank
Now, these strategies have a huge advantage over any normal user cause they now have access to a huge lending/borrowing pool (for ZERO collateral) which is not available to normal users.
Yes. This is scary shit.

But wait, we don't plan to go BRRRRRR... and then loose all our 💰

There are a lot of things that go into making sure that the IronBank stays solvent.
1 (a). Whenever an address (contract) is whitelisted to the IronBank, it goes through extensive internal and external audits, in addition to the borrower's (usually a project like @iearnfinance) reputation/track record.
1 (b). Each whitelisted contract has its own credit limit in USD assigned to it after accessing the protocol specific risks involved.

2. @CreamdotFinance is insured by @CoverProtocol, @NexusMutual.
The strategy in the diagram does the following things:

1. Takes $DAI from the Vault depositors.

2. Takes $DAI loan from IronBank for 0 collateral (with Collateral Factor: 90%, Reserve Factor: 5%)
3. Puts the DAI from step 1,2 into @compoundfinance and uses flash loan magic (more details in techies section below) using @AaveAave, @dydxprotocol to create a leveraged position.

4. Swaps the earned $COMP for more $DAI and re-invests in @compoundfinance.
5. It keeps a check if the @compoundfinance gives it more APY than what IronBank charges. If yes, then it checks if it is still profitable when it leverages its position on @compoundfinance and tries to find the maximum leverage that it can take while bieng profitable.
6. It repays the money which is left after calculating the optimum position from step 6.

There are a lot of edge-cases and details that I have left out to make the explanation simple, but these details make the strategy safe and capital efficient.
Techie Explanation:

The green labels represent the flow for the strategy's `adjustPosition()` where it adds funds to Compound.

The red labels represent the flow for the strategy's `adjustPosition()` (cases where we need to withdraw $DAI) where it withdraws funds from Compound.
There are a lot of edge-cases and conditions which make the strategy capital efficient, but this diagram is a dumbed-down version of the whole process.
Green Flow:

1. Vault deposits DAI to the strategy.

2. Check strategy's position with IronBank (can we borrow more, or does the IronBank wants its money back) and calculates an optimised position according to the IronBank lending rates and Compound lending rates.
3. Borrow DAI via Flashloan to lend to Compound. This is much more capital efficient and cheaper than doing multiple lending/borrowing cycles.

4. Lend DAI from Vault + DAI from FlashLoan to Compound.

5. Strategy borrows DAI from Compound to pay-off the Flashloan
6. Repay the Flashloan using the DAI borrowed from Compound

Red Flow:

1. Check strategy's position with IronBank (can we borrow more, or does the IronBank wants its money back) & calculates an optimized position according to the IronBank lending rates & Compound lending rates
2. Borrow DAI via Flashloan to repay the debt to Compound.

3. Repay debt to Compound using DAI borrowed from Flashloan.

4. Redeem DAI for cDAI from Compound.

5. Repay the Flashloan using the DAI redeemed from Compound.

6. Vault can withdraw DAI from the strategy.
There are also emergency exits in which case the strategy settles its debts with Compound and Ironbank before returning all the DAI back to the vault.

A similar procedure is followed when the strategy is migrated (version upgrades, etc.)
You can follow @vasa_develop.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.