# MarketMaker Scoring

### Methodology

* The evaluation objective is to reward market makers who consistently provide tight and deep liquidity for users.
* Market makers earn points according to liquidity contribution, which means there is a score cap per block.
* The calculation is done off-chain based on on-chain blockchain data. The codebase is publicly available for any third-party verification.

### Market Maker Eligibility

* Market maker eligibility is decided by governance every month.
* Only registered market makers can earn incentives based on their scores. Market makers who fail to meet the uptime requirements are also given their month incentives.
* New applicants are requested to submit ApplyMarketMaker transaction to be included in the uptime evaluation. Those who meet the uptime requirement will be included in eligible market makers through governance.
* The governance can exclude existing market makers who fail to meet the requirements for 2 consecutive months or 3 months within the last 5 months.

### Market Maker Orders Requirement

* Orders satisfying following conditions can be recognized and evaluated:
  * Use MMOrder from eligible MMAddress&#x20;
  * `Spread`equal or smaller than `MaxSpread`
  * Min(`AskWidth`,`BidWidth`) equal or larger than `MinWidth`
  * Min(`AskDepth`,`BidDepth`) equal or larger than `MinDepth`
* Parameters (bottom of the document) are assigned differently for each pair depending on the market characteristics, and can be adjusted by governance

### Uptime Requirement

* Uptime requirement is measured in 2 stages:
  * `LiveHour` is added as market maker provide valid orders for an hour. Following 1 out of 2 conditions, it fails:
    * No valid orders longer than `MaxDowntime` in a row
    * No valid orders longer than `MaxTotalDowntime` total in an hour
  * `LiveDay` is added as `LiveHour` is equal or larger than `MinHours` in a day
* Those who earn`LiveDay` equal or larger than `MinDays` satisfy the uptime requirement.
* Parameters (bottom of the document) are decided and adjusted by governance.

### Formula

* Following formula is used to compute how much incentives should be rewarded to each market maker per month. The amount of CRE earned is determined by the relative share of each market maker’s score.

1. First step (within a block)
   * Calculate 2-sided liquidity point and take minimum value (take integer part)
   * $$P = min \lbrack{ {AskQ1}\over{AskD1^2} }+ { {AskQ2}\over{AskD2^2} } + ... , { {BidQ1}\over{BidD1^2} }+ { {BidQ2}\over{BidD2^2} } + ... \rbrack$$
2. Second step (within a block)
   * Obtain contribution score by taking proportion of the point within the block $$P\_m \over \sum\_i P\_i$$
3. Third step (within a month)
   * Calculate `Uptime` by dividing `LiveHour` with total hours in a month

     U = Total `LiveHour` / Total hours in a month
4. Forth step (Final score)
   * Final score of market maker ‘m’ is as following : $$S\_m = {U\_m} ^3 \sum ^{B}{t=1} \lbrack { P{mt} \over \sum\_i P\_{it} }\rbrack$$
     * $$U\_m$$ : % of Market maker m’s `Uptime` in the month
     * $$B$$ : Total number of blocks for the month
     * $$P\_{mt}$$ : Contribution score of market maker ‘m’ at block ‘t’

### Processing Order data

* All variables are used as final values after the trade is made.
* Even if the order of n-th tick is partially filled, the tick can still be a reference point(whether the highest bid or lowest ask) of measures when one of the following conditions is met. If not, the following tick becomes the reference point.
* Min(`AskQ(n)`,`BidQ(n)`) is equal or larger than `MinOpenRatio` of the original order
* Min(`AskQ(n)`,`BidQ(n)`) is equal or larger than `MinOpenDepthRatio` of `MinDepth`

<figure><img src="https://3635471947-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEYtCuIUIqObZPWrSUQb%2Fuploads%2FTlcuwe0SU2hvqwLf1viQ%2Fimage.png?alt=media&#x26;token=e1ba462b-c435-4a2d-9e10-e88806c4ace0" alt=""><figcaption><p>Illustration of Bid/Ask</p></figcaption></figure>

### Measures

