Proposal: bolt a CFAMM facility to the Y pool

This is a discussion thread for this proposal draft:

WIP and contribution/feedback welcome, but here’s the gist for now:


A public trade(input X, min_output Y) function is added to the Y facility. Anyone can call it to supply X amounts of one stablecoin and receive at least Y amount of another stablecoin. The quote provided is according to a stablecoin-optimized CFAMM curve. If the trade is successful, the Y pool is rebalanced if necessary. The effect on the pool yield-optimizing allocation is equivelant to having a batched transaction of deposite(X) && withdraw(Y).


  • Remove intermediaries between Y pool LPs and the trading fees they earn should they opt-in in the trading facility.
  • Reduce extra-Y-protocol governance risks
  • Y depositors who are also interested in trading fees should not have to absorb governance risk from this choice other than YFI governance risk.
  • The incentives are aligned between YFI governors who are not participating in the trading facility and Y depositors who are, because the funds accessable by CFAMM still earns yield in the same manner than Y funds opting out of the trading facility are.


  • Governance risk minimization: Y depositors should not absorb more governance risk than necessary. YFI governance suffices.
  • Better UI/UX: opting-in to the trading facility is just a check box, not a whole dedicated frontend which adds confusion.
  • Sustainability and incentive alignments: the fruits of network effects of the trading facilities is kept within the YFI ecosystem.

Can you eli5 this? I feel like a know a good bit about yfi and I hardly understood anything above. Not sure how regular yfi holders can vote on this that way.


I would definitely vote for if you could implement this.

1 Like

As a user of yEarn, when you deposit your stablecoin(s) to the Y pool, there is a checkbox that says “I also would like to contribute my stablecoins to the AMM”.

The Automatic Market Maker (AMM) is the same as Uniswap or Balancer, but its constant function (CF) is optimized for stablecoins to reduce slippage for traders. So it’s similar to how Curve AMM works.

As a trader (e.g. OTC desks), you sell some stablecoin to buy another against this pool for a fee. The stablecoin sold to the pool is wrapped into yTokens (e.g. USDC -> yUSDC) and the stablecoin bought is unwrapped from yToken into the base (e.g. yDai -> Dai) and given to the trader.

Trading fees from this AMM goes to you and others like you who checked the box. A small percentage of trading fees, say 5%, is paid to YFI holders to align incentives and potentially contribute to an insurance fund (e.g. against Tether risk). This is in addition to the typical yield you get from your funds being rotated as yTokens between e.g. Aave and Compound etc.

Compared to people who deposited their stablecoins to Curve protocol, yEarn despositors who check this box are not subject to risks from CRV governance nor do they owe rent to the Curve protocol. The fruits of this AMM stays within the YFI ecosystem.

@cp287: it’s better to gauge the YFI community’s interest in the idea before we put more effort into implementing it.


community, pls, more support for that!!! ) It is really awesome to have our own AMM!


I like the idea but I’m leaning against for the time being.
Vertically integrated AMMs would be great for yearn, and the rationale you cited is solid. But can we afford one at this point in time? It takes time and focus to create and manage an AMM, and it’s not central for yearn’s value proposition. Having our own AMM falls clearly in the “optimization” bucket and right now we’re still working on basic stuff.


Wait so make our own ycrv pool and cut out curve for some of the yycrv? Humm… I would vote yes for this.

1 Like

Thanks @realisation looking forward to reading your docs!

Proposal draft v2 … PLEASE VOTE BELOW :point_down::point_down::point_down::point_down:

Simple Summary

Y pool stablecoin depositors (LPs) can have an additional revenue stream in the form of trading fees from a rent-free governance-minimized stablecoin-to-stablecoin automatic market-making functionality. This is in addition to the yield they currently earn from having their stablecoins optimally rotated between Compound, Aave and DyDx. To align incentives between LPs and YFI holders: (1) trading fees are split 95% to LPs and 5% to YFI holders (2) upgrades to the trading functionality are opt-in.


In addition to earning yield from optimized lending, stablecoins in the Y pool could also earn trading fees from an automatic market making (AMM) functionality. This is like bolting a multi-asset Balancer pool to the yEarn. A trader supplies stablecoin A (e.g. Dai) to the Y pool and receives stablecoin B (e.g. USDC) in return. The A:B exchange rate is provided by stablecoin-optimized constant function. Traders pay a fee on each trade which goes 95% to Y pool depositors (LPs) and 5% to YFI holders.

