# Pricing Mechanism

The pricing of perpetual contract is determined by the construction of the liquidity pool. We stipulate:

- 1.When users open/close positions, or get liquidated, LPs always passively open/close positions with the same size as the user, but in the opposite direction.
- 2.The Liquidity Pool Balance Rate (BR) is calculated using the formula:

BR = Short Positions Value Held by LPs / Total liquidity of LPs

If the LPs hold no positions, then BR is zero, indicating that the liquidity pool is in a fully balanced state. When the LPs hold long positions, BR becomes negative.

3. The Perpetual Contract Price Premium Rate (PR) is the premium rate of the price (P) of the perpetual contract liquidity pool relative to the index price (Pi).

PR = f(BR)

This function is jointly determined by the current state of the liquidity pool and the system parameters. Specifically, when BR = 0, f(BR) = 0, meaning that the premium rate is zero when the LPs are in a fully balanced state.

In summary, the pricing of the perpetual contract can be conceptually represented by the function:

P = f(PR, Pi, System Parameters)

Based on the above functions, with known index price and system parameters, the contract price is determined by the Balance Rate of the liquidity pool. Therefore, we call this mechanism the "Balance Rate Market Maker".

Additionally, in the BRMM algorithm, the f(BR) function is designed to automatically adjust itself, ensuring that the current contract price, P, stays constant when the BR value fluctuates due to the addition or removal of LPs.

**Please Note***: The description of the above functions and all subsequent algorithmic details are for conceptual understanding only. The actual implementation and functionality of the algorithm are defined by the source code.*

The implementation principle of the

*function explained:***PR = f(BR)**Let's take the 0.02% fee tier to explain the principles of the BRMM pricing algorithm. First, we define a set of endpoints comprising 19

*pairs:***(BR, PR)**

**[(-50%, -10%), (-10%, -0.6%), (-9%, -0.5%), (-8%, -0.4%), (-7%, -0.3%), (-6%, -0.2%), (-5%, -0.15%), (-4%, -0.1%), (-2%, -0.05%), (0, 0), (2%, 0.05%), (4%, 0.1%), (5%, 0.15%), (6%, 0.2%), (7%, 0.3%), (8%, 0.4%), (9%, 0.5%), (10%, 0.6%), (50%, 10%)]**

By plotting each point of this set on the

*coordinate axis and connecting them, we create a polyline comprising 18 segments. This polyline defines the direct correlation between BR values and PR values within a -10% to 10% premium rate range, which is the function***(BR, PR)***. Based on this function, we can determine the current market price according to the balance rate of LPs.***PR = f(BR)**From the set of endpoints, it is evident that the entirety of the liquidity provided by LPs in the 0.02% fee tier is symmetrically and non-uniformly distributed across the premium rate range of -10% to 10%.

Last modified 29d ago