@morpho-org/midnight-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +252 -0
  2. package/lib/cjs/abis.d.ts +3170 -0
  3. package/lib/cjs/abis.js +4073 -0
  4. package/lib/cjs/api/MidnightApi.d.ts +532 -0
  5. package/lib/cjs/api/MidnightApi.js +713 -0
  6. package/lib/cjs/api/helpers.d.ts +20 -0
  7. package/lib/cjs/api/helpers.js +189 -0
  8. package/lib/cjs/api/index.d.ts +2 -0
  9. package/lib/cjs/api/index.js +21 -0
  10. package/lib/cjs/api/types.d.ts +453 -0
  11. package/lib/cjs/api/types.js +2 -0
  12. package/lib/cjs/constants.d.ts +168 -0
  13. package/lib/cjs/constants.js +187 -0
  14. package/lib/cjs/errors.d.ts +253 -0
  15. package/lib/cjs/errors.js +309 -0
  16. package/lib/cjs/fetch/Market.d.ts +65 -0
  17. package/lib/cjs/fetch/Market.js +117 -0
  18. package/lib/cjs/fetch/Offer.d.ts +74 -0
  19. package/lib/cjs/fetch/Offer.js +119 -0
  20. package/lib/cjs/fetch/Position.d.ts +85 -0
  21. package/lib/cjs/fetch/Position.js +148 -0
  22. package/lib/cjs/fetch/Ratifier.d.ts +38 -0
  23. package/lib/cjs/fetch/Ratifier.js +57 -0
  24. package/lib/cjs/fetch/index.d.ts +5 -0
  25. package/lib/cjs/fetch/index.js +21 -0
  26. package/lib/cjs/fetch/types.d.ts +57 -0
  27. package/lib/cjs/fetch/types.js +2 -0
  28. package/lib/cjs/fetch/utils.d.ts +8 -0
  29. package/lib/cjs/fetch/utils.js +18 -0
  30. package/lib/cjs/index.d.ts +18 -0
  31. package/lib/cjs/index.js +57 -0
  32. package/lib/cjs/market/Market.d.ts +613 -0
  33. package/lib/cjs/market/Market.js +503 -0
  34. package/lib/cjs/market/MarketUtils.d.ts +189 -0
  35. package/lib/cjs/market/MarketUtils.js +303 -0
  36. package/lib/cjs/market/Position.d.ts +424 -0
  37. package/lib/cjs/market/Position.js +425 -0
  38. package/lib/cjs/market/PositionUtils.d.ts +115 -0
  39. package/lib/cjs/market/PositionUtils.js +194 -0
  40. package/lib/cjs/market/index.d.ts +4 -0
  41. package/lib/cjs/market/index.js +20 -0
  42. package/lib/cjs/math/ConsumableUnitsLib.d.ts +57 -0
  43. package/lib/cjs/math/ConsumableUnitsLib.js +77 -0
  44. package/lib/cjs/math/TakeAmountsLib.d.ts +175 -0
  45. package/lib/cjs/math/TakeAmountsLib.js +199 -0
  46. package/lib/cjs/math/TickLib.d.ts +200 -0
  47. package/lib/cjs/math/TickLib.js +272 -0
  48. package/lib/cjs/math/index.d.ts +3 -0
  49. package/lib/cjs/math/index.js +19 -0
  50. package/lib/cjs/offers/Offer.d.ts +534 -0
  51. package/lib/cjs/offers/Offer.js +343 -0
  52. package/lib/cjs/offers/OfferUtils.d.ts +565 -0
  53. package/lib/cjs/offers/OfferUtils.js +659 -0
  54. package/lib/cjs/offers/index.d.ts +2 -0
  55. package/lib/cjs/offers/index.js +18 -0
  56. package/lib/cjs/package.json +1 -0
  57. package/lib/cjs/queries/GetPosition.d.ts +55 -0
  58. package/lib/cjs/queries/GetPosition.js +74 -0
  59. package/lib/cjs/queries/index.d.ts +1 -0
  60. package/lib/cjs/queries/index.js +37 -0
  61. package/lib/cjs/signatures/EcrecoverRatifierUtils.d.ts +733 -0
  62. package/lib/cjs/signatures/EcrecoverRatifierUtils.js +618 -0
  63. package/lib/cjs/signatures/Group.d.ts +178 -0
  64. package/lib/cjs/signatures/Group.js +193 -0
  65. package/lib/cjs/signatures/GroupUtils.d.ts +191 -0
  66. package/lib/cjs/signatures/GroupUtils.js +127 -0
  67. package/lib/cjs/signatures/Payload.d.ts +283 -0
  68. package/lib/cjs/signatures/Payload.js +570 -0
  69. package/lib/cjs/signatures/RatifierUtils.d.ts +109 -0
  70. package/lib/cjs/signatures/RatifierUtils.js +76 -0
  71. package/lib/cjs/signatures/SetterRatifierUtils.d.ts +243 -0
  72. package/lib/cjs/signatures/SetterRatifierUtils.js +217 -0
  73. package/lib/cjs/signatures/Tree.d.ts +241 -0
  74. package/lib/cjs/signatures/Tree.js +263 -0
  75. package/lib/cjs/signatures/TreeUtils.d.ts +573 -0
  76. package/lib/cjs/signatures/TreeUtils.js +461 -0
  77. package/lib/cjs/signatures/index.d.ts +7 -0
  78. package/lib/cjs/signatures/index.js +23 -0
  79. package/lib/esm/abis.d.ts +3170 -0
  80. package/lib/esm/abis.js +4070 -0
  81. package/lib/esm/api/MidnightApi.d.ts +532 -0
  82. package/lib/esm/api/MidnightApi.js +709 -0
  83. package/lib/esm/api/helpers.d.ts +20 -0
  84. package/lib/esm/api/helpers.js +180 -0
  85. package/lib/esm/api/index.d.ts +2 -0
  86. package/lib/esm/api/index.js +2 -0
  87. package/lib/esm/api/types.d.ts +453 -0
  88. package/lib/esm/api/types.js +1 -0
  89. package/lib/esm/constants.d.ts +168 -0
  90. package/lib/esm/constants.js +184 -0
  91. package/lib/esm/errors.d.ts +253 -0
  92. package/lib/esm/errors.js +291 -0
  93. package/lib/esm/fetch/Market.d.ts +65 -0
  94. package/lib/esm/fetch/Market.js +113 -0
  95. package/lib/esm/fetch/Offer.d.ts +74 -0
  96. package/lib/esm/fetch/Offer.js +116 -0
  97. package/lib/esm/fetch/Position.d.ts +85 -0
  98. package/lib/esm/fetch/Position.js +144 -0
  99. package/lib/esm/fetch/Ratifier.d.ts +38 -0
  100. package/lib/esm/fetch/Ratifier.js +54 -0
  101. package/lib/esm/fetch/index.d.ts +5 -0
  102. package/lib/esm/fetch/index.js +5 -0
  103. package/lib/esm/fetch/types.d.ts +57 -0
  104. package/lib/esm/fetch/types.js +1 -0
  105. package/lib/esm/fetch/utils.d.ts +8 -0
  106. package/lib/esm/fetch/utils.js +12 -0
  107. package/lib/esm/index.d.ts +18 -0
  108. package/lib/esm/index.js +18 -0
  109. package/lib/esm/market/Market.d.ts +613 -0
  110. package/lib/esm/market/Market.js +498 -0
  111. package/lib/esm/market/MarketUtils.d.ts +189 -0
  112. package/lib/esm/market/MarketUtils.js +300 -0
  113. package/lib/esm/market/Position.d.ts +424 -0
  114. package/lib/esm/market/Position.js +420 -0
  115. package/lib/esm/market/PositionUtils.d.ts +115 -0
  116. package/lib/esm/market/PositionUtils.js +191 -0
  117. package/lib/esm/market/index.d.ts +4 -0
  118. package/lib/esm/market/index.js +4 -0
  119. package/lib/esm/math/ConsumableUnitsLib.d.ts +57 -0
  120. package/lib/esm/math/ConsumableUnitsLib.js +74 -0
  121. package/lib/esm/math/TakeAmountsLib.d.ts +175 -0
  122. package/lib/esm/math/TakeAmountsLib.js +196 -0
  123. package/lib/esm/math/TickLib.d.ts +200 -0
  124. package/lib/esm/math/TickLib.js +269 -0
  125. package/lib/esm/math/index.d.ts +3 -0
  126. package/lib/esm/math/index.js +3 -0
  127. package/lib/esm/offers/Offer.d.ts +534 -0
  128. package/lib/esm/offers/Offer.js +339 -0
  129. package/lib/esm/offers/OfferUtils.d.ts +565 -0
  130. package/lib/esm/offers/OfferUtils.js +656 -0
  131. package/lib/esm/offers/index.d.ts +2 -0
  132. package/lib/esm/offers/index.js +2 -0
  133. package/lib/esm/package.json +1 -0
  134. package/lib/esm/queries/GetPosition.d.ts +55 -0
  135. package/lib/esm/queries/GetPosition.js +71 -0
  136. package/lib/esm/queries/index.d.ts +1 -0
  137. package/lib/esm/queries/index.js +1 -0
  138. package/lib/esm/signatures/EcrecoverRatifierUtils.d.ts +733 -0
  139. package/lib/esm/signatures/EcrecoverRatifierUtils.js +615 -0
  140. package/lib/esm/signatures/Group.d.ts +178 -0
  141. package/lib/esm/signatures/Group.js +189 -0
  142. package/lib/esm/signatures/GroupUtils.d.ts +191 -0
  143. package/lib/esm/signatures/GroupUtils.js +124 -0
  144. package/lib/esm/signatures/Payload.d.ts +283 -0
  145. package/lib/esm/signatures/Payload.js +564 -0
  146. package/lib/esm/signatures/RatifierUtils.d.ts +109 -0
  147. package/lib/esm/signatures/RatifierUtils.js +73 -0
  148. package/lib/esm/signatures/SetterRatifierUtils.d.ts +243 -0
  149. package/lib/esm/signatures/SetterRatifierUtils.js +214 -0
  150. package/lib/esm/signatures/Tree.d.ts +241 -0
  151. package/lib/esm/signatures/Tree.js +259 -0
  152. package/lib/esm/signatures/TreeUtils.d.ts +573 -0
  153. package/lib/esm/signatures/TreeUtils.js +458 -0
  154. package/lib/esm/signatures/index.d.ts +7 -0
  155. package/lib/esm/signatures/index.js +7 -0
  156. package/package.json +69 -0
  157. package/src/index.ts +19 -0
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Centibip scale used by settlement fees.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { CBP } from "@morpho-org/midnight-sdk";
7
+ *
8
+ * console.log(CBP);
9
+ * ```
10
+ */
11
+ export declare const CBP = 1000000000000n;
12
+ /**
13
+ * Settlement-fee time-to-maturity breakpoints in seconds.
14
+ *
15
+ * Midnight linearly interpolates each market's seven settlement-fee cbp
16
+ * buckets across these breakpoints.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { SETTLEMENT_FEE_BREAKPOINTS } from "@morpho-org/midnight-sdk";
21
+ *
22
+ * console.log(SETTLEMENT_FEE_BREAKPOINTS[1]);
23
+ * ```
24
+ */
25
+ export declare const SETTLEMENT_FEE_BREAKPOINTS: readonly [0n, bigint, bigint, bigint, bigint, bigint, bigint];
26
+ /**
27
+ * Maximum Midnight tick.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { MAX_TICK } from "@morpho-org/midnight-sdk";
32
+ *
33
+ * console.log(MAX_TICK);
34
+ * ```
35
+ */
36
+ export declare const MAX_TICK = 6744n;
37
+ /**
38
+ * WAD price quantum used by Midnight tick prices.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { PRICE_ROUNDING_STEP } from "@morpho-org/midnight-sdk";
43
+ *
44
+ * console.log(PRICE_ROUNDING_STEP);
45
+ * ```
46
+ */
47
+ export declare const PRICE_ROUNDING_STEP = 100000000000n;
48
+ /**
49
+ * Default Midnight tick spacing.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { DEFAULT_TICK_SPACING } from "@morpho-org/midnight-sdk";
54
+ *
55
+ * console.log(DEFAULT_TICK_SPACING);
56
+ * ```
57
+ */
58
+ export declare const DEFAULT_TICK_SPACING = 4n;
59
+ /**
60
+ * Maximum collateral entries in a Midnight market.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * import { MAX_COLLATERALS } from "@morpho-org/midnight-sdk";
65
+ *
66
+ * console.log(MAX_COLLATERALS);
67
+ * ```
68
+ */
69
+ export declare const MAX_COLLATERALS = 128n;
70
+ /**
71
+ * Maximum active collateral entries per borrower.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import { MAX_COLLATERALS_PER_BORROWER } from "@morpho-org/midnight-sdk";
76
+ *
77
+ * console.log(MAX_COLLATERALS_PER_BORROWER);
78
+ * ```
79
+ */
80
+ export declare const MAX_COLLATERALS_PER_BORROWER = 16n;
81
+ /**
82
+ * Maximum settlement-fee values by Midnight fee index.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * import { MAX_SETTLEMENT_FEES } from "@morpho-org/midnight-sdk";
87
+ *
88
+ * console.log(MAX_SETTLEMENT_FEES[0]);
89
+ * ```
90
+ */
91
+ export declare const MAX_SETTLEMENT_FEES: readonly [14000000000000n, 14000000000000n, 98000000000000n, 417000000000000n, 1250000000000000n, 2500000000000000n, 5000000000000000n];
92
+ /**
93
+ * Maximum continuous fee per second.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { MAX_CONTINUOUS_FEE } from "@morpho-org/midnight-sdk";
98
+ *
99
+ * console.log(MAX_CONTINUOUS_FEE);
100
+ * ```
101
+ */
102
+ export declare const MAX_CONTINUOUS_FEE = 317097919n;
103
+ /**
104
+ * Low liquidation cursor used by liquidation incentive factor helpers.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * import { LIQUIDATION_CURSOR_LOW } from "@morpho-org/midnight-sdk";
109
+ *
110
+ * console.log(LIQUIDATION_CURSOR_LOW);
111
+ * ```
112
+ */
113
+ export declare const LIQUIDATION_CURSOR_LOW = 250000000000000000n;
114
+ /**
115
+ * High liquidation cursor from Midnight ConstantsLib.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * import { LIQUIDATION_CURSOR_HIGH } from "@morpho-org/midnight-sdk";
120
+ *
121
+ * console.log(LIQUIDATION_CURSOR_HIGH);
122
+ * ```
123
+ */
124
+ export declare const LIQUIDATION_CURSOR_HIGH = 500000000000000000n;
125
+ /**
126
+ * HashLib collateral params typehash.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * import { COLLATERAL_PARAMS_TYPEHASH } from "@morpho-org/midnight-sdk";
131
+ *
132
+ * console.log(COLLATERAL_PARAMS_TYPEHASH);
133
+ * ```
134
+ */
135
+ export declare const COLLATERAL_PARAMS_TYPEHASH = "0xaf44a88eb50ebdbbebd980e5a23045c44f61ece5f80ab708a1bbe8718102e6af";
136
+ /**
137
+ * HashLib market typehash.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * import { MARKET_TYPEHASH } from "@morpho-org/midnight-sdk";
142
+ *
143
+ * console.log(MARKET_TYPEHASH);
144
+ * ```
145
+ */
146
+ export declare const MARKET_TYPEHASH = "0x358117e98511cc3df97175dca58053b06675b43ad090b0553f8a1eff008b6e2e";
147
+ /**
148
+ * HashLib offer typehash.
149
+ *
150
+ * @example
151
+ * ```ts
152
+ * import { OFFER_TYPEHASH } from "@morpho-org/midnight-sdk";
153
+ *
154
+ * console.log(OFFER_TYPEHASH);
155
+ * ```
156
+ */
157
+ export declare const OFFER_TYPEHASH = "0x6bd2a06ec6952feb97c3e3b4f7de6c342f12b1ac769d5c91368271af636c85b7";
158
+ /**
159
+ * EcrecoverRatifier EIP-712 domain typehash.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * import { EIP712_DOMAIN_TYPEHASH } from "@morpho-org/midnight-sdk";
164
+ *
165
+ * console.log(EIP712_DOMAIN_TYPEHASH);
166
+ * ```
167
+ */
168
+ export declare const EIP712_DOMAIN_TYPEHASH = "0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218";
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Centibip scale used by settlement fees.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { CBP } from "@morpho-org/midnight-sdk";
7
+ *
8
+ * console.log(CBP);
9
+ * ```
10
+ */
11
+ export const CBP = 1000000000000n;
12
+ /**
13
+ * Settlement-fee time-to-maturity breakpoints in seconds.
14
+ *
15
+ * Midnight linearly interpolates each market's seven settlement-fee cbp
16
+ * buckets across these breakpoints.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { SETTLEMENT_FEE_BREAKPOINTS } from "@morpho-org/midnight-sdk";
21
+ *
22
+ * console.log(SETTLEMENT_FEE_BREAKPOINTS[1]);
23
+ * ```
24
+ */
25
+ export const SETTLEMENT_FEE_BREAKPOINTS = [
26
+ 0n,
27
+ 1n * 24n * 60n * 60n,
28
+ 7n * 24n * 60n * 60n,
29
+ 30n * 24n * 60n * 60n,
30
+ 90n * 24n * 60n * 60n,
31
+ 180n * 24n * 60n * 60n,
32
+ 360n * 24n * 60n * 60n,
33
+ ];
34
+ /**
35
+ * Maximum Midnight tick.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { MAX_TICK } from "@morpho-org/midnight-sdk";
40
+ *
41
+ * console.log(MAX_TICK);
42
+ * ```
43
+ */
44
+ export const MAX_TICK = 6744n;
45
+ /**
46
+ * WAD price quantum used by Midnight tick prices.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { PRICE_ROUNDING_STEP } from "@morpho-org/midnight-sdk";
51
+ *
52
+ * console.log(PRICE_ROUNDING_STEP);
53
+ * ```
54
+ */
55
+ export const PRICE_ROUNDING_STEP = 100000000000n;
56
+ /**
57
+ * Default Midnight tick spacing.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { DEFAULT_TICK_SPACING } from "@morpho-org/midnight-sdk";
62
+ *
63
+ * console.log(DEFAULT_TICK_SPACING);
64
+ * ```
65
+ */
66
+ export const DEFAULT_TICK_SPACING = 4n;
67
+ /**
68
+ * Maximum collateral entries in a Midnight market.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { MAX_COLLATERALS } from "@morpho-org/midnight-sdk";
73
+ *
74
+ * console.log(MAX_COLLATERALS);
75
+ * ```
76
+ */
77
+ export const MAX_COLLATERALS = 128n;
78
+ /**
79
+ * Maximum active collateral entries per borrower.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * import { MAX_COLLATERALS_PER_BORROWER } from "@morpho-org/midnight-sdk";
84
+ *
85
+ * console.log(MAX_COLLATERALS_PER_BORROWER);
86
+ * ```
87
+ */
88
+ export const MAX_COLLATERALS_PER_BORROWER = 16n;
89
+ /**
90
+ * Maximum settlement-fee values by Midnight fee index.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * import { MAX_SETTLEMENT_FEES } from "@morpho-org/midnight-sdk";
95
+ *
96
+ * console.log(MAX_SETTLEMENT_FEES[0]);
97
+ * ```
98
+ */
99
+ export const MAX_SETTLEMENT_FEES = [
100
+ 14000000000000n,
101
+ 14000000000000n,
102
+ 98000000000000n,
103
+ 417000000000000n,
104
+ 1250000000000000n,
105
+ 2500000000000000n,
106
+ 5000000000000000n,
107
+ ];
108
+ /**
109
+ * Maximum continuous fee per second.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { MAX_CONTINUOUS_FEE } from "@morpho-org/midnight-sdk";
114
+ *
115
+ * console.log(MAX_CONTINUOUS_FEE);
116
+ * ```
117
+ */
118
+ export const MAX_CONTINUOUS_FEE = 317097919n;
119
+ /**
120
+ * Low liquidation cursor used by liquidation incentive factor helpers.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * import { LIQUIDATION_CURSOR_LOW } from "@morpho-org/midnight-sdk";
125
+ *
126
+ * console.log(LIQUIDATION_CURSOR_LOW);
127
+ * ```
128
+ */
129
+ export const LIQUIDATION_CURSOR_LOW = 250000000000000000n;
130
+ /**
131
+ * High liquidation cursor from Midnight ConstantsLib.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * import { LIQUIDATION_CURSOR_HIGH } from "@morpho-org/midnight-sdk";
136
+ *
137
+ * console.log(LIQUIDATION_CURSOR_HIGH);
138
+ * ```
139
+ */
140
+ export const LIQUIDATION_CURSOR_HIGH = 500000000000000000n;
141
+ /**
142
+ * HashLib collateral params typehash.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * import { COLLATERAL_PARAMS_TYPEHASH } from "@morpho-org/midnight-sdk";
147
+ *
148
+ * console.log(COLLATERAL_PARAMS_TYPEHASH);
149
+ * ```
150
+ */
151
+ export const COLLATERAL_PARAMS_TYPEHASH = "0xaf44a88eb50ebdbbebd980e5a23045c44f61ece5f80ab708a1bbe8718102e6af";
152
+ /**
153
+ * HashLib market typehash.
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * import { MARKET_TYPEHASH } from "@morpho-org/midnight-sdk";
158
+ *
159
+ * console.log(MARKET_TYPEHASH);
160
+ * ```
161
+ */
162
+ export const MARKET_TYPEHASH = "0x358117e98511cc3df97175dca58053b06675b43ad090b0553f8a1eff008b6e2e";
163
+ /**
164
+ * HashLib offer typehash.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * import { OFFER_TYPEHASH } from "@morpho-org/midnight-sdk";
169
+ *
170
+ * console.log(OFFER_TYPEHASH);
171
+ * ```
172
+ */
173
+ export const OFFER_TYPEHASH = "0x6bd2a06ec6952feb97c3e3b4f7de6c342f12b1ac769d5c91368271af636c85b7";
174
+ /**
175
+ * EcrecoverRatifier EIP-712 domain typehash.
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * import { EIP712_DOMAIN_TYPEHASH } from "@morpho-org/midnight-sdk";
180
+ *
181
+ * console.log(EIP712_DOMAIN_TYPEHASH);
182
+ * ```
183
+ */
184
+ export const EIP712_DOMAIN_TYPEHASH = "0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218";
@@ -0,0 +1,253 @@
1
+ import type { Address } from "viem";
2
+ /**
3
+ * Thrown when a Midnight offer group violates protocol-level group mechanics.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { InvalidOfferGroupError } from "@morpho-org/midnight-sdk";
8
+ *
9
+ * throw new InvalidOfferGroupError("All offers in a group must use the same maker.");
10
+ * ```
11
+ */
12
+ export declare class InvalidOfferGroupError extends Error {
13
+ constructor(reason: string);
14
+ }
15
+ /**
16
+ * Thrown when a tick exceeds the deployed TickLib range.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { TickOutOfRangeError } from "@morpho-org/midnight-sdk";
21
+ *
22
+ * const error = new TickOutOfRangeError(7000n, 6744n);
23
+ * console.log(error.message);
24
+ * ```
25
+ */
26
+ export declare class TickOutOfRangeError extends Error {
27
+ constructor(tick: bigint, maxTick: bigint);
28
+ }
29
+ /**
30
+ * Thrown when a price is above the maximum WAD price accepted by TickLib.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { PriceGreaterThanOneError } from "@morpho-org/midnight-sdk";
35
+ *
36
+ * throw new PriceGreaterThanOneError(2n * 10n ** 18n);
37
+ * ```
38
+ */
39
+ export declare class PriceGreaterThanOneError extends Error {
40
+ constructor(price: bigint);
41
+ }
42
+ /**
43
+ * Thrown when tick spacing is invalid or a tick is not aligned to it.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { InvalidTickSpacingError } from "@morpho-org/midnight-sdk";
48
+ *
49
+ * throw new InvalidTickSpacingError(5n, 4n);
50
+ * ```
51
+ */
52
+ export declare class InvalidTickSpacingError extends Error {
53
+ constructor(spacing: bigint);
54
+ constructor(tick: bigint, spacing: bigint);
55
+ }
56
+ /**
57
+ * Thrown when a buy offer's settlement fee exceeds its tick price.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { SettlementFeeExceedsPriceError } from "@morpho-org/midnight-sdk";
62
+ *
63
+ * throw new SettlementFeeExceedsPriceError(10n, 9n);
64
+ * ```
65
+ */
66
+ export declare class SettlementFeeExceedsPriceError extends Error {
67
+ constructor(settlementFee: bigint, price: bigint);
68
+ }
69
+ /**
70
+ * Thrown when a local position accrual is requested for an impossible timestamp.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { InvalidPositionAccrualTimestampError } from "@morpho-org/midnight-sdk";
75
+ *
76
+ * throw new InvalidPositionAccrualTimestampError(1n, 2n);
77
+ * ```
78
+ */
79
+ export declare class InvalidPositionAccrualTimestampError extends Error {
80
+ constructor(timestamp: bigint, lastAccrual: bigint);
81
+ }
82
+ /**
83
+ * Thrown when a local position accrual sees a market loss factor older than the position.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { InvalidPositionLossFactorError } from "@morpho-org/midnight-sdk";
88
+ *
89
+ * throw new InvalidPositionLossFactorError(1n, 2n);
90
+ * ```
91
+ */
92
+ export declare class InvalidPositionLossFactorError extends Error {
93
+ constructor(marketLossFactor: bigint, positionLossFactor: bigint);
94
+ }
95
+ /**
96
+ * Thrown when local position accrual inputs violate Midnight accounting invariants.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * import { InvalidPositionAccrualStateError } from "@morpho-org/midnight-sdk";
101
+ *
102
+ * throw new InvalidPositionAccrualStateError("Pending fee exceeds credit.");
103
+ * ```
104
+ */
105
+ export declare class InvalidPositionAccrualStateError extends Error {
106
+ constructor(reason: string);
107
+ }
108
+ /**
109
+ * Thrown when a market parameter cannot satisfy Midnight protocol rules.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { InvalidMarketParameterError } from "@morpho-org/midnight-sdk";
114
+ *
115
+ * throw new InvalidMarketParameterError({
116
+ * parameter: "collateralParams",
117
+ * value: 0,
118
+ * instruction: "Provide at least one collateral.",
119
+ * });
120
+ * ```
121
+ * @param params.parameter - Invalid market parameter name.
122
+ * @param params.value - Invalid market parameter value.
123
+ * @param params.instruction - Optional instruction appended to the error message.
124
+ * @param params.cause - Optional wrapped cause.
125
+ */
126
+ export declare class InvalidMarketParameterError extends Error {
127
+ /** Invalid market parameter name. */
128
+ readonly parameter: string;
129
+ /** Invalid market parameter value. */
130
+ readonly value: unknown;
131
+ constructor(params: {
132
+ readonly parameter: string;
133
+ readonly value: unknown;
134
+ readonly instruction?: string;
135
+ readonly cause?: unknown;
136
+ });
137
+ }
138
+ /**
139
+ * Thrown when an offer builder receives a parameter that cannot satisfy Midnight protocol rules.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import { InvalidOfferParameterError } from "@morpho-org/midnight-sdk";
144
+ *
145
+ * throw new InvalidOfferParameterError({ parameter: "tick", value: 5821n });
146
+ * ```
147
+ * @param params.parameter - Invalid offer parameter name.
148
+ * @param params.value - Invalid offer parameter value.
149
+ * @param params.instruction - Optional instruction appended to the error message.
150
+ * @param params.cause - Optional wrapped cause.
151
+ */
152
+ export declare class InvalidOfferParameterError extends Error {
153
+ /** Invalid offer parameter name. */
154
+ readonly parameter: string;
155
+ /** Invalid offer parameter value. */
156
+ readonly value: unknown;
157
+ constructor(params: {
158
+ readonly parameter: string;
159
+ readonly value: unknown;
160
+ readonly instruction?: string;
161
+ readonly cause?: unknown;
162
+ });
163
+ }
164
+ /**
165
+ * Thrown when a tree height exceeds the ratifier typehash table.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * import { InvalidTreeHeightError } from "@morpho-org/midnight-sdk";
170
+ *
171
+ * throw new InvalidTreeHeightError(21);
172
+ * ```
173
+ */
174
+ export declare class InvalidTreeHeightError extends Error {
175
+ constructor(height: number);
176
+ }
177
+ /**
178
+ * Thrown when a tree cannot be represented by the ratifiers.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * import { InvalidTreeError } from "@morpho-org/midnight-sdk";
183
+ *
184
+ * throw new InvalidTreeError("Tree must not be empty.");
185
+ * ```
186
+ */
187
+ export declare class InvalidTreeError extends Error {
188
+ constructor(message: string);
189
+ }
190
+ /**
191
+ * Thrown when a typed-data signature does not recover to the expected signer.
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * import { InvalidTypedDataSignatureError } from "@morpho-org/midnight-sdk";
196
+ *
197
+ * throw new InvalidTypedDataSignatureError(
198
+ * "0x0000000000000000000000000000000000000001",
199
+ * );
200
+ * ```
201
+ */
202
+ export declare class InvalidTypedDataSignatureError extends Error {
203
+ /** Signer address the signature was expected to recover. */
204
+ readonly signer: Address;
205
+ constructor(signer: Address);
206
+ }
207
+ /**
208
+ * Thrown when the Midnight API returns a non-2xx response.
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * import { MidnightApiError } from "@morpho-org/midnight-sdk/api";
213
+ *
214
+ * throw new MidnightApiError({
215
+ * status: 400,
216
+ * code: "BAD_REQUEST",
217
+ * message: "Limit must be greater than 0.",
218
+ * details: [{ field: "limit", issue: "Limit must be greater than 0." }],
219
+ * requestId: "req-123",
220
+ * });
221
+ * ```
222
+ */
223
+ export declare class MidnightApiError extends Error {
224
+ /** HTTP response status from the API. */
225
+ readonly status: number;
226
+ /** API error code, when the response body includes one. */
227
+ readonly code?: string;
228
+ /** API error details, when the response body includes them. */
229
+ readonly details?: unknown;
230
+ /** API request id, when the response body includes one. */
231
+ readonly requestId?: string;
232
+ constructor(params: {
233
+ readonly status: number;
234
+ readonly code?: string;
235
+ readonly message?: string;
236
+ readonly details?: unknown;
237
+ readonly requestId?: string;
238
+ readonly cause?: unknown;
239
+ });
240
+ }
241
+ /**
242
+ * Thrown when the Midnight API returns a malformed successful response.
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * import { InvalidMidnightApiResponseError } from "@morpho-org/midnight-sdk/api";
247
+ *
248
+ * throw new InvalidMidnightApiResponseError("API response is missing data.");
249
+ * ```
250
+ */
251
+ export declare class InvalidMidnightApiResponseError extends Error {
252
+ constructor(message: string, options?: ErrorOptions);
253
+ }