@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.
- package/README.md +252 -0
- package/lib/cjs/abis.d.ts +3170 -0
- package/lib/cjs/abis.js +4073 -0
- package/lib/cjs/api/MidnightApi.d.ts +532 -0
- package/lib/cjs/api/MidnightApi.js +713 -0
- package/lib/cjs/api/helpers.d.ts +20 -0
- package/lib/cjs/api/helpers.js +189 -0
- package/lib/cjs/api/index.d.ts +2 -0
- package/lib/cjs/api/index.js +21 -0
- package/lib/cjs/api/types.d.ts +453 -0
- package/lib/cjs/api/types.js +2 -0
- package/lib/cjs/constants.d.ts +168 -0
- package/lib/cjs/constants.js +187 -0
- package/lib/cjs/errors.d.ts +253 -0
- package/lib/cjs/errors.js +309 -0
- package/lib/cjs/fetch/Market.d.ts +65 -0
- package/lib/cjs/fetch/Market.js +117 -0
- package/lib/cjs/fetch/Offer.d.ts +74 -0
- package/lib/cjs/fetch/Offer.js +119 -0
- package/lib/cjs/fetch/Position.d.ts +85 -0
- package/lib/cjs/fetch/Position.js +148 -0
- package/lib/cjs/fetch/Ratifier.d.ts +38 -0
- package/lib/cjs/fetch/Ratifier.js +57 -0
- package/lib/cjs/fetch/index.d.ts +5 -0
- package/lib/cjs/fetch/index.js +21 -0
- package/lib/cjs/fetch/types.d.ts +57 -0
- package/lib/cjs/fetch/types.js +2 -0
- package/lib/cjs/fetch/utils.d.ts +8 -0
- package/lib/cjs/fetch/utils.js +18 -0
- package/lib/cjs/index.d.ts +18 -0
- package/lib/cjs/index.js +57 -0
- package/lib/cjs/market/Market.d.ts +613 -0
- package/lib/cjs/market/Market.js +503 -0
- package/lib/cjs/market/MarketUtils.d.ts +189 -0
- package/lib/cjs/market/MarketUtils.js +303 -0
- package/lib/cjs/market/Position.d.ts +424 -0
- package/lib/cjs/market/Position.js +425 -0
- package/lib/cjs/market/PositionUtils.d.ts +115 -0
- package/lib/cjs/market/PositionUtils.js +194 -0
- package/lib/cjs/market/index.d.ts +4 -0
- package/lib/cjs/market/index.js +20 -0
- package/lib/cjs/math/ConsumableUnitsLib.d.ts +57 -0
- package/lib/cjs/math/ConsumableUnitsLib.js +77 -0
- package/lib/cjs/math/TakeAmountsLib.d.ts +175 -0
- package/lib/cjs/math/TakeAmountsLib.js +199 -0
- package/lib/cjs/math/TickLib.d.ts +200 -0
- package/lib/cjs/math/TickLib.js +272 -0
- package/lib/cjs/math/index.d.ts +3 -0
- package/lib/cjs/math/index.js +19 -0
- package/lib/cjs/offers/Offer.d.ts +534 -0
- package/lib/cjs/offers/Offer.js +343 -0
- package/lib/cjs/offers/OfferUtils.d.ts +565 -0
- package/lib/cjs/offers/OfferUtils.js +659 -0
- package/lib/cjs/offers/index.d.ts +2 -0
- package/lib/cjs/offers/index.js +18 -0
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/queries/GetPosition.d.ts +55 -0
- package/lib/cjs/queries/GetPosition.js +74 -0
- package/lib/cjs/queries/index.d.ts +1 -0
- package/lib/cjs/queries/index.js +37 -0
- package/lib/cjs/signatures/EcrecoverRatifierUtils.d.ts +733 -0
- package/lib/cjs/signatures/EcrecoverRatifierUtils.js +618 -0
- package/lib/cjs/signatures/Group.d.ts +178 -0
- package/lib/cjs/signatures/Group.js +193 -0
- package/lib/cjs/signatures/GroupUtils.d.ts +191 -0
- package/lib/cjs/signatures/GroupUtils.js +127 -0
- package/lib/cjs/signatures/Payload.d.ts +283 -0
- package/lib/cjs/signatures/Payload.js +570 -0
- package/lib/cjs/signatures/RatifierUtils.d.ts +109 -0
- package/lib/cjs/signatures/RatifierUtils.js +76 -0
- package/lib/cjs/signatures/SetterRatifierUtils.d.ts +243 -0
- package/lib/cjs/signatures/SetterRatifierUtils.js +217 -0
- package/lib/cjs/signatures/Tree.d.ts +241 -0
- package/lib/cjs/signatures/Tree.js +263 -0
- package/lib/cjs/signatures/TreeUtils.d.ts +573 -0
- package/lib/cjs/signatures/TreeUtils.js +461 -0
- package/lib/cjs/signatures/index.d.ts +7 -0
- package/lib/cjs/signatures/index.js +23 -0
- package/lib/esm/abis.d.ts +3170 -0
- package/lib/esm/abis.js +4070 -0
- package/lib/esm/api/MidnightApi.d.ts +532 -0
- package/lib/esm/api/MidnightApi.js +709 -0
- package/lib/esm/api/helpers.d.ts +20 -0
- package/lib/esm/api/helpers.js +180 -0
- package/lib/esm/api/index.d.ts +2 -0
- package/lib/esm/api/index.js +2 -0
- package/lib/esm/api/types.d.ts +453 -0
- package/lib/esm/api/types.js +1 -0
- package/lib/esm/constants.d.ts +168 -0
- package/lib/esm/constants.js +184 -0
- package/lib/esm/errors.d.ts +253 -0
- package/lib/esm/errors.js +291 -0
- package/lib/esm/fetch/Market.d.ts +65 -0
- package/lib/esm/fetch/Market.js +113 -0
- package/lib/esm/fetch/Offer.d.ts +74 -0
- package/lib/esm/fetch/Offer.js +116 -0
- package/lib/esm/fetch/Position.d.ts +85 -0
- package/lib/esm/fetch/Position.js +144 -0
- package/lib/esm/fetch/Ratifier.d.ts +38 -0
- package/lib/esm/fetch/Ratifier.js +54 -0
- package/lib/esm/fetch/index.d.ts +5 -0
- package/lib/esm/fetch/index.js +5 -0
- package/lib/esm/fetch/types.d.ts +57 -0
- package/lib/esm/fetch/types.js +1 -0
- package/lib/esm/fetch/utils.d.ts +8 -0
- package/lib/esm/fetch/utils.js +12 -0
- package/lib/esm/index.d.ts +18 -0
- package/lib/esm/index.js +18 -0
- package/lib/esm/market/Market.d.ts +613 -0
- package/lib/esm/market/Market.js +498 -0
- package/lib/esm/market/MarketUtils.d.ts +189 -0
- package/lib/esm/market/MarketUtils.js +300 -0
- package/lib/esm/market/Position.d.ts +424 -0
- package/lib/esm/market/Position.js +420 -0
- package/lib/esm/market/PositionUtils.d.ts +115 -0
- package/lib/esm/market/PositionUtils.js +191 -0
- package/lib/esm/market/index.d.ts +4 -0
- package/lib/esm/market/index.js +4 -0
- package/lib/esm/math/ConsumableUnitsLib.d.ts +57 -0
- package/lib/esm/math/ConsumableUnitsLib.js +74 -0
- package/lib/esm/math/TakeAmountsLib.d.ts +175 -0
- package/lib/esm/math/TakeAmountsLib.js +196 -0
- package/lib/esm/math/TickLib.d.ts +200 -0
- package/lib/esm/math/TickLib.js +269 -0
- package/lib/esm/math/index.d.ts +3 -0
- package/lib/esm/math/index.js +3 -0
- package/lib/esm/offers/Offer.d.ts +534 -0
- package/lib/esm/offers/Offer.js +339 -0
- package/lib/esm/offers/OfferUtils.d.ts +565 -0
- package/lib/esm/offers/OfferUtils.js +656 -0
- package/lib/esm/offers/index.d.ts +2 -0
- package/lib/esm/offers/index.js +2 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/queries/GetPosition.d.ts +55 -0
- package/lib/esm/queries/GetPosition.js +71 -0
- package/lib/esm/queries/index.d.ts +1 -0
- package/lib/esm/queries/index.js +1 -0
- package/lib/esm/signatures/EcrecoverRatifierUtils.d.ts +733 -0
- package/lib/esm/signatures/EcrecoverRatifierUtils.js +615 -0
- package/lib/esm/signatures/Group.d.ts +178 -0
- package/lib/esm/signatures/Group.js +189 -0
- package/lib/esm/signatures/GroupUtils.d.ts +191 -0
- package/lib/esm/signatures/GroupUtils.js +124 -0
- package/lib/esm/signatures/Payload.d.ts +283 -0
- package/lib/esm/signatures/Payload.js +564 -0
- package/lib/esm/signatures/RatifierUtils.d.ts +109 -0
- package/lib/esm/signatures/RatifierUtils.js +73 -0
- package/lib/esm/signatures/SetterRatifierUtils.d.ts +243 -0
- package/lib/esm/signatures/SetterRatifierUtils.js +214 -0
- package/lib/esm/signatures/Tree.d.ts +241 -0
- package/lib/esm/signatures/Tree.js +259 -0
- package/lib/esm/signatures/TreeUtils.d.ts +573 -0
- package/lib/esm/signatures/TreeUtils.js +458 -0
- package/lib/esm/signatures/index.d.ts +7 -0
- package/lib/esm/signatures/index.js +7 -0
- package/package.json +69 -0
- package/src/index.ts +19 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a Midnight offer group violates protocol-level group mechanics.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { InvalidOfferGroupError } from "@morpho-org/midnight-sdk";
|
|
7
|
+
*
|
|
8
|
+
* throw new InvalidOfferGroupError("All offers in a group must use the same maker.");
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export class InvalidOfferGroupError extends Error {
|
|
12
|
+
constructor(reason) {
|
|
13
|
+
super(`Invalid Midnight offer group. ${reason}`);
|
|
14
|
+
this.name = "InvalidOfferGroupError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Thrown when a tick exceeds the deployed TickLib range.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { TickOutOfRangeError } from "@morpho-org/midnight-sdk";
|
|
23
|
+
*
|
|
24
|
+
* const error = new TickOutOfRangeError(7000n, 6744n);
|
|
25
|
+
* console.log(error.message);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export class TickOutOfRangeError extends Error {
|
|
29
|
+
constructor(tick, maxTick) {
|
|
30
|
+
super(`Tick "${tick}" exceeds maximum tick "${maxTick}".`);
|
|
31
|
+
this.name = "TickOutOfRangeError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Thrown when a price is above the maximum WAD price accepted by TickLib.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { PriceGreaterThanOneError } from "@morpho-org/midnight-sdk";
|
|
40
|
+
*
|
|
41
|
+
* throw new PriceGreaterThanOneError(2n * 10n ** 18n);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export class PriceGreaterThanOneError extends Error {
|
|
45
|
+
constructor(price) {
|
|
46
|
+
super(`Price "${price}" is greater than WAD.`);
|
|
47
|
+
this.name = "PriceGreaterThanOneError";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Thrown when tick spacing is invalid or a tick is not aligned to it.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { InvalidTickSpacingError } from "@morpho-org/midnight-sdk";
|
|
56
|
+
*
|
|
57
|
+
* throw new InvalidTickSpacingError(5n, 4n);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export class InvalidTickSpacingError extends Error {
|
|
61
|
+
constructor(tickOrSpacing, spacing) {
|
|
62
|
+
super(spacing == null
|
|
63
|
+
? `Tick spacing "${tickOrSpacing}" is invalid. Use a positive spacing that divides the maximum tick.`
|
|
64
|
+
: `Tick "${tickOrSpacing}" is not aligned to spacing "${spacing}". Use a tick aligned to the market spacing.`);
|
|
65
|
+
this.name = "InvalidTickSpacingError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Thrown when a buy offer's settlement fee exceeds its tick price.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { SettlementFeeExceedsPriceError } from "@morpho-org/midnight-sdk";
|
|
74
|
+
*
|
|
75
|
+
* throw new SettlementFeeExceedsPriceError(10n, 9n);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export class SettlementFeeExceedsPriceError extends Error {
|
|
79
|
+
constructor(settlementFee, price) {
|
|
80
|
+
super(`Settlement fee "${settlementFee}" exceeds offer price "${price}". Use a lower fee or a higher tick.`);
|
|
81
|
+
this.name = "SettlementFeeExceedsPriceError";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Thrown when a local position accrual is requested for an impossible timestamp.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { InvalidPositionAccrualTimestampError } from "@morpho-org/midnight-sdk";
|
|
90
|
+
*
|
|
91
|
+
* throw new InvalidPositionAccrualTimestampError(1n, 2n);
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export class InvalidPositionAccrualTimestampError extends Error {
|
|
95
|
+
constructor(timestamp, lastAccrual) {
|
|
96
|
+
super(`Position accrual timestamp "${timestamp}" is before last accrual "${lastAccrual}". Use a timestamp greater than or equal to last accrual.`);
|
|
97
|
+
this.name = "InvalidPositionAccrualTimestampError";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Thrown when a local position accrual sees a market loss factor older than the position.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { InvalidPositionLossFactorError } from "@morpho-org/midnight-sdk";
|
|
106
|
+
*
|
|
107
|
+
* throw new InvalidPositionLossFactorError(1n, 2n);
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export class InvalidPositionLossFactorError extends Error {
|
|
111
|
+
constructor(marketLossFactor, positionLossFactor) {
|
|
112
|
+
super(`Market loss factor "${marketLossFactor}" is below position loss factor "${positionLossFactor}". Fetch a consistent market and position at the same block.`);
|
|
113
|
+
this.name = "InvalidPositionLossFactorError";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Thrown when local position accrual inputs violate Midnight accounting invariants.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { InvalidPositionAccrualStateError } from "@morpho-org/midnight-sdk";
|
|
122
|
+
*
|
|
123
|
+
* throw new InvalidPositionAccrualStateError("Pending fee exceeds credit.");
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export class InvalidPositionAccrualStateError extends Error {
|
|
127
|
+
constructor(reason) {
|
|
128
|
+
super(`Invalid Midnight position accrual state. ${reason}`);
|
|
129
|
+
this.name = "InvalidPositionAccrualStateError";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Thrown when a market parameter cannot satisfy Midnight protocol rules.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* import { InvalidMarketParameterError } from "@morpho-org/midnight-sdk";
|
|
138
|
+
*
|
|
139
|
+
* throw new InvalidMarketParameterError({
|
|
140
|
+
* parameter: "collateralParams",
|
|
141
|
+
* value: 0,
|
|
142
|
+
* instruction: "Provide at least one collateral.",
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
* @param params.parameter - Invalid market parameter name.
|
|
146
|
+
* @param params.value - Invalid market parameter value.
|
|
147
|
+
* @param params.instruction - Optional instruction appended to the error message.
|
|
148
|
+
* @param params.cause - Optional wrapped cause.
|
|
149
|
+
*/
|
|
150
|
+
export class InvalidMarketParameterError extends Error {
|
|
151
|
+
/** Invalid market parameter name. */
|
|
152
|
+
parameter;
|
|
153
|
+
/** Invalid market parameter value. */
|
|
154
|
+
value;
|
|
155
|
+
constructor(params) {
|
|
156
|
+
super(`Invalid market parameter "${params.parameter}" with value "${String(params.value)}".${params.instruction == null ? "" : ` ${params.instruction}`}`, params.cause === undefined ? undefined : { cause: params.cause });
|
|
157
|
+
this.name = "InvalidMarketParameterError";
|
|
158
|
+
this.parameter = params.parameter;
|
|
159
|
+
this.value = params.value;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Thrown when an offer builder receives a parameter that cannot satisfy Midnight protocol rules.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { InvalidOfferParameterError } from "@morpho-org/midnight-sdk";
|
|
168
|
+
*
|
|
169
|
+
* throw new InvalidOfferParameterError({ parameter: "tick", value: 5821n });
|
|
170
|
+
* ```
|
|
171
|
+
* @param params.parameter - Invalid offer parameter name.
|
|
172
|
+
* @param params.value - Invalid offer parameter value.
|
|
173
|
+
* @param params.instruction - Optional instruction appended to the error message.
|
|
174
|
+
* @param params.cause - Optional wrapped cause.
|
|
175
|
+
*/
|
|
176
|
+
export class InvalidOfferParameterError extends Error {
|
|
177
|
+
/** Invalid offer parameter name. */
|
|
178
|
+
parameter;
|
|
179
|
+
/** Invalid offer parameter value. */
|
|
180
|
+
value;
|
|
181
|
+
constructor(params) {
|
|
182
|
+
super(`Invalid offer parameter "${params.parameter}" with value "${String(params.value)}".${params.instruction == null ? "" : ` ${params.instruction}`}`, params.cause === undefined ? undefined : { cause: params.cause });
|
|
183
|
+
this.name = "InvalidOfferParameterError";
|
|
184
|
+
this.parameter = params.parameter;
|
|
185
|
+
this.value = params.value;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Thrown when a tree height exceeds the ratifier typehash table.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* import { InvalidTreeHeightError } from "@morpho-org/midnight-sdk";
|
|
194
|
+
*
|
|
195
|
+
* throw new InvalidTreeHeightError(21);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export class InvalidTreeHeightError extends Error {
|
|
199
|
+
constructor(height) {
|
|
200
|
+
super(`Tree height "${height}" is not supported.`);
|
|
201
|
+
this.name = "InvalidTreeHeightError";
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Thrown when a tree cannot be represented by the ratifiers.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* import { InvalidTreeError } from "@morpho-org/midnight-sdk";
|
|
210
|
+
*
|
|
211
|
+
* throw new InvalidTreeError("Tree must not be empty.");
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
export class InvalidTreeError extends Error {
|
|
215
|
+
constructor(message) {
|
|
216
|
+
super(message);
|
|
217
|
+
this.name = "InvalidTreeError";
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Thrown when a typed-data signature does not recover to the expected signer.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* import { InvalidTypedDataSignatureError } from "@morpho-org/midnight-sdk";
|
|
226
|
+
*
|
|
227
|
+
* throw new InvalidTypedDataSignatureError(
|
|
228
|
+
* "0x0000000000000000000000000000000000000001",
|
|
229
|
+
* );
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export class InvalidTypedDataSignatureError extends Error {
|
|
233
|
+
/** Signer address the signature was expected to recover. */
|
|
234
|
+
signer;
|
|
235
|
+
constructor(signer) {
|
|
236
|
+
super(`Typed-data signature does not recover to signer "${signer}". Check the wallet account or signing transport.`);
|
|
237
|
+
this.name = "InvalidTypedDataSignatureError";
|
|
238
|
+
this.signer = signer;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Thrown when the Midnight API returns a non-2xx response.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* import { MidnightApiError } from "@morpho-org/midnight-sdk/api";
|
|
247
|
+
*
|
|
248
|
+
* throw new MidnightApiError({
|
|
249
|
+
* status: 400,
|
|
250
|
+
* code: "BAD_REQUEST",
|
|
251
|
+
* message: "Limit must be greater than 0.",
|
|
252
|
+
* details: [{ field: "limit", issue: "Limit must be greater than 0." }],
|
|
253
|
+
* requestId: "req-123",
|
|
254
|
+
* });
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
export class MidnightApiError extends Error {
|
|
258
|
+
/** HTTP response status from the API. */
|
|
259
|
+
status;
|
|
260
|
+
/** API error code, when the response body includes one. */
|
|
261
|
+
code;
|
|
262
|
+
/** API error details, when the response body includes them. */
|
|
263
|
+
details;
|
|
264
|
+
/** API request id, when the response body includes one. */
|
|
265
|
+
requestId;
|
|
266
|
+
constructor(params) {
|
|
267
|
+
super(params.message ??
|
|
268
|
+
`Midnight API request failed with HTTP status "${params.status}".`, params.cause === undefined ? undefined : { cause: params.cause });
|
|
269
|
+
this.name = "MidnightApiError";
|
|
270
|
+
this.status = params.status;
|
|
271
|
+
this.code = params.code;
|
|
272
|
+
this.details = params.details;
|
|
273
|
+
this.requestId = params.requestId;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Thrown when the Midnight API returns a malformed successful response.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* import { InvalidMidnightApiResponseError } from "@morpho-org/midnight-sdk/api";
|
|
282
|
+
*
|
|
283
|
+
* throw new InvalidMidnightApiResponseError("API response is missing data.");
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
export class InvalidMidnightApiResponseError extends Error {
|
|
287
|
+
constructor(message, options) {
|
|
288
|
+
super(message, options);
|
|
289
|
+
this.name = "InvalidMidnightApiResponseError";
|
|
290
|
+
}
|
|
291
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Client, Hash } from "viem";
|
|
2
|
+
import { Market, MarketParams } from "../market/index.js";
|
|
3
|
+
import type { MidnightFetchParams } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Fetches immutable market params by id.
|
|
6
|
+
*
|
|
7
|
+
* Reads `eth_chainId` only when the viem client has no configured chain id,
|
|
8
|
+
* then reads `Midnight.toMarket(marketId)`.
|
|
9
|
+
*
|
|
10
|
+
* @param client - Viem client used for the read.
|
|
11
|
+
* @param params.marketId - Market id whose immutable params to read.
|
|
12
|
+
* @param params.account - Optional account used as the `from` field for the read.
|
|
13
|
+
* @param params.blockNumber - Optional block number used for the read.
|
|
14
|
+
* @param params.blockTag - Optional block tag used for the read.
|
|
15
|
+
* @param params.stateOverride - Optional state override set used for the read.
|
|
16
|
+
* @returns Market params instance.
|
|
17
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the client chain id.
|
|
18
|
+
* @throws {UnknownAddressError} when the registry has no Midnight address for the client chain id.
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { fetchMarketParams } from "@morpho-org/midnight-sdk";
|
|
22
|
+
* import { createPublicClient, http } from "viem";
|
|
23
|
+
* import { base } from "viem/chains";
|
|
24
|
+
*
|
|
25
|
+
* const client = createPublicClient({ chain: base, transport: http() });
|
|
26
|
+
* const params = await fetchMarketParams(client, {
|
|
27
|
+
* marketId: "0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",
|
|
28
|
+
* });
|
|
29
|
+
* console.log(params.loanToken);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function fetchMarketParams(client: Client, params: MidnightFetchParams & {
|
|
33
|
+
readonly marketId: Hash;
|
|
34
|
+
}): Promise<MarketParams>;
|
|
35
|
+
/**
|
|
36
|
+
* Fetches a hydrated market by id.
|
|
37
|
+
*
|
|
38
|
+
* Reads `eth_chainId` only when the viem client has no configured chain id,
|
|
39
|
+
* then reads `Midnight.toMarket(marketId)` and `Midnight.marketState(marketId)`.
|
|
40
|
+
*
|
|
41
|
+
* @param client - Viem client used for the reads.
|
|
42
|
+
* @param params.marketId - Market id whose hydrated market state to read.
|
|
43
|
+
* @param params.account - Optional account used as the `from` field for the reads.
|
|
44
|
+
* @param params.blockNumber - Optional block number used for the reads.
|
|
45
|
+
* @param params.blockTag - Optional block tag used for the reads.
|
|
46
|
+
* @param params.stateOverride - Optional state override set used for the reads.
|
|
47
|
+
* @returns Market instance.
|
|
48
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the client chain id.
|
|
49
|
+
* @throws {UnknownAddressError} when the registry has no Midnight address for the client chain id.
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { fetchMarket } from "@morpho-org/midnight-sdk";
|
|
53
|
+
* import { createPublicClient, http } from "viem";
|
|
54
|
+
* import { base } from "viem/chains";
|
|
55
|
+
*
|
|
56
|
+
* const client = createPublicClient({ chain: base, transport: http() });
|
|
57
|
+
* const market = await fetchMarket(client, {
|
|
58
|
+
* marketId: "0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",
|
|
59
|
+
* });
|
|
60
|
+
* console.log(market.params.loanToken);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function fetchMarket(client: Client, params: MidnightFetchParams & {
|
|
64
|
+
readonly marketId: Hash;
|
|
65
|
+
}): Promise<Market>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { getChainAddress } from "@morpho-org/morpho-ts";
|
|
2
|
+
import { readContract } from "viem/actions";
|
|
3
|
+
import { midnightAbi } from "../abis.js";
|
|
4
|
+
import { Market, MarketParams } from "../market/index.js";
|
|
5
|
+
import { callParameters, resolveChainId } from "./utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* Fetches immutable market params by id.
|
|
8
|
+
*
|
|
9
|
+
* Reads `eth_chainId` only when the viem client has no configured chain id,
|
|
10
|
+
* then reads `Midnight.toMarket(marketId)`.
|
|
11
|
+
*
|
|
12
|
+
* @param client - Viem client used for the read.
|
|
13
|
+
* @param params.marketId - Market id whose immutable params to read.
|
|
14
|
+
* @param params.account - Optional account used as the `from` field for the read.
|
|
15
|
+
* @param params.blockNumber - Optional block number used for the read.
|
|
16
|
+
* @param params.blockTag - Optional block tag used for the read.
|
|
17
|
+
* @param params.stateOverride - Optional state override set used for the read.
|
|
18
|
+
* @returns Market params instance.
|
|
19
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the client chain id.
|
|
20
|
+
* @throws {UnknownAddressError} when the registry has no Midnight address for the client chain id.
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { fetchMarketParams } from "@morpho-org/midnight-sdk";
|
|
24
|
+
* import { createPublicClient, http } from "viem";
|
|
25
|
+
* import { base } from "viem/chains";
|
|
26
|
+
*
|
|
27
|
+
* const client = createPublicClient({ chain: base, transport: http() });
|
|
28
|
+
* const params = await fetchMarketParams(client, {
|
|
29
|
+
* marketId: "0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",
|
|
30
|
+
* });
|
|
31
|
+
* console.log(params.loanToken);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export async function fetchMarketParams(client, params) {
|
|
35
|
+
const chainId = await resolveChainId(client);
|
|
36
|
+
const midnight = getChainAddress(chainId, "midnight");
|
|
37
|
+
const market = await readContract(client, {
|
|
38
|
+
...callParameters(params),
|
|
39
|
+
address: midnight,
|
|
40
|
+
abi: midnightAbi,
|
|
41
|
+
functionName: "toMarket",
|
|
42
|
+
args: [params.marketId],
|
|
43
|
+
});
|
|
44
|
+
return new MarketParams(market);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fetches a hydrated market by id.
|
|
48
|
+
*
|
|
49
|
+
* Reads `eth_chainId` only when the viem client has no configured chain id,
|
|
50
|
+
* then reads `Midnight.toMarket(marketId)` and `Midnight.marketState(marketId)`.
|
|
51
|
+
*
|
|
52
|
+
* @param client - Viem client used for the reads.
|
|
53
|
+
* @param params.marketId - Market id whose hydrated market state to read.
|
|
54
|
+
* @param params.account - Optional account used as the `from` field for the reads.
|
|
55
|
+
* @param params.blockNumber - Optional block number used for the reads.
|
|
56
|
+
* @param params.blockTag - Optional block tag used for the reads.
|
|
57
|
+
* @param params.stateOverride - Optional state override set used for the reads.
|
|
58
|
+
* @returns Market instance.
|
|
59
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the client chain id.
|
|
60
|
+
* @throws {UnknownAddressError} when the registry has no Midnight address for the client chain id.
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { fetchMarket } from "@morpho-org/midnight-sdk";
|
|
64
|
+
* import { createPublicClient, http } from "viem";
|
|
65
|
+
* import { base } from "viem/chains";
|
|
66
|
+
*
|
|
67
|
+
* const client = createPublicClient({ chain: base, transport: http() });
|
|
68
|
+
* const market = await fetchMarket(client, {
|
|
69
|
+
* marketId: "0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",
|
|
70
|
+
* });
|
|
71
|
+
* console.log(market.params.loanToken);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export async function fetchMarket(client, params) {
|
|
75
|
+
const chainId = await resolveChainId(client);
|
|
76
|
+
const midnight = getChainAddress(chainId, "midnight");
|
|
77
|
+
const [market, state] = await Promise.all([
|
|
78
|
+
readContract(client, {
|
|
79
|
+
...callParameters(params),
|
|
80
|
+
address: midnight,
|
|
81
|
+
abi: midnightAbi,
|
|
82
|
+
functionName: "toMarket",
|
|
83
|
+
args: [params.marketId],
|
|
84
|
+
}),
|
|
85
|
+
readContract(client, {
|
|
86
|
+
...callParameters(params),
|
|
87
|
+
address: midnight,
|
|
88
|
+
abi: midnightAbi,
|
|
89
|
+
functionName: "marketState",
|
|
90
|
+
args: [params.marketId],
|
|
91
|
+
}),
|
|
92
|
+
]);
|
|
93
|
+
const [totalUnits, lossFactor, withdrawable, continuousFeeCredit, settlementFeeCbps0, settlementFeeCbps1, settlementFeeCbps2, settlementFeeCbps3, settlementFeeCbps4, settlementFeeCbps5, settlementFeeCbps6, continuousFee, tickSpacing,] = state;
|
|
94
|
+
return new Market({
|
|
95
|
+
chainId,
|
|
96
|
+
params: new MarketParams(market),
|
|
97
|
+
totalUnits,
|
|
98
|
+
lossFactor,
|
|
99
|
+
withdrawable,
|
|
100
|
+
continuousFeeCredit,
|
|
101
|
+
settlementFeeCbps: [
|
|
102
|
+
settlementFeeCbps0,
|
|
103
|
+
settlementFeeCbps1,
|
|
104
|
+
settlementFeeCbps2,
|
|
105
|
+
settlementFeeCbps3,
|
|
106
|
+
settlementFeeCbps4,
|
|
107
|
+
settlementFeeCbps5,
|
|
108
|
+
settlementFeeCbps6,
|
|
109
|
+
],
|
|
110
|
+
continuousFee,
|
|
111
|
+
tickSpacing,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type BigIntish } from "@morpho-org/morpho-ts";
|
|
2
|
+
import type { Address, Client, Hash } from "viem";
|
|
3
|
+
import type { MidnightFetchParams } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Fetches and computes remaining consumable units for an offer.
|
|
6
|
+
*
|
|
7
|
+
* Unit-capped offers skip settlement-fee lookup, matching the Solidity
|
|
8
|
+
* library's early return. For asset-capped offers, pass the time to maturity
|
|
9
|
+
* for the same block context as the quote.
|
|
10
|
+
*
|
|
11
|
+
* Reads `eth_chainId` only when the viem client has no configured chain id,
|
|
12
|
+
* then reads `Midnight.consumed(offer.maker, group)` and
|
|
13
|
+
* `Midnight.continuousFee(marketId)`. If the offer's continuous fee cap is
|
|
14
|
+
* below the market's current continuous fee, returns zero. For asset-capped
|
|
15
|
+
* offers where `offer.maxUnits` is zero, also reads
|
|
16
|
+
* `Midnight.settlementFee(marketId, timeToMaturity)`.
|
|
17
|
+
*
|
|
18
|
+
* @param client - Viem client used for the reads.
|
|
19
|
+
* @param params.marketId - Market id used for settlement-fee lookup on asset-capped offers.
|
|
20
|
+
* @param params.offer.buy - Whether the maker buys loan assets.
|
|
21
|
+
* @param params.offer.maker - Maker address whose consumed group amount is read.
|
|
22
|
+
* @param params.offer.tick - Offer tick used for asset-to-unit conversion.
|
|
23
|
+
* @param params.offer.maxUnits - Unit cap; when non-zero, settlement-fee lookup is skipped.
|
|
24
|
+
* @param params.offer.maxAssets - Asset cap used when `params.offer.maxUnits` is zero.
|
|
25
|
+
* @param params.offer.continuousFeeCap - Maximum market continuous fee accepted by this offer.
|
|
26
|
+
* @param params.group - Offer group id whose consumed amount is read.
|
|
27
|
+
* @param params.timeToMaturity - Time to maturity used for settlement-fee lookup on asset-capped offers.
|
|
28
|
+
* @param params.account - Optional account used as the `from` field for the reads.
|
|
29
|
+
* @param params.blockNumber - Optional block number used for the reads.
|
|
30
|
+
* @param params.blockTag - Optional block tag used for the reads.
|
|
31
|
+
* @param params.stateOverride - Optional state override set used for the reads.
|
|
32
|
+
* @returns Consumable units.
|
|
33
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the client chain id.
|
|
34
|
+
* @throws {UnknownAddressError} when the registry has no Midnight address for the client chain id.
|
|
35
|
+
* @throws {NegativeValueError} when asset-capped `timeToMaturity`, offer caps, or SDK math inputs are negative.
|
|
36
|
+
* @throws {InvalidOfferParameterError} when offer caps are both zero or both non-zero.
|
|
37
|
+
* @throws {DivisionByZeroError} when the delegated units conversion divides by zero.
|
|
38
|
+
* @throws {SettlementFeeExceedsPriceError} when settlement fee exceeds a buy offer price.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { fetchConsumableUnits } from "@morpho-org/midnight-sdk";
|
|
42
|
+
* import { createPublicClient, http, zeroHash } from "viem";
|
|
43
|
+
* import { base } from "viem/chains";
|
|
44
|
+
*
|
|
45
|
+
* const client = createPublicClient({ chain: base, transport: http() });
|
|
46
|
+
* const units = await fetchConsumableUnits(client, {
|
|
47
|
+
* marketId: "0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",
|
|
48
|
+
* offer: {
|
|
49
|
+
* buy: true,
|
|
50
|
+
* maker: "0x0000000000000000000000000000000000009000",
|
|
51
|
+
* tick: 5_000n,
|
|
52
|
+
* maxUnits: 100n,
|
|
53
|
+
* maxAssets: 0n,
|
|
54
|
+
* continuousFeeCap: 317097919n,
|
|
55
|
+
* },
|
|
56
|
+
* group: zeroHash,
|
|
57
|
+
* timeToMaturity: 3_600n,
|
|
58
|
+
* });
|
|
59
|
+
* console.log(units);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function fetchConsumableUnits(client: Client, params: MidnightFetchParams & {
|
|
63
|
+
readonly marketId: Hash;
|
|
64
|
+
readonly offer: {
|
|
65
|
+
readonly buy: boolean;
|
|
66
|
+
readonly maker: Address;
|
|
67
|
+
readonly tick: BigIntish;
|
|
68
|
+
readonly maxUnits: BigIntish;
|
|
69
|
+
readonly maxAssets: BigIntish;
|
|
70
|
+
readonly continuousFeeCap: BigIntish;
|
|
71
|
+
};
|
|
72
|
+
readonly group: Hash;
|
|
73
|
+
readonly timeToMaturity: BigIntish;
|
|
74
|
+
}): Promise<bigint>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { assertNonNegative, getChainAddress, } from "@morpho-org/morpho-ts";
|
|
2
|
+
import { readContract } from "viem/actions";
|
|
3
|
+
import { midnightAbi } from "../abis.js";
|
|
4
|
+
import { ConsumableUnitsLib } from "../math/index.js";
|
|
5
|
+
import { OfferUtils } from "../offers/index.js";
|
|
6
|
+
import { callParameters, resolveChainId } from "./utils.js";
|
|
7
|
+
/**
|
|
8
|
+
* Fetches and computes remaining consumable units for an offer.
|
|
9
|
+
*
|
|
10
|
+
* Unit-capped offers skip settlement-fee lookup, matching the Solidity
|
|
11
|
+
* library's early return. For asset-capped offers, pass the time to maturity
|
|
12
|
+
* for the same block context as the quote.
|
|
13
|
+
*
|
|
14
|
+
* Reads `eth_chainId` only when the viem client has no configured chain id,
|
|
15
|
+
* then reads `Midnight.consumed(offer.maker, group)` and
|
|
16
|
+
* `Midnight.continuousFee(marketId)`. If the offer's continuous fee cap is
|
|
17
|
+
* below the market's current continuous fee, returns zero. For asset-capped
|
|
18
|
+
* offers where `offer.maxUnits` is zero, also reads
|
|
19
|
+
* `Midnight.settlementFee(marketId, timeToMaturity)`.
|
|
20
|
+
*
|
|
21
|
+
* @param client - Viem client used for the reads.
|
|
22
|
+
* @param params.marketId - Market id used for settlement-fee lookup on asset-capped offers.
|
|
23
|
+
* @param params.offer.buy - Whether the maker buys loan assets.
|
|
24
|
+
* @param params.offer.maker - Maker address whose consumed group amount is read.
|
|
25
|
+
* @param params.offer.tick - Offer tick used for asset-to-unit conversion.
|
|
26
|
+
* @param params.offer.maxUnits - Unit cap; when non-zero, settlement-fee lookup is skipped.
|
|
27
|
+
* @param params.offer.maxAssets - Asset cap used when `params.offer.maxUnits` is zero.
|
|
28
|
+
* @param params.offer.continuousFeeCap - Maximum market continuous fee accepted by this offer.
|
|
29
|
+
* @param params.group - Offer group id whose consumed amount is read.
|
|
30
|
+
* @param params.timeToMaturity - Time to maturity used for settlement-fee lookup on asset-capped offers.
|
|
31
|
+
* @param params.account - Optional account used as the `from` field for the reads.
|
|
32
|
+
* @param params.blockNumber - Optional block number used for the reads.
|
|
33
|
+
* @param params.blockTag - Optional block tag used for the reads.
|
|
34
|
+
* @param params.stateOverride - Optional state override set used for the reads.
|
|
35
|
+
* @returns Consumable units.
|
|
36
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the client chain id.
|
|
37
|
+
* @throws {UnknownAddressError} when the registry has no Midnight address for the client chain id.
|
|
38
|
+
* @throws {NegativeValueError} when asset-capped `timeToMaturity`, offer caps, or SDK math inputs are negative.
|
|
39
|
+
* @throws {InvalidOfferParameterError} when offer caps are both zero or both non-zero.
|
|
40
|
+
* @throws {DivisionByZeroError} when the delegated units conversion divides by zero.
|
|
41
|
+
* @throws {SettlementFeeExceedsPriceError} when settlement fee exceeds a buy offer price.
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { fetchConsumableUnits } from "@morpho-org/midnight-sdk";
|
|
45
|
+
* import { createPublicClient, http, zeroHash } from "viem";
|
|
46
|
+
* import { base } from "viem/chains";
|
|
47
|
+
*
|
|
48
|
+
* const client = createPublicClient({ chain: base, transport: http() });
|
|
49
|
+
* const units = await fetchConsumableUnits(client, {
|
|
50
|
+
* marketId: "0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",
|
|
51
|
+
* offer: {
|
|
52
|
+
* buy: true,
|
|
53
|
+
* maker: "0x0000000000000000000000000000000000009000",
|
|
54
|
+
* tick: 5_000n,
|
|
55
|
+
* maxUnits: 100n,
|
|
56
|
+
* maxAssets: 0n,
|
|
57
|
+
* continuousFeeCap: 317097919n,
|
|
58
|
+
* },
|
|
59
|
+
* group: zeroHash,
|
|
60
|
+
* timeToMaturity: 3_600n,
|
|
61
|
+
* });
|
|
62
|
+
* console.log(units);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export async function fetchConsumableUnits(client, params) {
|
|
66
|
+
const maxUnits = BigInt(params.offer.maxUnits);
|
|
67
|
+
const maxAssets = BigInt(params.offer.maxAssets);
|
|
68
|
+
const continuousFeeCap = BigInt(params.offer.continuousFeeCap);
|
|
69
|
+
assertNonNegative("offer.maxUnits", maxUnits);
|
|
70
|
+
assertNonNegative("offer.maxAssets", maxAssets);
|
|
71
|
+
assertNonNegative("offer.continuousFeeCap", continuousFeeCap);
|
|
72
|
+
OfferUtils.validateOfferCaps({ maxUnits, maxAssets });
|
|
73
|
+
const needsSettlementFee = maxUnits === 0n;
|
|
74
|
+
const timeToMaturity = needsSettlementFee
|
|
75
|
+
? BigInt(params.timeToMaturity)
|
|
76
|
+
: 0n;
|
|
77
|
+
if (needsSettlementFee) {
|
|
78
|
+
assertNonNegative("timeToMaturity", timeToMaturity);
|
|
79
|
+
}
|
|
80
|
+
const chainId = await resolveChainId(client);
|
|
81
|
+
const midnight = getChainAddress(chainId, "midnight");
|
|
82
|
+
const consumed = readContract(client, {
|
|
83
|
+
...callParameters(params),
|
|
84
|
+
address: midnight,
|
|
85
|
+
abi: midnightAbi,
|
|
86
|
+
functionName: "consumed",
|
|
87
|
+
args: [params.offer.maker, params.group],
|
|
88
|
+
});
|
|
89
|
+
const continuousFee = readContract(client, {
|
|
90
|
+
...callParameters(params),
|
|
91
|
+
address: midnight,
|
|
92
|
+
abi: midnightAbi,
|
|
93
|
+
functionName: "continuousFee",
|
|
94
|
+
args: [params.marketId],
|
|
95
|
+
});
|
|
96
|
+
const [consumedValue, marketContinuousFee] = await Promise.all([
|
|
97
|
+
consumed,
|
|
98
|
+
continuousFee,
|
|
99
|
+
]);
|
|
100
|
+
if (continuousFeeCap < BigInt(marketContinuousFee))
|
|
101
|
+
return 0n;
|
|
102
|
+
const settlementFee = needsSettlementFee
|
|
103
|
+
? await readContract(client, {
|
|
104
|
+
...callParameters(params),
|
|
105
|
+
address: midnight,
|
|
106
|
+
abi: midnightAbi,
|
|
107
|
+
functionName: "settlementFee",
|
|
108
|
+
args: [params.marketId, timeToMaturity],
|
|
109
|
+
})
|
|
110
|
+
: 0n;
|
|
111
|
+
return ConsumableUnitsLib.consumableUnits({
|
|
112
|
+
offer: params.offer,
|
|
113
|
+
consumed: consumedValue,
|
|
114
|
+
settlementFee,
|
|
115
|
+
});
|
|
116
|
+
}
|