# Ambiguity in charging of withdrawal fees in yVault contracts

**URL:** <https://gov.yearn.fi/t/ambiguity-in-charging-of-withdrawal-fees-in-yvault-contracts/2919>\
**Category:** General Chat\
**Created:** [20 August 2020 05:00 UTC](https://gov.yearn.fi/t/ambiguity-in-charging-of-withdrawal-fees-in-yvault-contracts/2919 "2020-08-20T05:00:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![williamHex](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@williamHex](https://gov.yearn.fi/u/williamHex)\
**Post date:** [20 August 2020 05:00 UTC](https://gov.yearn.fi/t/ambiguity-in-charging-of-withdrawal-fees-in-yvault-contracts/2919/1 "2020-08-20T05:00:05Z")

</div>

I’ve been trying to understand the yearn.finance ecosystem and ran into a confusing scenario on why withdrawal fees are handled this way.

The contract I’m reviewing is yVault, specifically the `withdraw()` function on line 339:

> **[yearn: yCRV Vault | Address 0x5dbcf33d8c2e976c6b560249878e6f1491bca25c |...](https://etherscan.io/address/0x5dbcf33d8c2e976c6b560249878e6f1491bca25c#code)**
>
> The Contract Address 0x5dbcf33d8c2e976c6b560249878e6f1491bca25c page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on...

Withdrawal fees are only charged when `b < r` is `true`, where `b` is the balance of the vault, and `r` is the total balance in the system (strategy contract + liquidity pools, etc.) for this strategy.

In other words, strategies that utilize external pools (such as how the yCRV strategy holds most of the assets in curve to generate yield) **will not** pay withdrawal fees since `b < r` under most normal operating conditions. Strategies that don’t hold much assets externally (such as the yDai strategy) will have a majority of its assets in its vault, and thus `b > r` mostly, and users **will** incur withdrawal fees.

**Example transactions:**  
A transaction withdrawing yCRV from the yCRV yVault does not incur withdrawal fees: `0x3e502ae3619c7302912afa66e438a355ed5f14703f1a27f67e1f6c4da0f8f639`

A transaction withdrawing yDai from the yDai yVault does incur withdrawal fees: `0x15dfa2e1e9714153e01f3d05ca14446742690ce735e1bb9eedc4f48003144142`

If anyone can shed some light on why withdrawal fees are handled this way, please do!

---

<div class="post-metadata">

**Author:** ![Dark](https://dub1.discourse-cdn.com/flex013/user_avatar/gov.yearn.fi/dark/32/307_2.png) [@Dark](https://gov.yearn.fi/u/Dark)\
**Post date:** [20 August 2020 06:03 UTC](https://gov.yearn.fi/t/ambiguity-in-charging-of-withdrawal-fees-in-yvault-contracts/2919/2 "2020-08-20T06:03:28Z")

</div>

From a telegram chat “@andrecronje any idea why the withdrawal has been hit or miss?”

“So there is a deposit buffer, when you hit this buffer, no fee, this buffer is roughly 5% of the system, if it increases above 5% the system deposits the diff of buffer less 5%, so it tries to keep the balance between available buffer and maximized earnings. So as you deposit and the buffer increases above 5% it sends it to the underlying strategy, when you withdraw from the underlying strategy, you pay 5% on the strategy withdraw amount, not the withdraw amount. Since you are working with sub $5k, it often falls within this buffer, but it is highly dependent on deposits at the time. So if a big deposit came in before your tx (which triggers strategy deposit), then your next withdrawal will hit 5%, if the deposits did not exceed it, you will withdraw from the buffer instead. Its designed so that smaller investors don’t take the fee hit”

---

<div class="post-metadata">

**Author:** ![milkyklim](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@milkyklim](https://gov.yearn.fi/u/milkyklim)\
**Post date:** [1 September 2020 10:54 UTC](https://gov.yearn.fi/t/ambiguity-in-charging-of-withdrawal-fees-in-yvault-contracts/2919/3 "2020-09-01T10:54:13Z")

</div>

Closed since inactive. Feel free to reopen if this topic is still relevant.
