Yup, this is basically what I’m thinking. I agree that it looks like the old proposal would result in cheaper gas for deposits, but the withdrawal flow is worse.
have a broker contract matching pending deposits and withdrawals and only deposit/withdraw the difference to the yVault
This is more or less what I’m referring to by a “broker” contract. I’m not sure what the wider community would think about using it to match pending deposits and withdrawals to skirt the withdrawal fee-- my guess is that it’d be frowned upon, though third-parties could design their broker contracts this way without us being able to stop them.
One note, depositing or withdrawing bigger or smaller amounts from the vault shouldn’t affect the gas cost (ie. should be similar gas to withdraw 100k ETH vs 200k ETH-- both are just treated as integer data types by the EVM and so cost the same to do computations with, IIUC).
You’re definitely right that a pooled withdrawal contract would make sense for users, but instead of calling after harvest to extract extra fees, it makes more sense to withdraw after large deposits. If there is idle capital in the yVault, users don’t pay the 0.5% withdrawal fee on the capital. If you make a pooled withdrawal contract, you can completely avoid paying the 0.5% withdrawal fee, as long as it only withdraws idle capital from the vaults.
If we model the withdrawal/deposit process as a random walk, most withdrawals never pay a withdrawal fee. I don’t think this is behaviour we want to encourage in the system, and I’m working on YIP that propose that the 0.5% withdrawal fee should be applied to all withdrawal transactions.
This of course still leaves room for a broker contract, but Uniswap already sort of functions this way, by letting you sell your yVault shares.