YieldSpace: a market maker for fixed yield tokens
In this post, I lay out the motivation and the mechanics of the YieldSpace algorithm, as well as provide some examples. This is a high-level overview that omits some insights on pricing curve derivation and further optimizations from the original whitepaper.
While general-purpose AMM invariants work well for most of the trading pairs, there are some cases where having a specialized solution would dramatically improve capital efficiency, improving the experience for both traders and LPs. One such example is StableSwap, an algorithm initially introduced by Curve. Another less-known example is YieldSpace, which tackles efficient price discovery for yield tokens.
Yield tokens effectively represent a claim on the underlying asset in the future. Underlying assets are locked until the maturity date in the contract, and available to be redeemed with yield tokens at a 1:1 price. For example, buying yield tokens that will mature in 4 months with a 5% discount would yield ~15.8% annually. Certainly, there are some risks, but compared to most of DeFi, yield tokens are a relatively safe investment.
Fixed loans in DeFi were introduced relatively recently, and are yet to gain real adoption. However, from the TradFi perspective, fixed-rate loans are simpler and more commonly used by retail investors compared to dynamic-rate loans of money markets.
Why there’s a need to trade yield tokens? Borrowers that receive yield tokens usually want to increase their exposure to a collateral asset (e.g. ETH). In that case, they would need to exchange these tokens for collateral in the market. For example, a borrower might put ETH as collateral, mint yDAI yield tokens, exchange them to DAI using YieldSpace, and then change it to ETH via general-purpose AMM. While it’s possible to set up ETH/yDAI market, this would likely not be efficient.
For lenders, exchanging their underlying for yield tokens is effectively lending their tokens. Lenders can also exchange yield tokens back to underlying before maturing on the market, in case they need liquidity or if the lending rate was changed unfavorably.
All specific AMM invariants are based on some assumptions about trading pairs. For example, StableSwap assumes the price of the assets will not drift too much from each other. YieldSpace, in turn, assumes that asset prices will gradually converge. It makes sense since at maturity yield tokens can be redeemed for underlying at 1:1, so the tokens should be traded interchangeably.
It’s possible to use a general-purpose AMM to trade yield tokens. But again, this will be severely less capital efficient than using YieldSpace or a similar algorithm. Also, this creates unnecessary arbitrage opportunities: as the yield tokens move to maturity, their price should move toward the underlying asset, but in the absence of trades, generic AMM would give the same quote over time. In turn, YieldSpace provides the same interest rate provided there are no trades.
YieldSpace is a constant power sum AMM. Far from maturity, it resembles constant-product AMMs, allowing for high deviation from the underlying asset. As the maturity date gets closer, the pricing curve starts to flatten. At maturity, YieldSpace becomes a constant-sum AMM, allowing to exchange 1 yield token for 1 underlying token, and vice versa.
To incentivize providing liquidity to YieldSpace, it needs to generate some revenue from trading activity. Charging a flat percentage for each swap would be suboptimal: a high fee would disincentivize trading closer to maturity, while a low fee would result in a negligible amount of revenue. Ideally, we want to have relatively high fees far from maturity and a 0% fee on maturity. By adding additional parameter g into the invariant, we can effectively charge the fee on interest rate instead of swap volume.
Combining all the ideas outlined above, let’s go through a made-up example to see how YieldSpace pool quotes would change over time.
Suppose Alice initializes the pool with 100 DAI and 110 yDAI, with g = 0.95, t = 360 days, and yDAI is maturing in 180 days. Bob then swaps his 10 DAI into 10.4 yDAI, effectively lending his coins at 8.16% APR. After 90 days, Charlie exchanges his newly minted 20 yDAI into 19.5 DAI, effectively fixing his borrowing rate at 10.7% APR. Between these two trades, the “spot” interest rate stayed at 7.9%.
YieldSpace was introduced by Yield to provide liquidity for yield tokens (fyTokens). For each yield market, there’s a YieldSpace pool deployed to facilitate trading between fyTokens and their underlying assets. Yield V1 works only with DAI, with the plans to introduces more underlying assets in the next version of the protocol.
In June 2021, Element was launched on mainnet. Element’s core protocol allows anyone to unlock the liquidity of their yield-generating positions by splitting the underlying token into yield token and principal token. While principal token represents the fixed amount of underlying asset to be claimed 1:1 at maturity, yield token is a claim on the variable yield that would be generated through the whole period. To facilitate liquidity, Element uses 2 types of pricing curves. For yield tokens, a constant product AMM is used. For principal tokens, Element implemented YieldSpace as a custom Balancer pricing curve.
If we look at the trading volume for one of the principal token pool over time, we can see that most of the trading happened near the term end, as one could expect:
Note that trading fee approached ~0% as yield tokens matured:
YieldSpace is designed to trade yield tokens with fixed maturity. Its quotes are changing over time. Initially, it resembles constant-product AMM, but it flattens as yield tokens are about to mature. Yield Protocol is using YieldSpace to trade fixed loan tokens, while Element Protocol uses the AMM to trade yield principal tokens.
Thanks to Allan Niemerg for review.