@morpho-org/midnight-sdk 2.2.1 → 2.3.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 +1 -0
- package/lib/cjs/abis.d.ts +822 -0
- package/lib/cjs/abis.js +1021 -1
- package/lib/cjs/api/MidnightApi.d.ts +6 -2
- package/lib/cjs/api/MidnightApi.js +8 -2
- package/lib/cjs/api/helpers.d.ts +2 -0
- package/lib/cjs/api/helpers.js +9 -4
- package/lib/cjs/api/types.d.ts +5 -0
- package/lib/cjs/api/version.generated.d.ts +1 -1
- package/lib/cjs/api/version.generated.js +1 -1
- package/lib/cjs/offers/Offer.d.ts +17 -21
- package/lib/cjs/offers/Offer.js +17 -24
- package/lib/esm/abis.d.ts +822 -0
- package/lib/esm/abis.js +1020 -0
- package/lib/esm/api/MidnightApi.d.ts +6 -2
- package/lib/esm/api/MidnightApi.js +8 -2
- package/lib/esm/api/helpers.d.ts +2 -0
- package/lib/esm/api/helpers.js +9 -4
- package/lib/esm/api/types.d.ts +5 -0
- package/lib/esm/api/version.generated.d.ts +1 -1
- package/lib/esm/api/version.generated.js +1 -1
- package/lib/esm/offers/Offer.d.ts +17 -21
- package/lib/esm/offers/Offer.js +17 -24
- package/package.json +2 -2
|
@@ -166,6 +166,8 @@ export declare class MidnightApi {
|
|
|
166
166
|
* @param params.units - Optional target unit amount. Mutually exclusive with `params.assets`.
|
|
167
167
|
* @param params.averageWorstPrice - Optional WAD-scaled average worst price guard. Mutually exclusive with `params.slippage`.
|
|
168
168
|
* @param params.slippage - Optional slippage percentage used to derive the guard. Mutually exclusive with `params.averageWorstPrice`.
|
|
169
|
+
* @param params.taker - Account that will execute the take (the `taker` passed to Midnight `take`).
|
|
170
|
+
* The API leaves out offers made by this account, since Midnight rejects self-takes.
|
|
169
171
|
* @param params.settlementFee - Optional current WAD-scaled settlement fee used for local guard validation. Defaults to zero.
|
|
170
172
|
* @param params.baseUrl - Optional Midnight API base URL override.
|
|
171
173
|
* @param params.fetch - Optional fetch implementation override.
|
|
@@ -180,7 +182,7 @@ export declare class MidnightApi {
|
|
|
180
182
|
* @throws {InvalidMidnightApiQuoteTargetError} when the runtime input does not set exactly one of `units` or `assets`.
|
|
181
183
|
* @throws {NegativeValueError} when `settlementFee` is negative.
|
|
182
184
|
* @throws {MidnightApiError} when the API returns a non-2xx response.
|
|
183
|
-
* @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
|
|
185
|
+
* @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when an offer's maker matches the requested `taker`, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
|
|
184
186
|
* @throws {SettlementFeeExceedsPriceError} when a bid's settlement fee exceeds its offer price.
|
|
185
187
|
* @example
|
|
186
188
|
* ```ts
|
|
@@ -421,6 +423,8 @@ export declare class MidnightApi {
|
|
|
421
423
|
* @param params.units - Optional target unit amount. Mutually exclusive with `params.assets`.
|
|
422
424
|
* @param params.averageWorstPrice - Optional WAD-scaled average worst price guard. Mutually exclusive with `params.slippage`.
|
|
423
425
|
* @param params.slippage - Optional slippage percentage used to derive the guard. Mutually exclusive with `params.averageWorstPrice`.
|
|
426
|
+
* @param params.taker - Account that will execute the take (the `taker` passed to Midnight `take`).
|
|
427
|
+
* The API leaves out offers made by this account, since Midnight rejects self-takes.
|
|
424
428
|
* @param params.settlementFee - Optional current WAD-scaled settlement fee used for local guard validation. Defaults to zero.
|
|
425
429
|
* @returns Quote and ABI-ready take caps. `averageWorstPrice` equals the caller's guard when provided,
|
|
426
430
|
* otherwise the API's guard. Offers are returned as the API sends them. An `asks` quote by
|
|
@@ -432,7 +436,7 @@ export declare class MidnightApi {
|
|
|
432
436
|
* @throws {InvalidMidnightApiQuoteTargetError} when the runtime input does not set exactly one of `units` or `assets`.
|
|
433
437
|
* @throws {NegativeValueError} when `settlementFee` is negative.
|
|
434
438
|
* @throws {MidnightApiError} when the API returns a non-2xx response.
|
|
435
|
-
* @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
|
|
439
|
+
* @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when an offer's maker matches the requested `taker`, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
|
|
436
440
|
* @throws {SettlementFeeExceedsPriceError} when a bid's settlement fee exceeds its offer price.
|
|
437
441
|
* @example
|
|
438
442
|
* ```ts
|
|
@@ -248,6 +248,8 @@ class MidnightApi {
|
|
|
248
248
|
* @param params.units - Optional target unit amount. Mutually exclusive with `params.assets`.
|
|
249
249
|
* @param params.averageWorstPrice - Optional WAD-scaled average worst price guard. Mutually exclusive with `params.slippage`.
|
|
250
250
|
* @param params.slippage - Optional slippage percentage used to derive the guard. Mutually exclusive with `params.averageWorstPrice`.
|
|
251
|
+
* @param params.taker - Account that will execute the take (the `taker` passed to Midnight `take`).
|
|
252
|
+
* The API leaves out offers made by this account, since Midnight rejects self-takes.
|
|
251
253
|
* @param params.settlementFee - Optional current WAD-scaled settlement fee used for local guard validation. Defaults to zero.
|
|
252
254
|
* @param params.baseUrl - Optional Midnight API base URL override.
|
|
253
255
|
* @param params.fetch - Optional fetch implementation override.
|
|
@@ -262,7 +264,7 @@ class MidnightApi {
|
|
|
262
264
|
* @throws {InvalidMidnightApiQuoteTargetError} when the runtime input does not set exactly one of `units` or `assets`.
|
|
263
265
|
* @throws {NegativeValueError} when `settlementFee` is negative.
|
|
264
266
|
* @throws {MidnightApiError} when the API returns a non-2xx response.
|
|
265
|
-
* @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
|
|
267
|
+
* @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when an offer's maker matches the requested `taker`, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
|
|
266
268
|
* @throws {SettlementFeeExceedsPriceError} when a bid's settlement fee exceeds its offer price.
|
|
267
269
|
* @example
|
|
268
270
|
* ```ts
|
|
@@ -296,11 +298,13 @@ class MidnightApi {
|
|
|
296
298
|
slippage: input.slippage,
|
|
297
299
|
units: input.units,
|
|
298
300
|
assets: input.assets,
|
|
301
|
+
taker: input.taker,
|
|
299
302
|
},
|
|
300
303
|
});
|
|
301
304
|
const takeableOffers = (0, helpers_js_1.mapBoundTakeableOffers)(response.data.takeable_offers, {
|
|
302
305
|
marketId: input.marketId,
|
|
303
306
|
side: input.side,
|
|
307
|
+
taker: input.taker,
|
|
304
308
|
});
|
|
305
309
|
const averageWorstPrice = "averageWorstPrice" in input && input.averageWorstPrice != null
|
|
306
310
|
? input.averageWorstPrice
|
|
@@ -665,6 +669,8 @@ class MidnightApi {
|
|
|
665
669
|
* @param params.units - Optional target unit amount. Mutually exclusive with `params.assets`.
|
|
666
670
|
* @param params.averageWorstPrice - Optional WAD-scaled average worst price guard. Mutually exclusive with `params.slippage`.
|
|
667
671
|
* @param params.slippage - Optional slippage percentage used to derive the guard. Mutually exclusive with `params.averageWorstPrice`.
|
|
672
|
+
* @param params.taker - Account that will execute the take (the `taker` passed to Midnight `take`).
|
|
673
|
+
* The API leaves out offers made by this account, since Midnight rejects self-takes.
|
|
668
674
|
* @param params.settlementFee - Optional current WAD-scaled settlement fee used for local guard validation. Defaults to zero.
|
|
669
675
|
* @returns Quote and ABI-ready take caps. `averageWorstPrice` equals the caller's guard when provided,
|
|
670
676
|
* otherwise the API's guard. Offers are returned as the API sends them. An `asks` quote by
|
|
@@ -676,7 +682,7 @@ class MidnightApi {
|
|
|
676
682
|
* @throws {InvalidMidnightApiQuoteTargetError} when the runtime input does not set exactly one of `units` or `assets`.
|
|
677
683
|
* @throws {NegativeValueError} when `settlementFee` is negative.
|
|
678
684
|
* @throws {MidnightApiError} when the API returns a non-2xx response.
|
|
679
|
-
* @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
|
|
685
|
+
* @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when an offer's maker matches the requested `taker`, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
|
|
680
686
|
* @throws {SettlementFeeExceedsPriceError} when a bid's settlement fee exceeds its offer price.
|
|
681
687
|
* @example
|
|
682
688
|
* ```ts
|
package/lib/cjs/api/helpers.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface TakeableOfferContext {
|
|
|
27
27
|
readonly marketId?: Hash;
|
|
28
28
|
readonly side?: MidnightApiBookSide;
|
|
29
29
|
readonly maker?: Address;
|
|
30
|
+
/** Taker address whose own offers must not appear in the response. */
|
|
31
|
+
readonly taker?: Address;
|
|
30
32
|
readonly marketIds?: readonly Hash[];
|
|
31
33
|
readonly groups?: readonly Hash[];
|
|
32
34
|
}
|
package/lib/cjs/api/helpers.js
CHANGED
|
@@ -316,10 +316,15 @@ function mapBoundTakeableOffers(takeableOffers, context) {
|
|
|
316
316
|
!(0, viem_1.isAddressEqual)(take.offer.maker, context.maker)) {
|
|
317
317
|
throw new errors_js_1.InvalidMidnightApiResponseError(`Midnight API takeable offer maker "${take.offer.maker}" does not match requested maker "${context.maker}".`);
|
|
318
318
|
}
|
|
319
|
-
if (context.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
if (context.taker != null &&
|
|
320
|
+
(0, viem_1.isAddressEqual)(take.offer.maker, context.taker)) {
|
|
321
|
+
throw new errors_js_1.InvalidMidnightApiResponseError(`Midnight API takeable offer maker "${take.offer.maker}" matches the requested taker "${context.taker}".`);
|
|
322
|
+
}
|
|
323
|
+
if (context.groups != null && context.groups.length > 0) {
|
|
324
|
+
const offerGroup = take.offer.group;
|
|
325
|
+
if (!context.groups.some((group) => (0, morpho_ts_1.isHexEqual)(group, offerGroup))) {
|
|
326
|
+
throw new errors_js_1.InvalidMidnightApiResponseError(`Midnight API takeable offer group "${offerGroup}" is outside the requested groups filter.`);
|
|
327
|
+
}
|
|
323
328
|
}
|
|
324
329
|
return take;
|
|
325
330
|
});
|
package/lib/cjs/api/types.d.ts
CHANGED
|
@@ -177,6 +177,11 @@ export type FetchBookQuoteParams = MidnightApiConfig & {
|
|
|
177
177
|
readonly marketId: Hash;
|
|
178
178
|
/** Book side to quote. */
|
|
179
179
|
readonly side: MidnightApiBookSide;
|
|
180
|
+
/**
|
|
181
|
+
* Account that will execute the take (the `taker` passed to Midnight `take`). The API leaves out
|
|
182
|
+
* offers made by this account, since Midnight rejects self-takes.
|
|
183
|
+
*/
|
|
184
|
+
readonly taker?: Address;
|
|
180
185
|
/** Current WAD-scaled settlement fee used for local guard validation. Defaults to zero. */
|
|
181
186
|
readonly settlementFee?: BigIntish;
|
|
182
187
|
} & (MidnightApiQuoteAssetsTarget | MidnightApiQuoteUnitsTarget) & (MidnightApiQuoteAverageWorstPriceGuard | MidnightApiQuoteSlippageGuard | MidnightApiQuoteWithoutGuard);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal Installed Midnight SDK package version. */
|
|
2
|
-
export declare const MIDNIGHT_SDK_VERSION = "2.
|
|
2
|
+
export declare const MIDNIGHT_SDK_VERSION = "2.3.0";
|
|
@@ -8,10 +8,10 @@ import { type IMarket, type IMarketParams, Market, MarketParams } from "../marke
|
|
|
8
8
|
* flow into `Offer.from`, `Group.create`, `Tree.create`, or
|
|
9
9
|
* take-side conversion helpers. Use {@link Offer.create} instead for new maker
|
|
10
10
|
* offers so deterministic fields are validated before grouping or signing.
|
|
11
|
-
* The `group` field is optional. When omitted,
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* The `group` field is optional. When omitted, the `Offer.group` getter derives
|
|
12
|
+
* the content-addressed singleton group id from this offer's zero-group hash.
|
|
13
|
+
* `Group.create` copies offers into a shared group and overrides this field on
|
|
14
|
+
* the copies it owns.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
|
@@ -90,11 +90,11 @@ export interface IOffer {
|
|
|
90
90
|
* `Group.create` for shared-consumption ladders or directly to `Tree.create`
|
|
91
91
|
* for standalone offers. API/take-side code can convert a plain `IOffer`
|
|
92
92
|
* into this class before ABI encoding. The class resolves the onchain `group`
|
|
93
|
-
* field
|
|
94
|
-
* group id from the offer's zero-group hash;
|
|
95
|
-
* overrides the group on those copies when
|
|
96
|
-
* consumption bucket. Offers hydrated from API or
|
|
97
|
-
* a known group id.
|
|
93
|
+
* field when accessed. Standalone offers derive their
|
|
94
|
+
* content-addressed singleton group id from the offer's zero-group hash;
|
|
95
|
+
* `Group.create` copies offers and overrides the group on those copies when
|
|
96
|
+
* several offers share one consumption bucket. Offers hydrated from API or
|
|
97
|
+
* decoded data may also carry a known group id.
|
|
98
98
|
*
|
|
99
99
|
* @example
|
|
100
100
|
* ```ts
|
|
@@ -148,9 +148,7 @@ export declare class Offer {
|
|
|
148
148
|
readonly expiry: bigint;
|
|
149
149
|
/** Midnight tick. */
|
|
150
150
|
readonly tick: bigint;
|
|
151
|
-
private
|
|
152
|
-
private cachedHash;
|
|
153
|
-
private cachedOnchainHash;
|
|
151
|
+
private readonly explicitGroup;
|
|
154
152
|
/**
|
|
155
153
|
* Whether the group id was supplied at construction rather than derived.
|
|
156
154
|
*
|
|
@@ -231,12 +229,11 @@ export declare class Offer {
|
|
|
231
229
|
/**
|
|
232
230
|
* Consumption group id encoded into this offer.
|
|
233
231
|
*
|
|
234
|
-
* When no group id was provided, the value is
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* layer from importing signature helpers and creating a circular dependency.
|
|
232
|
+
* When no group id was provided, the value is derived on access by hashing
|
|
233
|
+
* this offer with the protocol zero group id, then hashing that result as a
|
|
234
|
+
* singleton group. This is equivalent to `GroupUtils.hash([offer])`, but is
|
|
235
|
+
* computed directly to keep the offers layer from importing signature
|
|
236
|
+
* helpers and creating a circular dependency.
|
|
240
237
|
*
|
|
241
238
|
* @returns Consumption group id.
|
|
242
239
|
* @example
|
|
@@ -284,8 +281,7 @@ export declare class Offer {
|
|
|
284
281
|
/**
|
|
285
282
|
* Canonical protocol offer hash for this offer.
|
|
286
283
|
*
|
|
287
|
-
* The hash includes {@link Offer.group}
|
|
288
|
-
* because hashing includes market hashing and ABI encoding.
|
|
284
|
+
* The hash includes {@link Offer.group} and is computed when accessed.
|
|
289
285
|
*
|
|
290
286
|
* @returns Offer hash.
|
|
291
287
|
* @example
|
|
@@ -340,7 +336,7 @@ export declare class Offer {
|
|
|
340
336
|
* `offers`: `buildDescriptor` replaces both the default group and a
|
|
341
337
|
* `Group.create` group.
|
|
342
338
|
*
|
|
343
|
-
* @returns The
|
|
339
|
+
* @returns The on-chain offer hash.
|
|
344
340
|
* @throws {viem.InvalidAddressError} when an address has an invalid mixed-case checksum.
|
|
345
341
|
* @throws {viem.IntegerOutOfRangeError} when a uint field overflows its ABI size.
|
|
346
342
|
* @example
|
package/lib/cjs/offers/Offer.js
CHANGED
|
@@ -11,11 +11,11 @@ const OfferUtils_js_1 = require("./OfferUtils.js");
|
|
|
11
11
|
* `Group.create` for shared-consumption ladders or directly to `Tree.create`
|
|
12
12
|
* for standalone offers. API/take-side code can convert a plain `IOffer`
|
|
13
13
|
* into this class before ABI encoding. The class resolves the onchain `group`
|
|
14
|
-
* field
|
|
15
|
-
* group id from the offer's zero-group hash;
|
|
16
|
-
* overrides the group on those copies when
|
|
17
|
-
* consumption bucket. Offers hydrated from API or
|
|
18
|
-
* a known group id.
|
|
14
|
+
* field when accessed. Standalone offers derive their
|
|
15
|
+
* content-addressed singleton group id from the offer's zero-group hash;
|
|
16
|
+
* `Group.create` copies offers and overrides the group on those copies when
|
|
17
|
+
* several offers share one consumption bucket. Offers hydrated from API or
|
|
18
|
+
* decoded data may also carry a known group id.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts
|
|
@@ -69,9 +69,7 @@ class Offer {
|
|
|
69
69
|
expiry;
|
|
70
70
|
/** Midnight tick. */
|
|
71
71
|
tick;
|
|
72
|
-
|
|
73
|
-
cachedHash;
|
|
74
|
-
cachedOnchainHash;
|
|
72
|
+
explicitGroup;
|
|
75
73
|
/**
|
|
76
74
|
* Whether the group id was supplied at construction rather than derived.
|
|
77
75
|
*
|
|
@@ -112,7 +110,6 @@ class Offer {
|
|
|
112
110
|
offer instanceof Offer
|
|
113
111
|
? offer.hasExplicitGroup
|
|
114
112
|
: offer.group !== undefined;
|
|
115
|
-
this.cachedGroup = this.hasExplicitGroup ? offer.group : undefined;
|
|
116
113
|
this.callback = offer.callback;
|
|
117
114
|
this.callbackData = offer.callbackData;
|
|
118
115
|
this.receiverIfMakerIsSeller = offer.receiverIfMakerIsSeller;
|
|
@@ -121,6 +118,7 @@ class Offer {
|
|
|
121
118
|
this.maxUnits = BigInt(offer.maxUnits);
|
|
122
119
|
this.maxAssets = BigInt(offer.maxAssets);
|
|
123
120
|
this.continuousFeeCap = BigInt(offer.continuousFeeCap);
|
|
121
|
+
this.explicitGroup = this.hasExplicitGroup ? offer.group : undefined;
|
|
124
122
|
}
|
|
125
123
|
/**
|
|
126
124
|
* Returns an offer instance from class or plain input.
|
|
@@ -177,12 +175,11 @@ class Offer {
|
|
|
177
175
|
/**
|
|
178
176
|
* Consumption group id encoded into this offer.
|
|
179
177
|
*
|
|
180
|
-
* When no group id was provided, the value is
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* layer from importing signature helpers and creating a circular dependency.
|
|
178
|
+
* When no group id was provided, the value is derived on access by hashing
|
|
179
|
+
* this offer with the protocol zero group id, then hashing that result as a
|
|
180
|
+
* singleton group. This is equivalent to `GroupUtils.hash([offer])`, but is
|
|
181
|
+
* computed directly to keep the offers layer from importing signature
|
|
182
|
+
* helpers and creating a circular dependency.
|
|
186
183
|
*
|
|
187
184
|
* @returns Consumption group id.
|
|
188
185
|
* @example
|
|
@@ -227,14 +224,12 @@ class Offer {
|
|
|
227
224
|
* ```
|
|
228
225
|
*/
|
|
229
226
|
get group() {
|
|
230
|
-
this.
|
|
231
|
-
return this.cachedGroup;
|
|
227
|
+
return this.explicitGroup ?? (0, viem_1.keccak256)(OfferUtils_js_1.OfferUtils.groupHash(this));
|
|
232
228
|
}
|
|
233
229
|
/**
|
|
234
230
|
* Canonical protocol offer hash for this offer.
|
|
235
231
|
*
|
|
236
|
-
* The hash includes {@link Offer.group}
|
|
237
|
-
* because hashing includes market hashing and ABI encoding.
|
|
232
|
+
* The hash includes {@link Offer.group} and is computed when accessed.
|
|
238
233
|
*
|
|
239
234
|
* @returns Offer hash.
|
|
240
235
|
* @example
|
|
@@ -279,8 +274,7 @@ class Offer {
|
|
|
279
274
|
* ```
|
|
280
275
|
*/
|
|
281
276
|
get hash() {
|
|
282
|
-
|
|
283
|
-
return this.cachedHash;
|
|
277
|
+
return OfferUtils_js_1.OfferUtils.hash(this);
|
|
284
278
|
}
|
|
285
279
|
/**
|
|
286
280
|
* Returns the on-chain offer identifier emitted by Midnight's `Take` event.
|
|
@@ -292,7 +286,7 @@ class Offer {
|
|
|
292
286
|
* `offers`: `buildDescriptor` replaces both the default group and a
|
|
293
287
|
* `Group.create` group.
|
|
294
288
|
*
|
|
295
|
-
* @returns The
|
|
289
|
+
* @returns The on-chain offer hash.
|
|
296
290
|
* @throws {viem.InvalidAddressError} when an address has an invalid mixed-case checksum.
|
|
297
291
|
* @throws {viem.IntegerOutOfRangeError} when a uint field overflows its ABI size.
|
|
298
292
|
* @example
|
|
@@ -331,8 +325,7 @@ class Offer {
|
|
|
331
325
|
* ```
|
|
332
326
|
*/
|
|
333
327
|
get onchainHash() {
|
|
334
|
-
|
|
335
|
-
return this.cachedOnchainHash;
|
|
328
|
+
return OfferUtils_js_1.OfferUtils.onchainHash(this);
|
|
336
329
|
}
|
|
337
330
|
/**
|
|
338
331
|
* WAD zero-coupon price at this offer's tick.
|