* Breadth
  * `MidPrice` : Average price of lowest ask and highest bid
  * `Spread` : Price difference between lowest ask and highest bid divide by `MidPrice`
  * `AskWidth` : Price difference between maximum and minimum ask divided by `MidPrice`. `BidWidth` is same with bid prices
  * `AskD(n)` : Price difference between `MidPrice` and n-th ask price divided by `MidPrice`. `BidD(n)` is same with bid prices
* Depth
  * `AskQ(n)`,`BidQ(n)` : The amount of token remaining in n-th tick
  * `AskDepth`,`BidDepth` : Total amount of token remaining in ask or bid side

## Example

<figure><img src="https://3635471947-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmEYtCuIUIqObZPWrSUQb%2Fuploads%2F4JCgkr0AsfR3jaLEILBv%2Fimage.png?alt=media&#x26;token=8c95db44-51a5-4aea-b7f7-8f76f84247af" alt=""><figcaption></figcaption></figure>

* Assume `MaxSpread` 0.012, `MinWidth` 0.002, `MinDepth` 100, `MinOpenRatio` 0.5, `MinOpenDepthRatio` 0.1
* Measure

  * Block 1

  <table><thead><tr><th width="137"></th><th>Market Maker A</th><th>Market Maker B</th></tr></thead><tbody><tr><td>MidPrice</td><td>9.945 = (9.96 + 9.93) / 2</td><td>9.945 = (9.97 + 9.92) / 2</td></tr><tr><td>Spread</td><td>0.00301659.. = (9.96 - 9.93) / 9.945</td><td>0.00502765.. = (9.97 - 9.92) / 9.945</td></tr><tr><td>AskWidth</td><td>0.00301659.. = (9.99-9.96) / 9.945</td><td>0.00201106.. = (9.99 - 9.97) / 9.945</td></tr><tr><td>BidWidth</td><td>0.00301659.. = (9.93-9.90) / 9.945</td><td>0.00201106.. = (9.92 - 9.90) / 9.945</td></tr><tr><td>AskD(1)</td><td>0.00150829.. = (9.96-9.945) / 9.945</td><td>0.00251382.. = (9.97 - 9.945) / 9.945</td></tr><tr><td>AskD(2)</td><td>0.00251382.. = (9.97-9.945) / 9.945</td><td>0.00351935.. = (9.98 - 9.945) / 9.945</td></tr><tr><td>AskD(3)</td><td>0.00351935.. = (9.98-9.945) / 9.945</td><td>0.00452488.. = (9.99 - 9.945) / 9.945</td></tr><tr><td>AskD(4)</td><td>0.00452488.. = (9.99-9.945) / 9.945</td><td>-</td></tr><tr><td>BidD(1)</td><td>0.00150829.. = (9.945-9.93) / 9.945</td><td>0.00251382.. = (9.945 - 9.92) / 9.945</td></tr><tr><td>BidD(2)</td><td>0.00251382.. = (9.945-9.92) / 9.945</td><td>0.00351935.. = (9.945 - 9.91) / 9.945</td></tr><tr><td>BidD(3)</td><td>0.00351935.. = (9.945-9.91) / 9.945</td><td>0.00452488.. = (9.945 - 9.90) / 9.945</td></tr><tr><td>BidD(4)</td><td>0.00452488.. = (9.945-9.90) / 9.945</td><td>-</td></tr><tr><td>AskDepth</td><td>200</td><td>225</td></tr><tr><td>BidDepth</td><td>160</td><td>240</td></tr><tr><td>AskQ(1)</td><td>50</td><td>75</td></tr><tr><td>AskQ(2)</td><td>50</td><td>75</td></tr><tr><td>AskQ(3)</td><td>50</td><td>75</td></tr><tr><td>AskQ(4)</td><td>50</td><td>-</td></tr><tr><td>BidQ(1)</td><td>40</td><td>80</td></tr><tr><td>BidQ(2)</td><td>40</td><td>80</td></tr><tr><td>BidQ(3)</td><td>40</td><td>80</td></tr><tr><td>BidQ(4)</td><td>40</td><td>-</td></tr></tbody></table>

  * Block 2

  <table><thead><tr><th width="137"></th><th>Market Maker A</th><th>Market Maker B</th></tr></thead><tbody><tr><td>MidPrice</td><td>9.935 = (9.96 + 9.91) / 2</td><td>9.945 = (9.97 + 9.92) / 2</td></tr><tr><td>Spread</td><td>0.00503271.. = (9.96 - 9.91) / 9.935</td><td>0.00502765.. = (9.97 - 9.92) / 9.945</td></tr><tr><td>AskWidth</td><td>0.00301962.. = (9.99-9.96) / 9.935</td><td>0.00201106.. = (9.99 - 9.97) / 9.945</td></tr><tr><td>BidWidth</td><td>0.00100654.. = (9.91-9.90) / 9.935</td><td>0.00201106.. = (9.92 - 9.90) / 9.945</td></tr><tr><td>AskD(1)</td><td>0.00251635.. = (9.96-9.935) / 9.935</td><td>0.00251382.. = (9.97 - 9.945) / 9.945</td></tr><tr><td>AskD(2)</td><td>0.00352289.. = (9.97-9.935) / 9.935</td><td>0.00351935.. = (9.98 - 9.945) / 9.945</td></tr><tr><td>AskD(3)</td><td>0.00452944.. = (9.98-9.935) / 9.935</td><td>0.00452488.. = (9.99 - 9.945) / 9.945</td></tr><tr><td>AskD(4)</td><td>0.00553598.. = (9.99-9.935) / 9.935</td><td>-</td></tr><tr><td>BidD(1)</td><td>0.00050327.. = (9.935-9.93) / 9.935</td><td>0.00251382.. = (9.945 - 9.92) / 9.945</td></tr><tr><td>BidD(2)</td><td>0.00150981.. = (9.935-9.92) / 9.935</td><td>0.00351935.. = (9.945 - 9.91) / 9.945</td></tr><tr><td>BidD(3)</td><td>0.00251635.. = (9.935-9.91) / 9.935</td><td>0.00452488.. = (9.945 - 9.90) / 9.945</td></tr><tr><td>BidD(4)</td><td>0.00352289.. = (9.935-9.90) / 9.935</td><td>-</td></tr><tr><td>AskDepth</td><td>190</td><td>225</td></tr><tr><td>BidDepth</td><td>80</td><td>180</td></tr><tr><td>AskQ(1)</td><td>40</td><td>75</td></tr><tr><td>AskQ(2)</td><td>50</td><td>75</td></tr><tr><td>AskQ(3)</td><td>50</td><td>75</td></tr><tr><td>AskQ(4)</td><td>50</td><td>-</td></tr><tr><td>BidQ(1)</td><td>0</td><td>20</td></tr><tr><td>BidQ(2)</td><td>5</td><td>80</td></tr><tr><td>BidQ(3)</td><td>40</td><td>80</td></tr><tr><td>BidQ(4)</td><td>40</td><td>-</td></tr></tbody></table>

  * In case of market maker A, the highest bid has moved from 9.93 to 9.91 at block 2. `BidQ(2)` does not meet the either conditions of `MinOpenRatio` of original order amount (5/40 < 0.5) nor `MinOpenDepthRatio` ( 100(`MinDepth`) \* 0.1 = 10 ).
  * For market maker B’s case, reference point haven’t changed. `BidQ(1)` could not meet the `MinOpenRatio` (20/80 < 50)condition, but larger than `MinOpenDepthRatio`.
