@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,424 @@
1
+ import { type BigIntish } from "@morpho-org/morpho-ts";
2
+ import type { Address } from "viem";
3
+ import { type IMarket, Market } from "./Market.js";
4
+ /**
5
+ * Plain input accepted by {@link Position}.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import type { IPosition } from "@morpho-org/midnight-sdk";
10
+ *
11
+ * const position: IPosition = {
12
+ * credit: 0n,
13
+ * pendingFee: 0n,
14
+ * lastLossFactor: 0n,
15
+ * lastAccrual: 0n,
16
+ * debt: 0n,
17
+ * collateralBitmap: 0n,
18
+ * collateral: Array.from({ length: 128 }, () => 0n),
19
+ * };
20
+ * ```
21
+ */
22
+ export interface IPosition {
23
+ /** User credit. */
24
+ readonly credit: BigIntish;
25
+ /** Pending continuous fee. */
26
+ readonly pendingFee: BigIntish;
27
+ /** Last loss factor seen by the position. */
28
+ readonly lastLossFactor: BigIntish;
29
+ /** Last accrual timestamp. */
30
+ readonly lastAccrual: BigIntish;
31
+ /** User debt. */
32
+ readonly debt: BigIntish;
33
+ /** Collateral bitmap. */
34
+ readonly collateralBitmap: BigIntish;
35
+ /** Collateral balances by index. */
36
+ readonly collateral: readonly BigIntish[];
37
+ }
38
+ /**
39
+ * Midnight user position as stored by the core contract.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * import { Position } from "@morpho-org/midnight-sdk";
44
+ *
45
+ * const position = new Position({
46
+ * credit: 0n,
47
+ * pendingFee: 0n,
48
+ * lastLossFactor: 0n,
49
+ * lastAccrual: 0n,
50
+ * debt: 0n,
51
+ * collateralBitmap: 0n,
52
+ * collateral: [],
53
+ * });
54
+ * console.log(position.debt);
55
+ * ```
56
+ */
57
+ export declare class Position {
58
+ /** User credit. */
59
+ readonly credit: bigint;
60
+ /** Pending continuous fee. */
61
+ readonly pendingFee: bigint;
62
+ /** Last loss factor seen by the position. */
63
+ readonly lastLossFactor: bigint;
64
+ /** Last accrual timestamp. */
65
+ readonly lastAccrual: bigint;
66
+ /** User debt. */
67
+ readonly debt: bigint;
68
+ /** Collateral bitmap. */
69
+ readonly collateralBitmap: bigint;
70
+ /** Collateral balances by index. */
71
+ readonly collateral: readonly bigint[];
72
+ constructor(position: IPosition);
73
+ /**
74
+ * Returns credit net of pending fee, floored to zero for invalid raw inputs.
75
+ *
76
+ * @returns Credit minus pending fee.
77
+ * @example
78
+ * ```ts
79
+ * import { Position } from "@morpho-org/midnight-sdk";
80
+ *
81
+ * const position = new Position({
82
+ * credit: 1_000n,
83
+ * pendingFee: 100n,
84
+ * lastLossFactor: 0n,
85
+ * lastAccrual: 0n,
86
+ * debt: 0n,
87
+ * collateralBitmap: 1n,
88
+ * collateral: [50n],
89
+ * });
90
+ * console.log(position.faceValue);
91
+ * ```
92
+ */
93
+ get faceValue(): bigint;
94
+ }
95
+ /**
96
+ * Midnight position paired with its hydrated market.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * import { registerCustomAddresses } from "@morpho-org/morpho-ts";
101
+ * import { AccrualPosition } from "@morpho-org/midnight-sdk";
102
+ *
103
+ * registerCustomAddresses({
104
+ * addresses: {
105
+ * 31337: {
106
+ * morpho: "0x0000000000000000000000000000000000000001",
107
+ * bundler3: {
108
+ * bundler3: "0x0000000000000000000000000000000000000002",
109
+ * generalAdapter1: "0x0000000000000000000000000000000000000003",
110
+ * },
111
+ * adaptiveCurveIrm: "0x0000000000000000000000000000000000000004",
112
+ * midnight: "0x0000000000000000000000000000000000001000",
113
+ * },
114
+ * },
115
+ * });
116
+ *
117
+ * const position = new AccrualPosition(
118
+ * {
119
+ * credit: 1_000n,
120
+ * pendingFee: 100n,
121
+ * lastLossFactor: 0n,
122
+ * lastAccrual: 1_000n,
123
+ * debt: 0n,
124
+ * collateralBitmap: 1n,
125
+ * collateral: [50n],
126
+ * },
127
+ * {
128
+ * chainId: 31337,
129
+ * params: {
130
+ * loanToken: "0x0000000000000000000000000000000000006000",
131
+ * collateralParams: [
132
+ * {
133
+ * token: "0x0000000000000000000000000000000000007000",
134
+ * lltv: 770000000000000000n,
135
+ * maxLif: 1061007957559681697n,
136
+ * oracle: "0x0000000000000000000000000000000000008000",
137
+ * },
138
+ * ],
139
+ * maturity: 54_000n,
140
+ * rcfThreshold: 0n,
141
+ * enterGate: "0x0000000000000000000000000000000000000000",
142
+ * liquidatorGate: "0x0000000000000000000000000000000000000000",
143
+ * },
144
+ * totalUnits: 1_000n,
145
+ * lossFactor: 0n,
146
+ * withdrawable: 500n,
147
+ * continuousFeeCredit: 0n,
148
+ * settlementFeeCbps: [1, 2, 3, 4, 5, 6, 7],
149
+ * continuousFee: 10,
150
+ * tickSpacing: 4,
151
+ * },
152
+ * );
153
+ * console.log(position.market.id);
154
+ * ```
155
+ */
156
+ export declare class AccrualPosition extends Position {
157
+ /** Hydrated market for this position. */
158
+ readonly market: Market;
159
+ constructor(position: IPosition, market: IMarket);
160
+ /**
161
+ * Returns the position collateral balance at an index configured by the market.
162
+ *
163
+ * @param index - Collateral index.
164
+ * @returns Collateral balance, or undefined when the index is not configured.
165
+ * @example
166
+ * ```ts
167
+ * import { registerCustomAddresses } from "@morpho-org/morpho-ts";
168
+ * import { AccrualPosition } from "@morpho-org/midnight-sdk";
169
+ *
170
+ * registerCustomAddresses({
171
+ * addresses: {
172
+ * 31337: {
173
+ * morpho: "0x0000000000000000000000000000000000000001",
174
+ * bundler3: {
175
+ * bundler3: "0x0000000000000000000000000000000000000002",
176
+ * generalAdapter1: "0x0000000000000000000000000000000000000003",
177
+ * },
178
+ * adaptiveCurveIrm: "0x0000000000000000000000000000000000000004",
179
+ * midnight: "0x0000000000000000000000000000000000001000",
180
+ * },
181
+ * },
182
+ * });
183
+ *
184
+ * const position = new AccrualPosition(
185
+ * {
186
+ * credit: 1_000n,
187
+ * pendingFee: 100n,
188
+ * lastLossFactor: 0n,
189
+ * lastAccrual: 1_000n,
190
+ * debt: 0n,
191
+ * collateralBitmap: 1n,
192
+ * collateral: [50n],
193
+ * },
194
+ * {
195
+ * chainId: 31337,
196
+ * params: {
197
+ * loanToken: "0x0000000000000000000000000000000000006000",
198
+ * collateralParams: [
199
+ * {
200
+ * token: "0x0000000000000000000000000000000000007000",
201
+ * lltv: 770000000000000000n,
202
+ * maxLif: 1061007957559681697n,
203
+ * oracle: "0x0000000000000000000000000000000000008000",
204
+ * },
205
+ * ],
206
+ * maturity: 54_000n,
207
+ * rcfThreshold: 0n,
208
+ * enterGate: "0x0000000000000000000000000000000000000000",
209
+ * liquidatorGate: "0x0000000000000000000000000000000000000000",
210
+ * },
211
+ * totalUnits: 1_000n,
212
+ * lossFactor: 0n,
213
+ * withdrawable: 500n,
214
+ * continuousFeeCredit: 0n,
215
+ * settlementFeeCbps: [1, 2, 3, 4, 5, 6, 7],
216
+ * continuousFee: 10,
217
+ * tickSpacing: 4,
218
+ * },
219
+ * );
220
+ * const balance = position.getCollateralBalanceByIndex(0);
221
+ * console.log(balance);
222
+ * ```
223
+ */
224
+ getCollateralBalanceByIndex(index: BigIntish): bigint | undefined;
225
+ /**
226
+ * Returns the position collateral balance for a configured token.
227
+ *
228
+ * @param token - Collateral token address.
229
+ * @returns Collateral balance, or undefined when the token is not configured.
230
+ * @example
231
+ * ```ts
232
+ * import { registerCustomAddresses } from "@morpho-org/morpho-ts";
233
+ * import { AccrualPosition } from "@morpho-org/midnight-sdk";
234
+ *
235
+ * registerCustomAddresses({
236
+ * addresses: {
237
+ * 31337: {
238
+ * morpho: "0x0000000000000000000000000000000000000001",
239
+ * bundler3: {
240
+ * bundler3: "0x0000000000000000000000000000000000000002",
241
+ * generalAdapter1: "0x0000000000000000000000000000000000000003",
242
+ * },
243
+ * adaptiveCurveIrm: "0x0000000000000000000000000000000000000004",
244
+ * midnight: "0x0000000000000000000000000000000000001000",
245
+ * },
246
+ * },
247
+ * });
248
+ *
249
+ * const collateralToken = "0x0000000000000000000000000000000000007000";
250
+ * const position = new AccrualPosition(
251
+ * {
252
+ * credit: 1_000n,
253
+ * pendingFee: 100n,
254
+ * lastLossFactor: 0n,
255
+ * lastAccrual: 1_000n,
256
+ * debt: 0n,
257
+ * collateralBitmap: 1n,
258
+ * collateral: [50n],
259
+ * },
260
+ * {
261
+ * chainId: 31337,
262
+ * params: {
263
+ * loanToken: "0x0000000000000000000000000000000000006000",
264
+ * collateralParams: [
265
+ * {
266
+ * token: collateralToken,
267
+ * lltv: 770000000000000000n,
268
+ * maxLif: 1061007957559681697n,
269
+ * oracle: "0x0000000000000000000000000000000000008000",
270
+ * },
271
+ * ],
272
+ * maturity: 54_000n,
273
+ * rcfThreshold: 0n,
274
+ * enterGate: "0x0000000000000000000000000000000000000000",
275
+ * liquidatorGate: "0x0000000000000000000000000000000000000000",
276
+ * },
277
+ * totalUnits: 1_000n,
278
+ * lossFactor: 0n,
279
+ * withdrawable: 500n,
280
+ * continuousFeeCredit: 0n,
281
+ * settlementFeeCbps: [1, 2, 3, 4, 5, 6, 7],
282
+ * continuousFee: 10,
283
+ * tickSpacing: 4,
284
+ * },
285
+ * );
286
+ * const balance = position.getCollateralBalanceByToken(collateralToken);
287
+ * console.log(balance);
288
+ * ```
289
+ */
290
+ getCollateralBalanceByToken(token: Address): bigint | undefined;
291
+ /**
292
+ * Returns the market settlement fee at a timestamp.
293
+ *
294
+ * @param timestamp - Timestamp used to compute time to maturity.
295
+ * @returns WAD-scaled settlement fee.
296
+ * @example
297
+ * ```ts
298
+ * import { registerCustomAddresses } from "@morpho-org/morpho-ts";
299
+ * import { AccrualPosition } from "@morpho-org/midnight-sdk";
300
+ *
301
+ * registerCustomAddresses({
302
+ * addresses: {
303
+ * 31337: {
304
+ * morpho: "0x0000000000000000000000000000000000000001",
305
+ * bundler3: {
306
+ * bundler3: "0x0000000000000000000000000000000000000002",
307
+ * generalAdapter1: "0x0000000000000000000000000000000000000003",
308
+ * },
309
+ * adaptiveCurveIrm: "0x0000000000000000000000000000000000000004",
310
+ * midnight: "0x0000000000000000000000000000000000001000",
311
+ * },
312
+ * },
313
+ * });
314
+ *
315
+ * const position = new AccrualPosition(
316
+ * {
317
+ * credit: 1_000n,
318
+ * pendingFee: 100n,
319
+ * lastLossFactor: 0n,
320
+ * lastAccrual: 1_000n,
321
+ * debt: 0n,
322
+ * collateralBitmap: 1n,
323
+ * collateral: [50n],
324
+ * },
325
+ * {
326
+ * chainId: 31337,
327
+ * params: {
328
+ * loanToken: "0x0000000000000000000000000000000000006000",
329
+ * collateralParams: [
330
+ * {
331
+ * token: "0x0000000000000000000000000000000000007000",
332
+ * lltv: 770000000000000000n,
333
+ * maxLif: 1061007957559681697n,
334
+ * oracle: "0x0000000000000000000000000000000000008000",
335
+ * },
336
+ * ],
337
+ * maturity: 54_000n,
338
+ * rcfThreshold: 0n,
339
+ * enterGate: "0x0000000000000000000000000000000000000000",
340
+ * liquidatorGate: "0x0000000000000000000000000000000000000000",
341
+ * },
342
+ * totalUnits: 1_000n,
343
+ * lossFactor: 0n,
344
+ * withdrawable: 500n,
345
+ * continuousFeeCredit: 0n,
346
+ * settlementFeeCbps: [1, 2, 3, 4, 5, 6, 7],
347
+ * continuousFee: 10,
348
+ * tickSpacing: 4,
349
+ * },
350
+ * );
351
+ * const fee = position.getSettlementFee(0n);
352
+ * console.log(fee);
353
+ * ```
354
+ */
355
+ getSettlementFee(timestamp: BigIntish): bigint;
356
+ /**
357
+ * Returns a new position locally accrued like Midnight `updatePositionView`.
358
+ *
359
+ * @param timestamp - Timestamp at which to accrue. Must be greater than or equal to `lastAccrual`.
360
+ * @returns New accrual position with updated credit, pending fee, last loss factor, last accrual, and market continuous-fee credit.
361
+ * @throws {InvalidPositionAccrualTimestampError} when timestamp is before `lastAccrual`.
362
+ * @throws {InvalidPositionLossFactorError} when the market loss factor is older than the position loss factor.
363
+ * @throws {InvalidPositionAccrualStateError} when raw inputs violate Midnight accounting invariants.
364
+ * @example
365
+ * ```ts
366
+ * import { registerCustomAddresses } from "@morpho-org/morpho-ts";
367
+ * import { AccrualPosition } from "@morpho-org/midnight-sdk";
368
+ *
369
+ * registerCustomAddresses({
370
+ * addresses: {
371
+ * 31337: {
372
+ * morpho: "0x0000000000000000000000000000000000000001",
373
+ * bundler3: {
374
+ * bundler3: "0x0000000000000000000000000000000000000002",
375
+ * generalAdapter1: "0x0000000000000000000000000000000000000003",
376
+ * },
377
+ * adaptiveCurveIrm: "0x0000000000000000000000000000000000000004",
378
+ * midnight: "0x0000000000000000000000000000000000001000",
379
+ * },
380
+ * },
381
+ * });
382
+ *
383
+ * const position = new AccrualPosition(
384
+ * {
385
+ * credit: 1_000n,
386
+ * pendingFee: 100n,
387
+ * lastLossFactor: 0n,
388
+ * lastAccrual: 1_000n,
389
+ * debt: 0n,
390
+ * collateralBitmap: 1n,
391
+ * collateral: [50n],
392
+ * },
393
+ * {
394
+ * chainId: 31337,
395
+ * params: {
396
+ * loanToken: "0x0000000000000000000000000000000000006000",
397
+ * collateralParams: [
398
+ * {
399
+ * token: "0x0000000000000000000000000000000000007000",
400
+ * lltv: 770000000000000000n,
401
+ * maxLif: 1061007957559681697n,
402
+ * oracle: "0x0000000000000000000000000000000000008000",
403
+ * },
404
+ * ],
405
+ * maturity: 54_000n,
406
+ * rcfThreshold: 0n,
407
+ * enterGate: "0x0000000000000000000000000000000000000000",
408
+ * liquidatorGate: "0x0000000000000000000000000000000000000000",
409
+ * },
410
+ * totalUnits: 1_000n,
411
+ * lossFactor: 0n,
412
+ * withdrawable: 500n,
413
+ * continuousFeeCredit: 0n,
414
+ * settlementFeeCbps: [1, 2, 3, 4, 5, 6, 7],
415
+ * continuousFee: 10,
416
+ * tickSpacing: 4,
417
+ * },
418
+ * );
419
+ * const accrued = position.accrueInterest(1_500n);
420
+ * console.log(accrued.credit);
421
+ * ```
422
+ */
423
+ accrueInterest(timestamp: BigIntish): AccrualPosition;
424
+ }