Can you short junk coins without a counterparty? DeFi is really getting more and more interesting
星球君的朋友们
2019-04-19 07:32
本文约3257字,阅读全文需要约13分钟
A shortable bonding curve model.

Editor's Note: This article comes fromorange book(ID: chengpishu), author:Sorawit SuriyakarnEditor's Note: This article comes from

orange book

(ID: chengpishu), author:The evolution of the DeFi world is fast. If you thought that DeFi was just a clumsy imitation of real-world finance, today's article may change your mind. It proposes an optimization scheme based on the bonding curve model, which can realize the short-selling function without a counterparty. I believe that the combination of machines and codes will gradually allow us to see another possibility, which was unimaginable in the traditional financial industry before. The iteration of finance will develop at another speed.Check.

on github

Check.

The bonding curve model allows the discovery of dynamic changes in Token prices and incentivizes early buyers through the increase in Token prices in the community. In a traditional bonding curve setup, when someone finds that tokens are undervalued, they can buy tokens on the bonding curve and sell them at a higher price. However, when the value of Token is overvalued, there is no direct way to release bearishness to the community and make a profit (similar to shorting in the regular market). In this article, we explore ways to solve this problem by improving smart contracts to support shorting functionality naturally.

secondary title1 What is the bonding curve modelIntroduction to the Bonding Curve Model: Simply understood, this is a smart contract. When you transfer funds (usually eth) into this contract, the smart contract will automatically generate a token. When you transfer the token into it, the smart contract will automatically redeem the token and reduce the total assets supporting the bond issuance. How is the price of the token determined? The token price is automatically calculated completely through the algorithm set in advance by the contract, and the price is applicable to all users."What is the Bonding Curve Model"

"Using the method of "pyramid marketing" to do charity:

Application of the Bonding Curve to Charitable Giving

secondary title

2 Short Introduction

What would you do in a traditional market if you were convinced that an asset was overpriced? Quite simply, you can short the asset with the hope of buying it back at a lower price in the future, making a profit. Essentially, you borrow and sell assets from an exchange or stockbroker, and they make sure you're always able to buy them back, or force liquidation.

2.2 Short selling in decentralized markets

Traditional markets require trusted organizations so that you can borrow or lend assets to third parties without fear of fraud. Such concerns do not exist in the blockchain world. Various protocols like dYdX, Dharma, etc. aim to provide decentralized margin lending services. Ocean Protocol has a series of technical guidelines, which can well apply these DeFi protocols to the bonding curve model with counterparties. But there are situations where counterparties exist, introducing unnecessary transaction fees and friction costs. What if you want to short an asset, but no one offers you a loan on that asset? This situation is very common for niche tokens that do not have much transaction volume and do not have much pledge lockup.

secondary title

3 Use the bonding curve model to get rid of the restriction of no counterparty

This article will focus on the idea of ​​adding shorting functionality directly to the bonding curve model. Three methods will be added in the smart contract: shortSell, closePosition and forceLiquidation. For demonstration purposes, let's imagine a fictional community with a COMM Token whose price is tied to ETH.

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

The equation of mortgage assets is: C(x) = 5x ^ 2 (where C(x) is the total mortgage assets and x is the total supply of tokens)

We assume that there is currently a total outstanding supply of 100 COMM and that the marginal price of 1 COMM is 1,000 ETH. The community has set a marginCall threshold of 80% (see section Liquidating Positions/Positions).

3.1 Use the bonding curve model to go short directly

Alice believes that COMM is overvalued and speculates that its price will fall. She sends a shortSell command for 15 COMM and 10,000 ETH as collateral. At this time, the smart contract adjusts the token supply to 85, and establishes a position of 15 COMMs for Alice, and the effective collateral is: 13,875 (the ETH received from selling 15 Tokens, the calculation method is: collateral c(100 )-c(85) = 5*100^2 - 5*85^2 = 13,875) + 10,000 (additional collateral) = 23,875 ETH.

3.2 Closing a position

Note that Alice could also choose to close her position if the supply moves up, but she will have less than 10,000 ETH to redeem. In this case, she will not profit.

3.3 Clearance

Suppose Alice refuses to close her position even when the supply exceeds 103.92. At that time, the cost of buying back 15 COMM will 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 collateral due to the drop in ETH value due to liquidation, the smart contract will force liquidation and return to Alice a total of 23,875 ETH minus the cost of buying back 15 COMM of ETH upon redemption.

https://github.com/bandprotocol/contracts/blob/c24c06ed70e61124ac5a898302b71b844ece63f0/contracts/bonding-curve/ShortableBondingCurve.sol

secondary title

4 Implementation Details

The source code of the smart contract of ShortableBondingCurve (bonding curve model that can be shorted) can be seen here:


Next, we will introduce some important technical implementation details and the theoretical basis behind them.

4.1 The concept of "current supply" in the bonding curve model

Traditional bonding curves only have the concept of a Token supply. However, in this shortable model, the concept of bonding curve supply is not directly equivalent to the actual total supply of tokens. Instead, the current effective supply of the bonding curve must be subtracted from the total amount of tokens shorted at this time.

4.2 Watch out for the worst possible liquidation scenario

In simple implementations, the supply point of the bonding curve can be used to determine the liquidation point.

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

To solve this problem, the supply point to determine the liquidation point should be the current supply plus all outstanding short tokens. In other words, in order to check that Alice's positions are sufficiently margined, the contract assumes that all but Alice's positions were liquidated before her.

4.3 Liquidation as an incentive game

In normal cryptocurrency trading, centralized management institutions such as exchanges need to ensure that all open positions have sufficient collateral, and are responsible for liquidating all positions that may lose the lender's funds. On-chain bonding curve contracts don't really have that privilege. Instead, we open the call to the forceLiquidation function, opening it up to the public. Anyone can respond to a liquidation event and get a fixed percentage of Token incentives, and take part of the liquidation fee of the liquidation position owner as a commission return for the responder. This is similar to MakerDAO's liquidation scheme.

Let’s conclude by discussing some of the potential attack vectors that people might expect, and our views and responses to them.

1. The attacker shorts the entire token supply: When this happens, no one in the community can sell their tokens because the supply drops straight to zero. At first glance this might be problematic. However, reducing the supply to zero makes buying new tokens very cheap. People who find tokens undervalued can buy tokens to change the supply relationship and price. So the attacker will lose money in this kind of attack.

2. The attacker pushes the bonding curve upwards and forces everyone to liquidate: This attack is already possible in traditional exchanges (see the 2017 Ethereum flash crash). To reduce risk, short sellers must provide more collateral to ensure their positions are not easily liquidated.

星球君的朋友们
作者文库