Skip to content

Commit

Permalink
feat: allowed empty amm levels
Browse files Browse the repository at this point in the history
  • Loading branch information
cdummett committed Sep 10, 2024
1 parent ad45701 commit 705a118
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions protocol/0001-MKTF-market_framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Data:
- **Tick size**: the minimum change in quote price for the market. Order prices and offsets for pegged orders must be given as an exact multiple of the tick size. For example if the tick size is 0.02 USD. then a price of 100.02 USD is acceptable and a price of 100.03 USD is not. The tick size of a market can be updated through governance. Note, the tick size should be specified in terms of the market decimals, e.g. for a scaled tick size of `0.02` (USDT) in a market using `5` decimal places, the tick size would be set to `2000`.
- **Liquidation strategy**: A field specifying the liquidation strategy for the market. Please refer to [0012-POSR-position_resolution](./0012-POSR-position_resolution.md#managing-networks-position) for supported strategies.
- **Transaction Prioritisation**: A boolean, whether to enable [transaction prioritisation](./0092-TRTO-trading_transaction_ordering.md).
- **Empty AMM Price Levels**: An integer greater than or equal to zero which defines the maximum number of price levels permitted in an AMM range which would quote zero volume. This value should default to 100.

Note: it is agreed that initially the integer representation of the full precision of both order and positions can be required to fit into an int64, so this means that the largest position/order size possible reduces by a factor of ten for every extra decimal place used. This also means that, for instance, it would not be possible to create a `BTCUSD` market that allows order/position sizes equivalent to 1 sat.

Expand Down
25 changes: 25 additions & 0 deletions protocol/0090-VAMM-automated_market_maker.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,31 @@ Note, there is no need to handle the complexity where the fair price is currentl
- if the fair price is currently on the lower curve, the best-ask will also be on the lower curve
- if the fair price is currently on the upper curve, the best-bid will also be on the upper curve

## Curve validity

To prevent the protocol evaluating AMMs providing little liquidity to the network, the network will reject AMM submissions or amendments which cause an AMMs liquidity to be spread too thinly across it's entire range.

If the number of ticks in the largest price range in which the AMM quotes zero volume is more than the parameter $allowedEmptyAmmLevels$, then the submission or amendment will be rejected. Note this parameter is defined on each market to allow different markets with varying volatility to be configured appropriately.

- for the lower curve, this range is between the fair price at which the AMMs long position is $P=1$ and the base price.
- for the upper curve, this range is between the fair price at which the AMMs short position is $(P_v-1)$ and the upper price bound.

The above definitions yield the following inequality which must be satisfied for both the upper and lower curve (providing they are defined) for the AMM to be valid.

$$
n\cdot\Delta{p} \geq \frac{L\cdot\sqrt{p_u}}{L + \Delta{P}\cdot \sqrt{p_u}}
$$

Where:

- $\Delta{p}$ is the smallest price movement supported by the market's price decimals and tick size
- $\Delta{P}$ is the smallest position size supported by the market's position decimals
- $n$ is the market parameter $allowedEmptyAmmLevels$
- $L$ is the liquidity score for the relevant curve
- $p_u$ is the upper price (the base price for the lower curve and the upper bound for the upper curve)

Note, if the market parameter $allowedEmptyAmmLevels$ is updated via governance all existing pools that would no longer satisfy the inequality **must not** be cancelled. Amends to these pools should be evaluated and rejected if necessary and any cancellations should be accepted.

## Determining Liquidity Contribution

The provided liquidity from an AMM commitment must be determined for two reasons. Firstly to decide instantaneous distribution of liquidity fees between the various liquidity types and secondly to calculate a virtual liquidity commitment amount for assigning AMM users with an ELS value. This will be used for determining the distribution of ELS-eligible fees on a market along with voting weight in market change proposals.
Expand Down

0 comments on commit 705a118

Please sign in to comment.