Mango Markets
Searchโ€ฆ
Liquidity Mining

Overview

Mango Perps are the first perpetual futures contracts that are traded on a fully on chain order book. Providing liquidity on an order book is more of a skilled activity than providing on an AMM contract. In order to bootstrap the liquidity on Mango Perps, the Mango Protocol will disburse MNGO automatically to market makers according to an on-chain algorithm. This document describes the mechanism.

Formula

1
/*
2
Definitions:
3
near touch - best bid if the order is a bid, best ask if order is an ask
4
best_initial - near touch when the order was placed
5
best_final - near touch when the order was canceled
6
time_initial - unix timestamp in seconds of when order was placed
7
time_final - unix timestamp of when order is being executed/canceled
8
โ€‹
9
max_depth_bps - the maximum depth behind near touch the program will reward
10
price - the price of the order
11
โ€‹
12
target_period_length - this is a param set by admin; It's how often we want
13
rate adjustments. Analogous to Bitcoin difficulty adjustment period of 2 weeks
14
15
mngo_per_period - How much MNGO to award per period. This is the threshold
16
to determine when a period ends.
17
18
rate - this is the conversion MNGO per point. It's valid until mngo_per_period MNGO
19
is paid out. Then the rate adjusts.
20
*/
21
โ€‹
22
let best = if order.is_bid {
23
max(best_initial, best_final)
24
} else {
25
min(best_initial, best_final)
26
}
27
โ€‹
28
let dist_bps = abs(price - best) * 10000 / best;
29
let reverse_dist = max(max_depth_bps - dist_bps, 0);
30
let time_on_book = time_final - time_initial;
31
โ€‹
32
let points = reverse_dist * reverse_dist * time_on_book * quantity
33
โ€‹
34
let points_in_period = mngo_left_in_period * rate
35
โ€‹
36
// Check if this puts us over period threshold; If so rate adjust
37
if points >= points_in_period {
38
user.mngo_accrued += mngo_left_in_period;
39
points -= points_in_period;
40
41
// There's no more MNGO for this period
42
// Adjust rate (difficulty adjustment) and start new period
43
let rate_adj = clamp((time_final - period_start) / target_period_length, 1/4, 4);
44
rate = rate * rate_adj;
45
period_start = time_final;
46
mngo_left_in_period = mngo_per_period;
47
}
48
โ€‹
49
// Convert points to MNGO and award to user; limit to mngo_per_period
50
let mngo_earned = min(points * rate, mngo_per_period)
51
mngo_left_in_period -= mngo_earned
52
user.mngo_accrued += mngo_earned
Copied!

Explanation

This mechanism was inspired by the Bitcoin block rewards and difficulty mining adjustments that happen every 2016 blocks. In Bitcoin the target for 2016 blocks is 2 weeks. If it took longer than 2 weeks, then difficulty is adjusted down proportional to the time. If it took less than 2 weeks, difficulty is adjusted up. Similarly, we have a target time of 1 hour with a reward of 1,000 MNGO. When 1000 MNGO is distributed in a period, the time it took is compared against the target time of 1 hour. The rate is adjusted down if it took less than 1 hour and it's adjusted up if it took more than 1 hour.

Motivation

This formula comes out of the intersection of our goals and technical limitations. Here are the goals:
    trustless and decentralized - should work even if initial devs disappear
    open and transparent - no special market maker agreements
    liquidity - tight spread, thick book that rivals centralized exchanges, even if volume is low
    easy to access - deploying the mango markets reference market maker should be profitable
โ€‹
Last modified 1mo ago