Can I empty the trash without a counterparty? DeFi is really getting more and more interesting

The evolution of the DeFi world is fast. If you think that DeFi is just a clumsy imitation of the real world of finance, then this article may change your mind today. It proposes an optimization scheme based on the joint curve model, which can realize the short function without counterparty. I believe that the combination of machine and code will slowly let us see another possibility, which was unimaginable in the traditional financial industry. The iteration of finance will continue at another speed.

The length of the article is longer. If you don't want to discuss it in depth or have limited time, you can look at the following summary (TLDR): We propose a method to optimize the joint curve so that the joint curve model can be used directly without the presence of a counterparty. Trusted, fully mortgaged short.

This smart contract for the short joint curve model can be obtained here:

The joint curve model mechanism allows for the discovery of dynamic changes in Token prices and motivates early buyers through rising community Token prices. In the traditional joint curve setup, when someone finds that Token's value is underestimated, they can buy Token on the joint curve and then sell it at a higher price. However, when the value of the Token is overvalued, there is no direct way to free the community and make a profit (similar to shorting in the regular market). In this article, we will explore ways to solve this problem by improving the smart contract to naturally support the short function.

What is a joint curve model?

Introduction to the Joint Curve Model: Simply understand that this is a smart contract. When you transfer funds into this contract (usually eth), the smart contract will automatically generate a token. When you transfer into the token, the smart contract will automatically redeem the token and reduce the total assets that support the bond issue. What is the price of the token? The token price is automatically calculated entirely by the algorithm set by the contract in advance, and the price is applicable to all users.

A more detailed introduction can be found in these two articles:

  • What is a joint curve model?
  • Doing charity with the method of "MLM": the application of the joint curve in charitable donations

Short introduction

Short selling in traditional markets

In the traditional market, if you are convinced that the price of an asset is too high, what would you do? Quite simply, you can short the asset and hope to repurchase it at a lower price in the future to make a profit. Essentially, you borrow and sell assets from exchanges or stockbrokers, and they make sure that you can always buy back assets or force a clearance.

Decentralized market short

Traditional markets require trustworthy organizations so that you can borrow or lend assets to third parties without fear of fraud. This concern does not exist in the blockchain world. Various agreements such as dYdX and Dharma are designed to provide decentralized margin lending services. The Ocean Protocol has a series of technical guidelines that can be used to apply these DeFi protocols to a joint curve model that exists in a counterparty. But with the existence of a counterparty, unnecessary transaction costs and friction costs are introduced. What if you want to short an asset but no one offers it to lend you? This is very common for niche Tokens that do not have too much trading volume and do not have too many pledge locks.

Use the joint curve model to get rid of the restrictions without counterparties

This article will focus on the idea of ​​adding a short function directly to a joint curve model. Three methods will be added to the smart contract: shortSell, closePosition, and forceLiquidation. To demonstrate the effect of the demo, let's imagine a fictional community with a COMM Token whose price is tied to ETH.

The price equation for the COMM token is as follows: P(x) = 10x (P(x) is the price of the token, and x is the total supply of the token)

The equation for the mortgaged asset is: C(x) = 5x ^ 2 (C(x) is the total mortgage asset, x is the total supply of token)

We assume that there is currently an unpaid total supply of 100 COMMs, and the marginal price of 1 COMM is 1,000 ETH. The community has set the marginCall threshold to 80% (see Clearing Position/Positions section).

Direct shorting using the joint curve model

Alice believes that the COMM price is overvalued and speculates that its price will fall. She sent a shortSell command for 15 COMM and 10,000 ETH as a collateral. At this point, the smart contract adjusted the Token supply to 85 and established 15 COMM positions for Alice. The effective collateral was: 13,875 (ETH received from the sale of 15 Tokens, calculated as: collateral c (100 )-c(85) = 5100^2 – 585^2 = 13,875) + 10,000 (extra collateral) = 23,875 ETH.

Close the position

After a while, the community’s interest did drop, and others sold 30 community tokens during this period. The community Token supply is therefore reduced to 55. At this point, Alice calls closePosition to buy back the short Token and get: 23,875 – 9,375 = 14,500 ETH. This is equivalent to a net profit of 4,500 ETH!

Please note that if the supply moves up, Alice can also choose to close the position, but she will redeem the ETH less than 10,000 ETH. In this case, she will not make a profit.


Assume that even if the supply exceeds 103.92, Alice refuses to close the position. At that time, the cost of repurchasing 15 COMM would be C (118.92) – C (103.92) ≈ 16713, which is greater than 70% of Alice's total collateral. In order to prevent the community from losing the risk of collateral due to the fall in ETH value due to clearance, the smart contract will force the clearance and return to Alice a total of 23,875 ETH at the redemption minus the cost of purchasing ETH for 15 COMM.

Implementation details

The smart contract of ShortableBondingCurve (the short joint curve model can be shorted), the source code can be seen here . In this section, we will introduce some important technical implementation details and the theoretical basis behind them.

The concept of "current supply" in the joint curve model

The traditional joint curve has only one concept of Token supply. However, in this shortable model, the concept of joint curve supply is not directly equivalent to the actual total supply of Token. Instead, the currently valid joint curve supply must subtract the total amount of Tokens that are shorted at this time.

Pay attention to the worst possible liquidation situation

In a simple implementation, the supply point of the joint curve can be used to determine the clearing point.

If there is only one short order at a time, this is not a problem. However, in the case of multiple positions, multiple liquidation events may result in insufficient collateral to cover all losses.

To resolve this issue, determine that the supply point for the clearing point should be the current supply plus all outstanding short tokens. In other words, in order to check if Alice's position has sufficient margin, the contract assumes that all positions except Alice are liquidated before her.

Liquidation as an incentive game

In ordinary cryptocurrency transactions, centralized management agencies such as exchanges need to ensure that all open positions have sufficient collateral and are responsible for liquidating all positions that may lose lender funds. The joint curve contract on the chain does not really have this privilege. Instead, we open the call to the forceLiquidation function and open it to the public. Anyone can respond to the liquidation event and obtain a fixed percentage of Token incentives, taking a portion of the clearing fee of the clearing position owner as a responder's commission refund. This is similar to the clearing scheme of MakerDAO.

Possible attack methods and solutions

Finally, let's discuss some of the potential attacks in anticipation and our views and responses to these attacks.

  • The attacker shorts the entire Token supply: When this happens, no one in the community can sell their Token because the supply drops directly to zero. At first glance this may be a problem. However, reducing the supply to zero will make buying a new token very cheap. People who find that Token values ​​are undervalued can buy Tokens to change supply relationships and prices. So the attacker will settle in this attack.
  • The attacker pushed the joint curve up to force everyone to clear the position: this type of attack has become possible in traditional exchanges (see 2017 Ethereum lightning crash). In order to reduce risk, short sellers must provide more collateral to ensure that their positions are not easily liquidated.

in conclusion

In this article, we explore an implementation idea that allows for a short token in a joint curve model. The design does not require a counterparty and can be combined into any joint curve model to accelerate price discovery. We also proposed a smart contract to show its feasibility. Having said that, this is still a work in progress and we appreciate any feedback or comments. Please contact us at!




Author: Sorawit Suriyakarn

Translation: Wayne