Deposit workflow: LPs deposit stablecoins to the Y pool by visiting and clicking on a “deposit” tab as usual. But now there is also a checkbox that says “I also would like to contribute my stablecoins for market-making and earn trading fees”. LPs that check the box earn lucrative trading fees but are also exposed to the risk of all the stablecoins in the trading pool. Depositors who do not check the box miss out on these fees but they also do not have exposure to stablecoin risks other than the stablecoin they deposited.

Trade workflow: traders go to and click on “trade” tab, input the desired amount of stablecoin to sell and be presented with a quote for the stablecoin they want to buy. The stablecoin sold to the pool is wrapped into yTokens (e.g. USDC → yUSDC) and begins earning interest optimized yield immediately. The stablecoin bought is unwrapped from yToken into the base (e.g. yDai → Dai) and given to the trader.


  • Efficiency: remove intermediaries between Y pool LPs and the trading fees they earn should they opt-in to market-make.
  • Security: reduce extra-yEarn-protocol governance risks.
  • Sustainability: the fruits of network effects of the trading facilities is kept within the YFI ecosystem. This captures the value which is otherwise leaked outside the YFI ecosystem. This value comes from trading fees, liquidity network effects, and good governance.
  • Incentive alignment between YFI governors and Y pool’s LPs by (1) splitting trading fees 95% to LPs and 5% to YFI-holders and (2) enshrining upgrades as opt-in only. The 5% fee is fair compensation, not rent, fo YFI governors for maintaining the underlying yEarn machinery which LPs benefit from (interest rate optimization for now, other features and strategies added in the future).
  • Usability: better UI/UX for market-making because opting-in to the trading facility is just a checkbox, not a whole dedicated frontend which creates confusion.
  • Increase liquidity and network effects of the yEarn ecosystem.
  • Increase YFI’s moat against copy-paste clones. Clones can fork the AMM and the yield-optimizing strategies underneath it, but they can’t fork the AMM’s liquidity which results in extremely high slippage in their clone AMM.



The constant function of the automatic market making function is stablecoin-optimized in order to reduce slippage for traders. A similar function to that used in Curve or the upcoming Shell protocol can be used. A buffer of unwrapped stablecoins is kept to reduce gas costs for small depositors. The pool of AMM-participating Y depositors is the same as the current pool except for the additional publicly callable trade() function as well as backend utility functions that support it. The index token given to depositors represents a pro rata claim on of the total stablecoins in the pool. From a UI/UX perspective, LPs can withdraw to their desirable stablecoin. The withdrawal function performs the necessary swaps in the background to provide the withdrawer with the desired stablecoin. For example, suppose the pool is currently 25% Dai, 25% USDC, 25% USDT, and 25% TUSD. Suppose Alice has a 4% share of the pool, and she wants to withdraw her share into Dai only. The utility contracts unwraps (i.e. withdraws from lending protocols) 1% of yUSDC, 1% of yUSDT, and 1% yTUSD swaps each for Dai in the AMM itself. This represents 3% of Alice’s share, the remaining 1% is taken from the unwrapped from the yDai pool. The aggregate total of Dai’s which represent 4% share of the pool (under current exchange rates) is given to Alice.

The deployment admin key expires soon after deployment. Future upgrades of the AMM facility are opt-in, in a similar fashion to Uniswap → Uniswap v2 migration.


There are three principles: (1) modularity (2) minimalism (3) gas efficiency. The proposed approach above trades some of (3) in exchange for more (1) and (2). The inverse would have been to implement one global pool for both participating and non-participating LPs in market making. This makes the rebalancing more gas efficient Y-pool-wide. But then it’s less modular and more bloated because the pool needs to keep track of the trading fee distribution to participating LPs only. This means the current Y pool must be amended, which comes with its own risks.

The stablecoin-optimized function is designed to reduce slippage for traders. But it also assumes that some amount of de-pegging of one stablecoin should be arbitraged away by the market. The constant function becomes “concious” of a catastrophic de-pegging in a stablecoin only after a certain threshold, at which point the exponential nature of the pegged:depegged exchange rate protects the pool from further draining. This is a risk that LPs should know and understand about all stablecoin-constant functions generally.

