-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconstants.ml
118 lines (92 loc) · 6.37 KB
/
constants.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
open Common
open FixedPoint
open Tok
(** Dimensionless. Factor used for setting the minting limit. *)
let[@inline] fminting : ratio = make_ratio (Ligo.int_from_literal "21") (Ligo.int_from_literal "10") (* 2.1 *)
(** Dimensionless. Factor used for setting the liquidation limit. *)
let[@inline] fliquidation : ratio = make_ratio (Ligo.int_from_literal "19") (Ligo.int_from_literal "10") (* 1.9 *)
(** Number of tez needed to be given for the creation of a burrow; it does
not count towards the burrow's collateral. *)
let[@inline] creation_deposit : tok = tok_one
(** Yearly burrow fee percentage. *)
let[@inline] burrow_fee_percentage : ratio = make_ratio (Ligo.int_from_literal "5") (Ligo.int_from_literal "1000") (* 0.005 *)
(** Factor used to scale down the imbalance rate. The higher the value, the
faster the imbalance rate saturates. *)
let[@inline] imbalance_scaling_factor : ratio = make_ratio (Ligo.int_from_literal "3") (Ligo.int_from_literal "4") (* 0.75 *)
(** Maximum yearly imbalance rate. *)
let[@inline] imbalance_limit = make_ratio (Ligo.int_from_literal "5") (Ligo.int_from_literal "100")
(** The percentage of a burrow's collateral that we offer to whoever triggers
the burrow's liquidation. *)
let[@inline] liquidation_reward_percentage : ratio =
make_ratio (Ligo.int_from_literal "1") (Ligo.int_from_literal "1000") (* 0.001 *)
(** Percentage kept by the cfmm contract from the return asset. *)
let[@inline] cfmm_fee : ratio = make_ratio (Ligo.int_from_literal "2") (Ligo.int_from_literal "1000") (* 0.002 *)
(** Protected index epsilon. The higher this value is, the faster the protected
index catches up with the actual index. Currently calculated as 0.05cNp
per minute. Basically
{[(0.05 / 100) / 60 = 5/600_000 = 1/120_000]}
so the inverse is simply 120_000. *)
let[@inline] protected_index_inverse_epsilon : Ligo.int = Ligo.int_from_literal "120_000"
(** The maximum amount of collateral that can be in an auction lot. *)
let[@inline] max_lot_size : tok = tok_of_denomination (Ligo.nat_from_literal "10_000_000_000n")
(** The minimum fraction of the auction queue which must go into a new auction lot. *)
let[@inline] min_lot_auction_queue_fraction : ratio =
make_ratio (Ligo.int_from_literal "5") (Ligo.int_from_literal "100")
(** The percentage of additional collateral that we charge when liquidating
a burrow, to penalize it for liquidation. *)
let[@inline] liquidation_penalty : ratio = make_ratio (Ligo.int_from_literal "1") (Ligo.int_from_literal "10") (* 0.1 *)
(** For convenience. The number of seconds in a year, taking into account
leap years. Basically
{[(365 + 1/4 - 1/100 + 1/400) days * 24 * 60 * 60]}
*)
let[@inline] seconds_in_a_year : Ligo.int = Ligo.int_from_literal "31556952"
(** For convenience. The number of seconds in a day. Basically
{[24h * 60min/h * 60sec/min = 86400]}
*)
let[@inline] seconds_in_a_day : Ligo.int = Ligo.int_from_literal "86400"
(** Low bracket used for the calculation of the drift derivative. *)
let[@inline] target_low_bracket : ratio = make_ratio (Ligo.int_from_literal "5") (Ligo.int_from_literal "1000") (* 0.005 *)
(** High bracket used for the calculation of the drift derivative. *)
let[@inline] target_high_bracket : ratio = make_ratio (Ligo.int_from_literal "5") (Ligo.int_from_literal "100") (* 0.05 *)
(** The drift derivative can take one of 5 distinct values: 0, +/-0.01 cNp/day,
and +/-0.05 cNp/day. We calculate those statically thus as follows:
{[
low_acceleration = 0.01/100 * (86400 * 86400) = 1/74649600000000 = 247111 in fixedpoint
high_acceleration = 0.05/100 * (86400 * 86400) = 5/74649600000000 = 1235555 in fixedpoint
]}
*)
let[@inline] low_positive_acceleration : fixedpoint = fixedpoint_of_raw (Ligo.int_from_literal "247111")
let[@inline] low_negative_acceleration : fixedpoint = fixedpoint_of_raw (Ligo.int_from_literal "-247111")
let[@inline] high_positive_acceleration : fixedpoint = fixedpoint_of_raw (Ligo.int_from_literal "1235555")
let[@inline] high_negative_acceleration : fixedpoint = fixedpoint_of_raw (Ligo.int_from_literal "-1235555")
(** How fast a descending option price drops per second. Currently we want it
to drop by around 1cNp per minute, so we just divide by 60 to get roughly
how much it should be per second. *)
let[@inline] auction_decay_rate : ratio = make_ratio (Ligo.int_from_literal "1") (Ligo.int_from_literal "6000") (* 0.01/60 *)
(** The maximum number of seconds that can pass between two (ascending) bids
during an auction. The auction should expire if more than this many seconds
pass between two bids. Currently set to 20min ([20min * 60sec/min = 1200s]). *)
let[@inline] max_bid_interval_in_seconds : Ligo.int = Ligo.int_from_literal "1200"
(** The maximum number of blocks that can pass between two (ascending) bids
during an auction. The auction should expire if more blocks than this
number pass between two bids. Currently set to 20. *)
let[@inline] max_bid_interval_in_blocks : Ligo.nat = Ligo.nat_from_literal "20n"
(** Every bid in an ascending auction needs to improve over the previous bid by
at least 0.33 cNp. *)
let[@inline] bid_improvement_factor : ratio = make_ratio (Ligo.int_from_literal "33") (Ligo.int_from_literal "10000") (* 0.33/100 *)
(** Parameter used for calculating the current reward for touching the checker
contract. See {!Checker.calculate_touch_reward} for their use. *)
let[@inline] touch_reward_low_bracket : Ligo.int = Ligo.int_from_literal "600" (* = 60 * 10 = 10 minutes *)
(** We want the reward in the first bracket to be 0.1 kit / minute, so we just
divide by 60 to get roughly how much should it be per second. *)
let[@inline] touch_low_reward : ratio = make_ratio (Ligo.int_from_literal "1") (Ligo.int_from_literal "600") (* 0.1/60 *)
(** We want the reward in the first bracket to be 1 kit / minute, so we just
divide by 60 to get roughly how much should it be per second. *)
let[@inline] touch_high_reward : ratio = make_ratio (Ligo.int_from_literal "1") (Ligo.int_from_literal "60") (* 1/60 *)
(** The number of liquidation slices to process every time the checker
contract is touched. *)
let[@inline] number_of_slices_to_process : Ligo.nat = Ligo.nat_from_literal "5n"
(** Maximum height of the tree used as liquidation queue.
The maximum number of elements will be between [2**(n-1)] and [2**(n-2)].
*)
let[@inline] max_liquidation_queue_height: Ligo.nat = Ligo.nat_from_literal "12n"