* Liquidity Point
  * Block 1
    * Both market maker A and B meet the condition
      * `Spread(A)`, `Spread(B)` < `MaxSpread` (0.012)
      * `AskWidth(A)`, `BidWidth(A)`, `AskWidth(B)`, `BidWidth(B)` > `MinWidth` (0.002)
      * `AskDepth(A)`, `BidDepth(A)`, `AskDepth(B)`, `BidDepth(B)` > `MinDepth` (100)
    * Each point on Block 1 is as follows, $$P\_{A1} = min \lbrack{ {50}\over{0.0015..^2} }+ {{50}\over{0.0025..^2} } + {{50}\over{0.0035..^2} }+ {{50}\over{0.0045..^2} }, {{40}\over{0.0015..^2} }+ {{40}\over{0.0025..^2} } + {{40}\over{0.0035..^2}}+ {{40}\over{0.0035..^2} }\rbrack$$

      $$P\_{A1} = min \lbrack36369600, 29095680\rbrack = 29,095,680$$\
      $$P\_{B1} = min \lbrack{ {75}\over{0.0025..^2} }+ {{75}\over{0.0035..^2} } + {{75}\over{0.0045..^2} }, {{80}\over{0.0025..^2} }+ {{80}\over{0.0035..^2} } + {{80}\over{0.0045..^2}}\rbrack$$\
      $$P\_{B1} = min \lbrack 21586725, 23025840\rbrack = 21,586,725$$
  * Block 2
    * Only Market maker B meet the condition,

      * `Spread(A)`, `Spread(B)` < `MaxSpread` (0.012)
      * `AskWidth(A)`, `AskWidth(B)`, `BidWidth(B)` > `MinWidth` (0.002)
      * `BidWidth(A) < MinWidth`
      * `AskDepth(A)`, `AskDepth(B)`, `BidDepth(B)` > `MinDepth` (100)
      * `BidDepth(A) < MinDepth`

      $$P\_{A2} = min \lbrack 14414430,0\rbrack = 0$$\
      $$P\_{B2} = min \lbrack{ {75}\over{0.0025..^2} }+ {{75}\over{0.0035..^2} } + {{75}\over{0.0045..^2} }, {{20}\over{0.0025..^2} }+ {{80}\over{0.0035..^2} } + {{80}\over{0.0045..^2}}\rbrack$$\
      $$P\_{B2} = min \lbrack 21586725, 13531150\rbrack = 13,531,150$$
