xy=k bonds: Autonomous market operations primitive

Nour Haridy
5 min readMar 7, 2022

Special thanks to Captain Isaac A. from Station0x for the discussions and thoughts that went into this piece

Earlier, I tweeted my opinion that Olympus bonds were the most disruptive DeFi innovation in 2021.

Bonds allow DeFi protocols to spend their native token emissions on fundraising and permanently acquiring tokens that add value to the protocol, rather than temporarily renting them from mercenary farmers using liquidity mining rewards.

This fundraising tool is especially powerful for securing trading liquidity for the protocol’s native tokens. Many protocols are spending over 100%+ APY to their pool2 farmers due to a high impermanent loss risk. To put this into perspective, from a protocol’s POV, this is equivalent to renting property at a higher cost per year than the cost of purchasing it forever. Bonds offer protocols the opportunity to buy their property and keep it forever rather than pay unsustainable rent forever.

Before Olympus offered their Bonds-as-a-Service product, Olympus Pro, to other protocols, Inverse DAO was one of many protocols paying unsustainable rewards to their liquidity providers. Today, Inverse DAO is a user of Olympus Pro bonds in an attempt to slowly shift all emissions spending from unsustainable rewards to permanent liquidity purchases.

This close collaboration between Inverse DAO and Olympus gave me an opportunity to dive deeper into how bonds work, their limitations and how they can be improved.

Limitations of Olympus-style bonds

Unpredictable emissions

It’s hard to predict or set an exact rate of monthly token emissions using bonds. This is because the rate of bond purchases is dependent on what discount market participants are willing to accept at any given moment. This can vary based on changes in market sentiment around the reward token (e.g. OHM).

If the market suddenly becomes more bearish, bond purchasers will wait for bonds to offer higher discounts, slowing down emissions. If the market is bullish, they’ll accept lower discounts, accelerating emissions.

Lack of autonomy

In order to keep the emission rate near a determined target, bond operators must continuously adjust a parameter called Bond Control Variable. BCV specifies the rate at which the bond discount increases per second.

This adds reliance on and trust to a bond operator role to keep spending near a promised target. More importantly, this limitation prevents the ability to deploy autonomous and/or long-term bond contracts, unlike staking rewards programs which can continue to run autonomously for years.

Discount frontrunning

Purchasers of many protocol bonds including Olympus, Alchemix and Inverse DAO are often targets of bond frontrunning bots. These bots use purchasers’ pending bond purchase transactions in the mempool as an oracle for when to deem a discount as acceptable.

Once a bot frontruns a bond purchaser, the bond discount significantly decreases and original bond purchaser’s transaction fails. The purchaser then must wait for the discount to increase again according to the BCV and hope that no one will snipe it first next time. Bots gain a disproportionate advantage in sniping the best discount rate, often locking out other participants.

Purchase limits

Bond purchasers are capped to a maximum amount of reward token per purchase. This limits the protocol’s exposure to potentially unfavorable discount rates at any give time.

However, this forces large bond purchasers to split up their purchases over multiple transactions over a long duration, resulting in higher gas costs. Participants price this cost in the minimum discount they’re willing to accept per purchase, resulting in lower total bond revenue for the protocol.

xy=k bonds

In an attempt to address the limitations of Olympus-style bonds, I’m proposing a new bond design inspired by Uniswap’s xy=k constant product bonding curve formula.

Uniswap’s formula is defined as:

x × y = K

where

  • x and y are supplied reserves of 2 tokens in a pair
  • K is a constant product of x and y.

When a trader executes a swap, their tokens are added to one of the 2 reserves, say x. Because K must remain both constant and the product of x and y, the trader receives an amount from y reserves:

amountOut = y - K / (x + amountIn)

In order to adapt this formula to bond sales, we can make a slight change:

x × (rt - s) = K

where

  • x is the total income of the purchase token (e.g. Dai)
  • r is the payout token emission rate per second (e.g. OHM)
  • t is seconds since last r adjustment
  • s is total amount of payout tokens sold since last r adjustment

In order to calculate the bond payout token amount, we use the formula:

amountOut = rt - s - (x(rt - s) / (x + amountIn))

The y reserve variable is replaced with the time-linear function (rt - s) on both sides of the equation.

This design is equivalent to a xy=k pool that continuously adds single-sided liquidity only to the y side of reserves at a fixed rate every second. However, in this pool, adding liquidity is restricted only to the protocol (by adjusting the r variable) and traders can only swap the purchase token to the payout token and not the other way around. After each trade, the payout token amount sent to the trader can be vested with linear unlock, same as Olympus-style bonds.

Since the purchase token cannot be bought back from the pool by traders, it can be transferred directly to the protocol treasury on each swap, or burned in the case of a buyback, after updating the x variable.

Similar to an Olympus-style bonds, this design results in decreasing the price of the payout token over time. The payout token price increases after each trade then continues to decrease based on the r variable.

However, in this design, bond sales can run autonomously without adjustment for any duration of time while preserving a constant payout token emission rate, without requiring individual trade limits and while reducing the impact of bond frontrunning on traders.

Use cases

The most obvious use case for this design is treasury diversification bonds/continuous sales e.g. for Olympus and Inverse DAO among others.

Another use case is Inverse Bonds (aka buyback bonds) where a protocol can set a monthly rate of its protocol revenue to be spent on the maximum possible amount of buybacks of its native tokens without risks of trade frontrunning or requiring a central operator to execute buybacks.

This design can also be expanded to serve any form of protocol-controlled autonomous market operations.

For example, we can create other variants of this design that allow the creation of algorithmic synthetic assets using a combination of bonds and inverse bonds that dynamically adjust their r variables in order to correct the peg. This will be explored in more details in another article.

In the meantime, this design is being implemented within 2 products that I’m involved with that are launching soon: Station0x ore refinery contract and a Fantom AMM that owns its liquidity. If you’re part of a project that intends to implement this design, please feel free to DM me on Twitter.

--

--