Skip to content

Commit 7246759

Browse files
committed
feat: allowed empty amm levels
1 parent d335bce commit 7246759

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

protocol/0001-MKTF-market_framework.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Data:
3535
- **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`.
3636
- **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.
3737
- **Transaction Prioritisation**: A boolean, whether to enable [transaction prioritisation](./0092-TRTO-trading_transaction_ordering.md).
38+
- **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.
3839

3940
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.
4041

protocol/0090-VAMM-automated_market_maker.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ $$
167167
P_{v_u} = \frac{r_f b}{p_u (1 + r_f) - r_f p_a} ,
168168
$$
169169

170-
where $r_f$ is the `short` factor for the upper range and the `long` factor for the lower range, `b` is the current total balance of the vAMM across all accounts, $P_{v_l}$ is the theoretical volume and the bottom of the lower bound and $P_{v_u}$ is the (absolute value of the) theoretical volume at the top of the upper bound. The final $L$ scores can then be reached with the equation
170+
where $r_f$ is the `short` factor for the upper range and the `long` factor for the lower range, `b` is the commitment amount, $P_{v_l}$ is the theoretical volume and the bottom of the lower bound and $P_{v_u}$ is the (absolute value of the) theoretical volume at the top of the upper bound. The final $L$ scores can then be reached with the equation
171171

172172
$$
173173
L = P_v \cdot \frac{\sqrt{p_u} \sqrt{p_l}}{\sqrt{p_u} - \sqrt{p_l}} = P_v L_u,
@@ -235,6 +235,52 @@ $$
235235

236236
Then simply return the absolute difference between these two prices.
237237

238+
## Best bid / best ask
239+
240+
As the volume provided between two ticks can theoretically be less than the smallest unit of volume supported by the market's position decimals, the best-bid and ask will not always simply be one tick greater or less than the AMMs current fair price.
241+
242+
Instead the best-bid and best-ask of an AMM curve is defined as the price levels at which the AMM will quote at least one unit of volume between those prices and the current fair price. Re-arranging the formulas defined in the prior [section](#volume-between-two-prices) yields the following:
243+
244+
$$
245+
p_{bb} = \frac{L\cdot\sqrt{p_f}}{L + V\cdot \sqrt{p_f}}
246+
$$
247+
248+
$$
249+
p_{bb} = \frac{L\cdot\sqrt{p_f}}{L - V\cdot \sqrt{p_f}}
250+
$$
251+
252+
Where:
253+
254+
- $P_{bb}$ is the calculated best bid
255+
- $P_{ba}$ is the calculated best ask
256+
- $p_{f}$ is the current fair price as calculated [here](#fair-price)
257+
- $L$ is the liquidity score as calculated [here](#determining-volumes-and-prices)
258+
259+
## Curve validity
260+
261+
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.
262+
263+
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.
264+
265+
- for the lower curve, this range is between the fair price at which the AMMs long position is $P=1$ and the base price.
266+
- 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.
267+
268+
The above definitions yield the following inequality which must be satisfied for both the upper and lower curve for the AMM to be valid.
269+
270+
$$
271+
n\cdot\Delta{p} \geq \frac{L\cdot\sqrt{p_u}}{L + \Delta{P}\cdot \sqrt{p_u}}
272+
$$
273+
274+
Where:
275+
276+
- $\Delta{p}$ is the smallest price movement supported by the market's price decimals and tick size
277+
- $\Delta{P}$ is the smallest position size supported by the market's position decimals
278+
- $n$ is the market parameter $allowedEmptyAmmLevels$
279+
- $L$ is the liquidity score for the relevant curve
280+
- $p_u$ is the upper price (the base price for the lower curve and the upper bound for the upper curve)
281+
282+
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.
283+
238284
## Determining Liquidity Contribution
239285

240286
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.
@@ -341,3 +387,16 @@ At market settlement, an AMM's position will be settled alongside all others as
341387
- With an existing book consisting solely of vAMM orders, pegged orders referencing best bid/best ask remain deployed, pegged to their pegs, where the best buy/sell vAMM order price acts as the best bid, or best ask peg respectively. (<a name="0090-VAMM-036" href="#0090-VAMM-036">0090-VAMM-036</a>)
342388

343389
- With an existing book consisting solely of vAMM orders on one side, pegged orders referencing best bid/best ask remain deployed on the side with the vAMM orders. Pegged orders referencing the empty side of the book are parked. (<a name="0090-VAMM-037" href="#0090-VAMM-037">0090-VAMM-037</a>)
390+
391+
## Curve validity
392+
393+
### Governance
394+
395+
- A market creation proposal specifying a market parameter $allowedEmptyAmmLevels$ less than zero should be rejected. (<a name="0090-VAMM-xxx" href="#0090-VAMM-xxx">0090-VAMM-xxx</a>)
396+
- A market update proposal specifying a market parameter $allowedEmptyAmmLevels$ less than zero should be rejected. (<a name="0090-VAMM-xxx" href="#0090-VAMM-xxx">0090-VAMM-xxx</a>)
397+
- A market specifying $allowedEmptyAmmLevels=0$ will enforce the requirement that an AMM provides at least one unit of volume at every price level within in it's range. (<a name="0090-VAMM-xxx" href="#0090-VAMM-xxx">0090-VAMM-xxx</a>)
398+
399+
- If the market parameter $allowedEmptyAmmLevels$ is updated such that a valid AMM is no longer valid, that AMM is not cancelled. (<a name="0090-VAMM-xxx" href="#0090-VAMM-xxx">0090-VAMM-xxx</a>)
400+
- If the market parameter $allowedEmptyAmmLevels$ is updated such that a valid AMM is no longer valid, any amendments to that AMM that are also not valid should be rejected but the AMM should remain active. (<a name="0090-VAMM-xxx" href="#0090-VAMM-xxx">0090-VAMM-xxx</a>)
401+
- If the market parameter $allowedEmptyAmmLevels$ is updated such that a valid AMM is no longer valid, any amendments to that AMM that are valid should be accepted and the AMM should be updated. (<a name="0090-VAMM-xxx" href="#0090-VAMM-xxx">0090-VAMM-xxx</a>)
402+
- If the market parameter $allowedEmptyAmmLevels$ is updated such that a valid AMM is no longer valid, any cancellations of that AMM should be accepted and the AMM should be cancelled. (<a name="0090-VAMM-xxx" href="#0090-VAMM-xxx">0090-VAMM-xxx</a>)

0 commit comments

Comments
 (0)