Charm

The easiest way to provide and manage liquidity

Liquidity on Charm

--

Photo by Vansh Juneja on Unsplash

Charm.fi is a decentralized options protocol that launched last week.

We’re adding a new feature to allow anyone to provide liquidity. Up until now, the treasury was the only LP.

This article goes into the technical details of how providing liquidity works in Charm’s AMM. The two key takeaways from this article are:

  1. Providing liquidity is risky and you can lose up to 100%. It should be treated more as a speculative bet rather than a way to earn a yield. You could realistically lose up to 100% of your deposit before the expiration date of the option.
  2. Depositing and withdrawing funds incurs slippage. If you attempt to deposit or withdraw a large amount, you might be overpaying.

If you believe prices won’t move a lot before expiry, an alternative and probably safer way of earning a yield is to sell calls or puts.

Charm works very differently from other options protocols. It uses the LMSR (Hanson’s market maker) to provide tokenized spreads that can be combined into various options. When a user buys an option from the AMM, they’re actually buying the tokenized spreads that make up the option.

Example of tokenized spread payoffs
Examples of how tokenized spreads can be combined into options

The LMSR is defined by the following cost function.

This cost function returns how much ETH the contract should be holding at any time (assuming we’re looking at ETH calls). q is a vector where qᵢ represents the open interest of the iᵗʰ tokenized spread —i.e. the quantity bought so far minus the quantity sold back. b is a parameter that will be discussed in more detail later.

As an example, let’s say a market has just been created with three tokenized spreads, so q = [0, 0, 0], and that b has been set to 10. If someone wants to buy 2 units of spread qₒ, the cost of this purchase in ETH can be calculated by seeing how much the cost function has increased:

The parameter b determines market depth. It’s typically set at the start when the market is created. If b is high, it means large trades can occur with lower slippage. If b is low, it means even small trades would incur high slippage.

So we want b to be higher, but the trade-off for increasing b is that more funds need to be deposited into the AMM.

For example, if we want to increase b from 10 to 15, the amount of ETH that needs to be added into the AMM is 5.478 ETH:

This is the basis of how liquidity provision in Charm works. When users deposit funds, b is increased which reduces slippage for future trades. When they withdraw funds, b is decreased.

If you wish to provide liquidity, there are a few quirks you should be aware of.

Liquidity is provided only for the duration of an option market, so you’ll need to withdraw after expiration. In the future, we’ll work on ways to automatically roll liquidity to new markets.

Slippage is incurred when LPs deposit or withdraw. This is different from Uniswap or other AMMs. The price of each LP share (the price to increase b by 1) increases as funds are deposited and decreased as funds are withdrawn. This means you’d incur a lot slippage if you try to deposit a large amount relative to the current pool size.

Why isn’t pool share determined by the amount of ETH deposited rather than by the increase in b? This would fix the slippage problem, but it would mean that the AMM is no longer path-invariant. There could potentially be an economic attack which instantly extracts funds from the contract, such as a sequence like deposit → buy → withdraw → sell.

After settlement, users can’t deposit any more and they have to withdraw their funds. The calculation for the withdrawal amount works in a different way from before expiry. The total pool value that can be claimed by LPs is calculated by taking the LMSR cost minus the total payoff owed to option holders. This guarantees all the balance in the contract will be split among option holders and LPs. Each LP will receive a cut of the pool value proportional to their LP shares held.

So when an LP withdraws before expiration, the amount redeemed is calculated from the difference in LMSR cost, plus a proportional amount of trading fees earned. After settlement, LP payoff is calculated from the balance left after option holders have been paid out.

A nice property is that assuming the market is efficient (i.e. that the tokenized spreads converge in price to their payoff at expiration), the LP payoff just before expiration will be equal to LP payoff after settlement . This prevents arbitrage opportunities just before expiration that could result in a rush of deposits (diluting LP payoff) or withdrawals (reducing market depth).

What does LP exposure look like? The plot below shows estimated LP payoff at expiry for different ETH prices. The market used has several strike prices ranging from 800 to 2240 and the price of ETH currently sits around 1400.

The payoff shape roughly resembles a deep in the money call option. This means it’s possible to hedge this exposure by selling the equivalent call (on Charm!).

It’s important to note that you can lose up to 100% of your deposit. This would happen if the price of ETH drops below 800 (the lowest strike price listed).

Why isn’t a constant-product market used instead of the LMSR? Constant-product markets seem simpler, they don’t suffer from LP slippage and an existing protocol like Balancer could be used.

The reason the LMSR was chosen was in the case of tokenized spreads, LP risk is significantly reduced. The plot below shows how constant-product LP payoff would change as ETH price changes.

There’s a trading fee of 1% of the underlying when traders open positions. 100% of these trading fees are split proportionally among LPs.

Since this system is experimental and risky for LPs, we’ve implemented a cap of around $100k on the total amount that can be deposited per contract. Please note this is separate from the TVL cap on each contract, which will be increased to allow more trading to take place freely.

If you have any questions, feel free to ask on Discord

--

--

Charm
Charm

Published in Charm

The easiest way to provide and manage liquidity

No responses yet