# \[Strategy\] yDai - Leveraged COMP farming - added yUSDC & yUNI

**URL:** <https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998>\
**Category:** Vaults\
**Created:** [15 October 2020 22:17 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998 "2020-10-15T22:17:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gspoosi](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/gspoosi/32/2117_2.png) [@gspoosi](https://gov.yearn.fi/u/gspoosi)\
**Post date:** [15 October 2020 22:17 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/1 "2020-10-15T22:17:19Z")

</div>

**Summary** :

> Use Dai in the yDai Vault to supply and borrow Dai on Compound and sell COMP for yield and to pay the fees. Instead of a simple supply and borrow we can maximise yield by leveraging both positions up to the collateral factor.

**Abstract** :

> The vault uses recursion (or flashloans or other means) to supply Compound with dai\_vault \* 1/(1-collatoral\_factor) and borrows dai\_vault \* (1/(1-collatoral\_factor)-1). The position should not be liquidatable because the collateral token and the borrowed token are the same and the ratio is fixed when setting up the position. A safety margin should be applied to the collateral factor, which would decrease yield slightly.

Example with current Compound rates:

> ```
> 100 Dai in Vault
> Collateral Factor for Dai is currently 75%
> 100 Dai * 1/0.25 -> 400 Dai supplied with 5.86% APY
> (2.82% supply rate + 3.04% COMP)
> 100 Dai * 1/0.25-1 -> 300 Dai borrowed with 0.10% APY 
> (-3.90% borrow rate + 4.00% COMP)
> -----------------
> 23.744% APY total
> 300 Dai borrowed is exactly 75% of the 400
> 
> ```

> With a safetly margin of 5% (using only a collateral ratio of 70%) we still get 19.7% APY.

**Motivation** :

> Get better yield than currently. This Strategy can also be used for yUSDC vaults (or others e.g yUNI) and for usage in the yETH vault. Once implemented we can use it in v2 Vaults as an alternative strategy for many vaults (basically any profitable token on Compound). Currently there are 1200 million Dai supplied in Compound and about 960 million Dai borrowed out. Imo some 100 million more or less should not impact rates too much - especially since both supply and borrow amout in compound raise in similar proportion.

**Specification** :

> Supply 1/(1-scf) #_token\_in\_vault_ to COMP and Borrow 1/(1-scf)-1 #_token\_in\_vault_ from COMP to farm COMP with leverage.  
> collateral\_factor (short _cf_) is defined by COMP per _token\_type_.  
> safe\_collateral\_factor (short _scf_) is defined by Yearn to ensure no liquidation takes place.  
> _scf = cf - safety\_margin_
> 
> For DAI & USDC:  
> _cf = 0.75_  
> _scf = 0.7_ (proposed - to be discussed)  
> For UNI:  
> _cf = 0.6_  
> _scf = 0.55_ (proposed - to be discussed)
> 
> There are multiple options to go into leveraged positions in COMP:
> 
> 1. Recursion
> 2. Flashloan
> 3. Pseudo-Flashloan
> 
> Recursion is illustrated in the diagram:
> 
> ![recursive_token (1)](https://europe1.discourse-cdn.com/flex013/uploads/yearn/original/2X/b/bd11949ce03d80f7ebf0ad6bd9e98e700cc6e477.png)  
> Flashloan utilizes Aaves flashloans for providing the target supply according to the formula without iterating. The borrowed assets are used to pay back the flashloan.
> 
> Pseudo-Flashloans could use other funds as collateral (e.g. YFI) to borrow the funds from a lending platform (probably Aave) to reach target supply without paying the fees for a regular flashloan. The debt could be payed back subsequently (even in the same transaction) with the borrowed asset.

**For** :

- Better yield than current vault
- Usable for other Vaults
- great addition to v2 Vaults as an additional strategy

**Against** :

- With large volume it might impact Compounds rates
- Need to track collateral ratio if Compound community decides to change ratio

**Poll** :

_Poll ([view on site](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/1))_

---

<div class="post-metadata">

**Author:** ![hen](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/hen/32/1426_2.png) [@hen](https://gov.yearn.fi/u/hen)\
**Post date:** [15 October 2020 23:33 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/2 "2020-10-15T23:33:09Z")

</div>

if you open the position exactly at the liquidation ratio, won’t it be vulnerable the second it starts accruing interest, since the borrow rate is higher than the supply rate?

---

<div class="post-metadata">

**Author:** ![franklin](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@franklin](https://gov.yearn.fi/u/franklin)\
**Post date:** [16 October 2020 02:58 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/3 "2020-10-16T02:58:44Z")

</div>

How does 400 DAI with a 5.86% APY and 300 DAI with 0.10% APY equal a total of 23.74% APY specified in your example?

---

<div class="post-metadata">

**Author:** ![gspoosi](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/gspoosi/32/2117_2.png) [@gspoosi](https://gov.yearn.fi/u/gspoosi)\
**Post date:** [16 October 2020 05:38 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/4 "2020-10-16T05:38:43Z")

</div>

> [@franklin](#):
>
> How does 400 DAI with a 5.86% APY and 300 DAI with 0.10% APY equal a total of 23.74% APY specified in your example?

Initial investment is 100 Dai - you get 400 Dai with 5,86% and 300 Dai with 0.10% from it.

---

<div class="post-metadata">

**Author:** ![gspoosi](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/gspoosi/32/2117_2.png) [@gspoosi](https://gov.yearn.fi/u/gspoosi)\
**Post date:** [16 October 2020 05:41 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/5 "2020-10-16T05:41:53Z")

</div>

Absolutely! There probably needs to be a safety margin! There is a safety margin in Compound of 5% additional to the collateral ratio, but I’m not sure it would apply in this case.

```
safe_collateral_factor = collateral_factor - safety_margin

```

I added a sentence about a safety margin. With a safetly margin of 5% we still get 19.7% APY.

---

<div class="post-metadata">

**Author:** ![dormeur23](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@dormeur23](https://gov.yearn.fi/u/dormeur23)\
**Post date:** [16 October 2020 06:25 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/6 "2020-10-16T06:25:43Z")

</div>

The APY will be reduced with the volume we would provide, not sure you will be able to leverage yourself that much.

Though, given V2 vault will allow up to 20 strategies, it sounds reasonable to have this one running with limited funds.

---

<div class="post-metadata">

**Author:** ![mattdw](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/mattdw/32/1799_2.png) [@mattdw](https://gov.yearn.fi/u/mattdw)\
**Post date:** [16 October 2020 06:30 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/7 "2020-10-16T06:30:28Z")

</div>

I’m currently working on a strategy extremely similar to this with @macarse right now. The relevant forum post is attached.

We decided to start building on Compound instead of Aave at the moment due to the added yield from COMP - but the core concept is nearly identical.

> Note: this is all out of date. Apologies. Please ignore!  
> One important note: **You cannot supply and borrow the same asset on Compound**. If you supplied DAI you couldn’t borrow it - so this won’t work as written. You’d need to take out a different stablecoin for the leveraging. This introduces liquidation risk to the vault in the _unlikely_ scenario that DAI falls in value compared to the other stablecoin, e.g. USDC.

> [@Update the yDAI vault strategy to utilize Aave](http://gov.yearn.fi/t/update-the-ydai-vault-strategy-to-utilize-aave/6214/5):
>
> Oh, absolutely. I agree 100%. This strategy would by its nature have lower returns, as we’d only be able to deploy a fraction of the deposited collateral into working capital. When starting this strategy my main concern was how to allow end users to be certain their DAI would be secure in case of DAI losing its peg; returns were a secondary consideration. One just needs to look at the fraction of DAI in the yCRV pool to see how much more in demand this token is. In a worst case scenario, DAI…

Edit: it is possible to supply/borrow the same asset on Compound. I was wrong. Womp womp.

---

<div class="post-metadata">

**Author:** ![gspoosi](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/gspoosi/32/2117_2.png) [@gspoosi](https://gov.yearn.fi/u/gspoosi)\
**Post date:** [16 October 2020 06:53 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/8 "2020-10-16T06:53:17Z")

</div>

It was possible before if you interacted with the smartcontract before - did they fix this?  
Personally I borrowed tether and deposited usdc/dai (depending on the rates) switched via SWERVE/CURVE.

Are you absolutely sure its not possible anymore? Because the risk is much higher if you use different stablecoins…

---

<div class="post-metadata">

**Author:** ![mattdw](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/mattdw/32/1799_2.png) [@mattdw](https://gov.yearn.fi/u/mattdw)\
**Post date:** [16 October 2020 07:40 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/9 "2020-10-16T07:40:24Z")

</div>

Nope, I was wrong. It looks like you can now! Will edit my previous post.

---

<div class="post-metadata">

**Author:** ![JLS](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/jls/32/1010_2.png) [@JLS](https://gov.yearn.fi/u/JLS)\
**Post date:** [16 October 2020 10:38 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/10 "2020-10-16T10:38:04Z")

</div>

You can use Instadapp as a second layer to be able to supply the borrowed asset again into comp.

---

<div class="post-metadata">

**Author:** ![franklin](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@franklin](https://gov.yearn.fi/u/franklin)\
**Post date:** [16 October 2020 13:40 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/12 "2020-10-16T13:40:43Z")

</div>

I guess this is where I am still confused. How does 100 DAI get you 400 DAI.

How does 5.86% + 0.10% = 23.74% APY.

Can you break it down step by step?

---

<div class="post-metadata">

**Author:** ![gspoosi](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/gspoosi/32/2117_2.png) [@gspoosi](https://gov.yearn.fi/u/gspoosi)\
**Post date:** [16 October 2020 17:16 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/14 "2020-10-16T17:16:37Z")

</div>

> [@SamPriestley](#):
>
> I have a smart contract that does this with my own funds. Have been using it for a few months now. I could probably adapt it for use as a yearn strategy if you’re interested.
> 
> Very simply it flash loans into the position leveraging up to 99% of allowed collateral level.
> 
> Then to harvest it borrows 1 dai. Lends 1 dai. This triggers the comp airdrop. Sells the comp on uniswap for dai and leverages up again.

Can you elaborate on the comp airdrop trigger? Is it not a function of time?  
I won’t be the one implementing it - but I guess sharing is caring 🙂 and I’m curious about your contract.

---

<div class="post-metadata">

**Author:** ![dormeur23](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@dormeur23](https://gov.yearn.fi/u/dormeur23)\
**Post date:** [16 October 2020 22:58 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/16 "2020-10-16T22:58:40Z")

</div>

@gspoosi Why don’t you send those wrapped coins into the compound curve pool on top of your leverage?  
The CRV distribution is currently appealing

---

<div class="post-metadata">

**Author:** ![ramaruro](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@ramaruro](https://gov.yearn.fi/u/ramaruro)\
**Post date:** [17 October 2020 05:47 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/17 "2020-10-17T05:47:56Z")

</div>

Pickle already implemented this strategy…

> <https://twitter.com/picklefinance/status/1317303571960922112?s=20>

---

<div class="post-metadata">

**Author:** ![gspoosi](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/gspoosi/32/2117_2.png) [@gspoosi](https://gov.yearn.fi/u/gspoosi)\
**Post date:** [17 October 2020 07:40 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/18 "2020-10-17T07:40:16Z")

</div>

> [@ramaruro](#):
>
> Pickle already implemented this strategy…
> 
> [twitter.com](https://twitter.com/picklefinance/status/1317303571960922112?s=20)
> 
> ![](https://europe1.discourse-cdn.com/flex013/uploads/yearn/original/2X/4/43f0e6c938a3004cc5bce3e3e54099fa673e92fc.jpeg)
> 
> #### [Pickle Finance 🥒 (bluepickle.eth) (picklefinance)](https://twitter.com/picklefinance/status/1317303571960922112?s=20)
> 
> 🚨🚨🚨NEW PICKLEJAR INCOMING​:rotating\_light:🚨🚨 PickleJar 0.88 uses a leveraged $COMP (@compoundfinance) mining strategy on your $DAI deposits. Learn more here: [https://medium.com/@picklefinance/a35182cb0905](https://t.co/9iIoggCbMo) [https://twitter.com/picklefinance/status/1317303571960922112/video/1](https://t.co/gQA1OGvmMb)
> 
> [20:17 - 16 okt. 2020](https://twitter.com/picklefinance/status/1317303571960922112?s=20) 81 19

So we just too slow on the strategy front - imo we should still use it, since yearn is not anon…

---

<div class="post-metadata">

**Author:** ![cavernec](https://avatars.discourse-cdn.com/v4/letter/c/c0e974/32.png) [@cavernec](https://gov.yearn.fi/u/cavernec)\
**Post date:** [17 October 2020 11:50 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/21 "2020-10-17T11:50:18Z")

</div>

This thread would probably help : [Request for "Knowledge Base" howto - learning steps for becoming a strategy writer](http://gov.yearn.fi/t/request-for-knowledge-base-howto-learning-steps-for-becoming-a-strategy-writer/7007/3)

---

<div class="post-metadata">

**Author:** ![milesr](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@milesr](https://gov.yearn.fi/u/milesr)\
**Post date:** [17 October 2020 12:17 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/22 "2020-10-17T12:17:56Z")

</div>

Even if Pickle already released this strategy, I still think most people would rather deposit their funds on yearn. Single assets strategies are very much needed in our products range and COMP is a great starting point.

---

<div class="post-metadata">

**Author:** ![cavernec](https://avatars.discourse-cdn.com/v4/letter/c/c0e974/32.png) [@cavernec](https://gov.yearn.fi/u/cavernec)\
**Post date:** [17 October 2020 12:37 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/23 "2020-10-17T12:37:45Z")

</div>

> Even if Pickle already released this strategy, I still think most people would rather deposit their funds on yearn

Totally agreed

---

<div class="post-metadata">

**Author:** ![ramaruro](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@ramaruro](https://gov.yearn.fi/u/ramaruro)\
**Post date:** [17 October 2020 16:23 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/24 "2020-10-17T16:23:54Z")

</div>

I agree yearn should have it too. I highlighted that Pickle already has it and lately has been faster in implementing new vaults (they call them jars)

---

<div class="post-metadata">

**Author:** ![YieldBouncer](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/yieldbouncer/32/62_2.png) [@YieldBouncer](https://gov.yearn.fi/u/YieldBouncer)\
**Post date:** [17 October 2020 18:33 UTC](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998/25 "2020-10-17T18:33:26Z")

</div>

Can’t we just farm pickle jar instead? Earn pickle PLUS comp.

[Next page](https://gov.yearn.fi/t/strategy-ydai-leveraged-comp-farming-added-yusdc-yuni/6998.md?page=2)