* Contribution Score
  * Block 1\
    $$C\_{A1} = \frac{29095680}{29095680+21586725} = 0.574078..$$\
    $$C\_{B1} = \frac{21586725}{29095680+21586725} = 0.425921..$$
  * Block 2\
    $$C\_{A2} = 0$$\
    $$C\_{B2} = 1$$
* Final Score
  * Sum up all of the contribution scores for the month and product cube of uptime
  * Market maker A : (Assuming uptime 70%)  $$S\_A = (0.7)^3 \*(0.5740.. + 0 +...)$$
  * Market maker B : (Assuming uptime 90%) :  $$S\_B = (0.9)^3 \*( 0.4259..+1+...)$$

### Parameters

Scoring module contains following parameters :

#### Common Parameters

<table><thead><tr><th width="209.33333333333331">Key</th><th width="395">Definition</th><th>Example</th></tr></thead><tbody><tr><td>MinOpenRatio</td><td>Minimum ratio to maintain the tick order</td><td>0.5</td></tr><tr><td>MinOpenDepthRatio</td><td>Minimum ratio of open amount to MinDepth</td><td>0.1</td></tr><tr><td>MaxDowntime</td><td>Maximum allowable consecutive blocks of outage</td><td>20 (blocks)</td></tr><tr><td>MaxTotalDowntime</td><td>Maximum allowable sum of blocks in an hour</td><td>100 (blocks)</td></tr><tr><td>MinHours</td><td>Minimum value of LiveHour to achieve LiveDay</td><td>16</td></tr><tr><td>MinDays</td><td>Minimum value of LiveDay to maintain MM eligibility</td><td>22</td></tr></tbody></table>

#### Parameters for each pair

<table><thead><tr><th width="179.33333333333331">Key</th><th>Definition</th><th>Example</th></tr></thead><tbody><tr><td>PairId</td><td>Pair id of liquidity module</td><td>20</td></tr><tr><td>UpdateTime</td><td>Time the pair variables start to be applied to the scoring system</td><td>2022-12-01T00:00:00Z</td></tr><tr><td>IncentiveWeight</td><td>Incentive weights for each pair</td><td>0.1</td></tr><tr><td>MaxSpread</td><td>Maximum allowable spread between bid and ask</td><td>0.006 (ETH-USDC pair), 0.012 (ATOM-USDC pair)</td></tr><tr><td>MinWidth</td><td>Minimum allowable price difference of high and low on both side of orders</td><td>0.001 (ETH-USDC pair), 0.002 (ATOM-USDC pair)</td></tr><tr><td>MinDepth</td><td>Minimum allowable order depth on each side</td><td>600000000000000000 (ETH-USDC pair), 100000000 (ATOM-USDC pair)</td></tr></tbody></table>