The minimal change in UI/UX is to reduce confusion and mental overhead. Opting-in is a simple checkbox. Withdrawal abstracts away the swapping of underlying AMM shares of the withdrawer to the desired withdraw stablecoin(s). The withdraw workflow and UI/UX is exactly the same for both types of LPs: those participating in the AMM and those that are not. Note that both types of LPs earn optimized yield.


  • Overseeing this stablecoin market-making functionality is an added responsibility to the YFI governance.
  • As with any additional contracts that get added to yEarn, there is smart contract risks.
  • Stablecoin risks: a market-making LP is exposed to the risks of all the stablecoin being market made, not just the stablecoins they supplied.


The Y pool provides stablecoin-to-stablecoin automatic market-making functionality and collects trading fees. This functionality will be implemented and added to the Y pool.


The Y pool does not provide stablecoin-to-stablecoin automatic market-making of stablecoins.


  • Yes, provide the Y pool depositors the option to market-make stablecoins swapping natively and earn trading fees.
  • No, do not provide Y pool depositors with the option to market-make stablecoins swapping.
0 voters


Copyright and related rights waived via CC0.


This is amazing work, but unfortunately, I have to say I am against this.

From a technological perspective this introduces new risks to the vaults, that we should not discount.
From a maintenance perspective this introduces a new area of focus that we need to monitor and adds additional operational overhead.
From a business development perspective this requires new integrations with multiple vendors (1inch, matcha, paraswap, and more)
From an ideological perspective I feel this goes against composability.

And then on a personal note, yearn has made it till here, because it relied on its ecosystem partners for their work and support, Aave, Compound, Curve, 1inch, Zapper, Frontier, and more. While I understand that this could add value and additional revenues, I feel it goes against the ethos of defi and open finance. We could fork Aave, and we could fork Curve, and we would have sufficient liquidity to create those markets, but that isn’t what this movement is about. It’s about supporting each other and elevating those around us, not for our own personal well being, but for the space as a whole. I do understand that this is a naive view, but I feel it is important that I share it.

I think there is value in revisiting this strongly should decisions in sub protocols cause detriment to the sustainability and ethos of the project. But I would personally not be able to implement this due to my own morals and beliefs.

Now, as always, this is up to the community to decide, and happy to support the outcome, but needed to express my views.


this introduces new risks to the vaults

Yes, I highlighted that risk, which is stablecoins de-depegging. This risk is isolated to LPs participating in the AMM but they should indeed be aware of it (it’s the same risk anywhere else though in any protocol hosting these stablecoins).

we need to monitor and adds additional operational overhead.

Although I volunteered to bear the bulk of the work on this proposal I agree with you it will still take time and effort for the core devs just to review and appraise progress.

this requires new integrations with multiple vendors

This IMHO is not a big deal, it’s just a few lines of Javascript

From an ideological perspective I feel this goes against composability.

Im not sure I follow this one. The pool’s trade() function is public and can be composed into anything by anyone

and we could fork Curve

Curve has a much larger scope and will no doubt continue to thrive as a protocol and community. The two communities can and will maintain strong and friendly relations, but the YFI community should simply not absorb unnecessary risks or pay unnecessary rents. DeFi is about eliminating these (unfair inefficient rents) which plague TradeFi.


Agreed on Andre’s view.

1 Like

+1 agree with this and see it as consistent with the ethos of the project and space which Andre speaks of


Legendary! DeFi and Crypto more broadly is a big team fighting to innovate and push decentralization and finance further, there’s no need to always fight each other, we’re riding the same new and exciting era.


Amen!! Well said.

Dont think this is naive at all! This thinking is a competitive mote thats hard to compete against!

Ah the beauty of defi!! makes me wonder in awe! :slight_smile:


Couldn’t agree more with Andre! Thank you so much for your work. We all want a healthy DeFi ecosystem where Yearn plays a significant role. That won’t happen if other platforms see us a competition or as a a major threat to their projects.

1 Like

Swerve mostly satisfies the objectives of this proposal so I propose we archive it for now.


As per author above.