@morpho-dev/router 0.7.2 → 0.9.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 (68) hide show
  1. package/dist/cli.js +834 -334
  2. package/dist/drizzle/migrations/0000_setup_single_migration_folder.sql +64 -64
  3. package/dist/drizzle/migrations/0001_add-trigger-for-consumed-events.sql +5 -5
  4. package/dist/drizzle/migrations/0002_insert-status-code.sql +1 -1
  5. package/dist/drizzle/migrations/0003_update-triggers-for-consumed-events.sql +1 -1
  6. package/dist/drizzle/migrations/0004_drop-status-offers-foreign-key-constraint.sql +1 -1
  7. package/dist/drizzle/migrations/0005_add-index-to-boost-group-query-and-offer-hash.sql +1 -1
  8. package/dist/drizzle/migrations/0006_add-callbacks-and-positions-relations.sql +11 -11
  9. package/dist/drizzle/migrations/0008_validation.sql +10 -10
  10. package/dist/drizzle/migrations/0009_add-transfers-table.sql +4 -4
  11. package/dist/drizzle/migrations/0010_add-price.sql +1 -1
  12. package/dist/drizzle/migrations/0011_nullable-callback-amount.sql +1 -1
  13. package/dist/drizzle/migrations/0012_add-position-asset.sql +1 -1
  14. package/dist/drizzle/migrations/0013_remove-depecrated-domains.sql +13 -13
  15. package/dist/drizzle/migrations/0014_rename-offers-v2-into-offers.sql +19 -19
  16. package/dist/drizzle/migrations/0015_add-lots-table.sql +3 -3
  17. package/dist/drizzle/migrations/0016_merkle-metadata.sql +7 -7
  18. package/dist/drizzle/migrations/0017_dusty_the_hunter.sql +1 -1
  19. package/dist/drizzle/migrations/0018_add_chain_collector_constraints.sql +3 -3
  20. package/dist/drizzle/migrations/0019_add-obligation-units-shares.sql +2 -2
  21. package/dist/drizzle/migrations/0020_add-session.sql +1 -1
  22. package/dist/drizzle/migrations/0021_drop_chain_collector_epoch_indexes.sql +2 -2
  23. package/dist/drizzle/migrations/0021_migrate-rate-to-price.sql +6 -6
  24. package/dist/drizzle/migrations/0022_consolidate-price.sql +5 -5
  25. package/dist/drizzle/migrations/0023_remove-block-number-for-collaterals.sql +1 -1
  26. package/dist/drizzle/migrations/0024_add-obligation-id-to-lots.sql +8 -0
  27. package/dist/drizzle/migrations/0025_rename-price-to-tick.sql +202 -0
  28. package/dist/drizzle/migrations/0026_add-receiver-if-maker-is-seller.sql +1 -0
  29. package/dist/drizzle/migrations/meta/0000_snapshot.json +48 -48
  30. package/dist/drizzle/migrations/meta/0001_snapshot.json +48 -48
  31. package/dist/drizzle/migrations/meta/0002_snapshot.json +48 -48
  32. package/dist/drizzle/migrations/meta/0003_snapshot.json +48 -48
  33. package/dist/drizzle/migrations/meta/0004_snapshot.json +47 -47
  34. package/dist/drizzle/migrations/meta/0005_snapshot.json +47 -47
  35. package/dist/drizzle/migrations/meta/0006_snapshot.json +61 -61
  36. package/dist/drizzle/migrations/meta/0008_snapshot.json +62 -62
  37. package/dist/drizzle/migrations/meta/0009_snapshot.json +66 -66
  38. package/dist/drizzle/migrations/meta/0010_snapshot.json +66 -66
  39. package/dist/drizzle/migrations/meta/0013_snapshot.json +48 -48
  40. package/dist/drizzle/migrations/meta/0014_snapshot.json +48 -48
  41. package/dist/drizzle/migrations/meta/0015_snapshot.json +52 -52
  42. package/dist/drizzle/migrations/meta/0016_snapshot.json +61 -61
  43. package/dist/drizzle/migrations/meta/0017_snapshot.json +61 -61
  44. package/dist/drizzle/migrations/meta/0018_snapshot.json +62 -62
  45. package/dist/drizzle/migrations/meta/0019_snapshot.json +62 -62
  46. package/dist/drizzle/migrations/meta/0023_snapshot.json +62 -62
  47. package/dist/drizzle/migrations/meta/0024_snapshot.json +1448 -0
  48. package/dist/drizzle/migrations/meta/0025_snapshot.json +1448 -0
  49. package/dist/drizzle/migrations/meta/0026_snapshot.json +1454 -0
  50. package/dist/drizzle/migrations/meta/_journal.json +21 -0
  51. package/dist/evm/bytecode/morpho.txt +1 -1
  52. package/dist/index.browser.d.mts +206 -77
  53. package/dist/index.browser.d.mts.map +1 -1
  54. package/dist/index.browser.d.ts +206 -77
  55. package/dist/index.browser.d.ts.map +1 -1
  56. package/dist/index.browser.js +445 -197
  57. package/dist/index.browser.js.map +1 -1
  58. package/dist/index.browser.mjs +440 -198
  59. package/dist/index.browser.mjs.map +1 -1
  60. package/dist/index.node.d.mts +347 -119
  61. package/dist/index.node.d.mts.map +1 -1
  62. package/dist/index.node.d.ts +347 -119
  63. package/dist/index.node.d.ts.map +1 -1
  64. package/dist/index.node.js +865 -312
  65. package/dist/index.node.js.map +1 -1
  66. package/dist/index.node.mjs +861 -314
  67. package/dist/index.node.mjs.map +1 -1
  68. package/package.json +1 -1
@@ -52,11 +52,191 @@ let openapi_metadata_decorators = require("openapi-metadata/decorators");
52
52
  let openapi_fetch = require("openapi-fetch");
53
53
  openapi_fetch = __toESM(openapi_fetch);
54
54
 
55
+ //#region \0@oxc-project+runtime@0.110.0/helpers/typeof.js
56
+ function _typeof(o) {
57
+ "@babel/helpers - typeof";
58
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
59
+ return typeof o;
60
+ } : function(o) {
61
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
62
+ }, _typeof(o);
63
+ }
64
+
65
+ //#endregion
66
+ //#region \0@oxc-project+runtime@0.110.0/helpers/toPrimitive.js
67
+ function toPrimitive(t, r) {
68
+ if ("object" != _typeof(t) || !t) return t;
69
+ var e = t[Symbol.toPrimitive];
70
+ if (void 0 !== e) {
71
+ var i = e.call(t, r || "default");
72
+ if ("object" != _typeof(i)) return i;
73
+ throw new TypeError("@@toPrimitive must return a primitive value.");
74
+ }
75
+ return ("string" === r ? String : Number)(t);
76
+ }
77
+
78
+ //#endregion
79
+ //#region \0@oxc-project+runtime@0.110.0/helpers/toPropertyKey.js
80
+ function toPropertyKey(t) {
81
+ var i = toPrimitive(t, "string");
82
+ return "symbol" == _typeof(i) ? i : i + "";
83
+ }
84
+
85
+ //#endregion
86
+ //#region \0@oxc-project+runtime@0.110.0/helpers/defineProperty.js
87
+ function _defineProperty(e, r, t) {
88
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
89
+ value: t,
90
+ enumerable: !0,
91
+ configurable: !0,
92
+ writable: !0
93
+ }) : e[r] = t, e;
94
+ }
95
+
96
+ //#endregion
97
+ //#region src/utils/Errors.ts
98
+ var Errors_exports = /* @__PURE__ */ __exportAll({
99
+ BaseError: () => BaseError,
100
+ ReorgError: () => ReorgError
101
+ });
102
+ /**
103
+ * Base error class inherited by all errors thrown by mempool.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * import { Errors } from 'mempool'
108
+ * throw new Errors.BaseError('An error occurred')
109
+ * ```
110
+ */
111
+ var BaseError = class BaseError extends Error {
112
+ constructor(shortMessage, options = {}) {
113
+ const details = (() => {
114
+ if (options.cause instanceof BaseError) {
115
+ if (options.cause.details) return options.cause.details;
116
+ if (options.cause.shortMessage) return options.cause.shortMessage;
117
+ }
118
+ if (options.cause && "details" in options.cause && typeof options.cause.details === "string") return options.cause.details;
119
+ if (options.cause?.message) return options.cause.message;
120
+ return options.details;
121
+ })();
122
+ const message = [
123
+ shortMessage || "An error occurred.",
124
+ ...options.metaMessages ? ["", ...options.metaMessages] : [],
125
+ ...details ? ["", details ? `Details: ${details}` : void 0] : []
126
+ ].filter((x) => typeof x === "string").join("\n");
127
+ super(message, options.cause ? { cause: options.cause } : void 0);
128
+ _defineProperty(this, "details", void 0);
129
+ _defineProperty(this, "shortMessage", void 0);
130
+ _defineProperty(this, "cause", void 0);
131
+ _defineProperty(this, "name", "BaseError");
132
+ this.cause = options.cause;
133
+ this.details = details;
134
+ this.shortMessage = shortMessage;
135
+ }
136
+ walk(fn) {
137
+ return walk(this, fn);
138
+ }
139
+ };
140
+ /** @internal */
141
+ function walk(err, fn) {
142
+ if (fn?.(err)) return err;
143
+ if (err && typeof err === "object" && "cause" in err && err.cause) return walk(err.cause, fn);
144
+ return fn ? null : err;
145
+ }
146
+ var ReorgError = class extends BaseError {
147
+ constructor(blockNumber) {
148
+ super(`Reorg detected at block number ${blockNumber}`);
149
+ _defineProperty(this, "name", "ReorgError");
150
+ }
151
+ };
152
+
153
+ //#endregion
154
+ //#region src/core/Tick.ts
155
+ var Tick_exports = /* @__PURE__ */ __exportAll({
156
+ InvalidPriceError: () => InvalidPriceError,
157
+ InvalidTickError: () => InvalidTickError,
158
+ MAX_PRICE: () => MAX_PRICE,
159
+ TICK_RANGE: () => TICK_RANGE,
160
+ priceToTick: () => priceToTick,
161
+ tickToPrice: () => tickToPrice
162
+ });
163
+ /** ln(1 + 0.025), scaled by 1e18. Matches TickLib onchain constant. */
164
+ const LN_ONE_PLUS_DELTA = 24692612590371501n;
165
+ /** ln(2), scaled by 1e18. Matches TickLib onchain constant. */
166
+ const LN2 = 693147180559945309n;
167
+ const WAD$1 = 10n ** 18n;
168
+ const WAD_SQUARED = 10n ** 36n;
169
+ const PRICE_STEP = 10n ** 13n;
170
+ const HALF_TICK_RANGE = 495n;
171
+ /** Tick domain supported by Morpho V2. */
172
+ const TICK_RANGE = 990;
173
+ /** Max allowed price (1e18 in wad). */
174
+ const MAX_PRICE = WAD$1;
175
+ /**
176
+ * Converts a tick to a wad price using the same approximation and rounding as TickLib.
177
+ * @param tick - Tick value in the inclusive range [0, 990].
178
+ * @returns The price in wad units.
179
+ * @throws {@link InvalidTickError} If tick is not an integer in range [0, 990].
180
+ */
181
+ function tickToPrice(tick) {
182
+ assertTick(tick);
183
+ return divHalfDownUnchecked(divHalfDownUnchecked(WAD_SQUARED, WAD$1 + wExp(LN_ONE_PLUS_DELTA * (HALF_TICK_RANGE - BigInt(tick)))), PRICE_STEP) * PRICE_STEP;
184
+ }
185
+ /**
186
+ * Returns the lowest tick with a higher-or-equal price.
187
+ * @param price - Price in wad units.
188
+ * @returns The first tick whose {@link tickToPrice} is greater than or equal to `price`.
189
+ * @throws {@link InvalidPriceError} If price is outside [0, 1e18].
190
+ */
191
+ function priceToTick(price) {
192
+ assertPrice(price);
193
+ let low = 0;
194
+ let high = TICK_RANGE;
195
+ while (low !== high) {
196
+ const mid = Math.floor((low + high) / 2);
197
+ if (tickToPrice(mid) < price) low = mid + 1;
198
+ else high = mid;
199
+ }
200
+ return low;
201
+ }
202
+ function divHalfDownUnchecked(x, d) {
203
+ return (x + (d - 1n) / 2n) / d;
204
+ }
205
+ function wExp(x) {
206
+ if (x < 0n) return WAD_SQUARED / wExp(-x);
207
+ const q = (x + LN2 / 2n) / LN2;
208
+ const r = x - q * LN2;
209
+ const secondTerm = r * r / (2n * WAD$1);
210
+ const thirdTerm = secondTerm * r / (3n * WAD$1);
211
+ return WAD$1 + r + secondTerm + thirdTerm << q;
212
+ }
213
+ function assertTick(tick) {
214
+ if (!Number.isInteger(tick) || tick < 0 || tick > TICK_RANGE) throw new InvalidTickError(tick);
215
+ }
216
+ function assertPrice(price) {
217
+ if (price < 0n || price > MAX_PRICE) throw new InvalidPriceError(price);
218
+ }
219
+ var InvalidTickError = class extends BaseError {
220
+ constructor(tick) {
221
+ super(`Invalid tick: ${tick}. Tick must be an integer between 0 and ${TICK_RANGE}.`);
222
+ _defineProperty(this, "name", "Tick.InvalidTickError");
223
+ }
224
+ };
225
+ var InvalidPriceError = class extends BaseError {
226
+ constructor(price) {
227
+ super(`Invalid price: ${price}. Price must be between 0 and ${MAX_PRICE}.`);
228
+ _defineProperty(this, "name", "Tick.InvalidPriceError");
229
+ }
230
+ };
231
+
232
+ //#endregion
55
233
  //#region src/api/Schema/BookResponse.ts
56
234
  var BookResponse_exports = /* @__PURE__ */ __exportAll({ from: () => from$15 });
57
235
  function from$15(level) {
236
+ const price = tickToPrice(level.tick);
58
237
  return {
59
- price: level.price.toString(),
238
+ tick: level.tick,
239
+ price: price.toString(),
60
240
  assets: level.assets.toString(),
61
241
  count: level.count
62
242
  };
@@ -103,6 +283,7 @@ var ObligationResponse_exports = /* @__PURE__ */ __exportAll({ from: () => from$
103
283
  * Creates an `ObligationResponse` from a `Obligation`.
104
284
  * @constructor
105
285
  * @param obligation - {@link Obligation}
286
+ * @param quote - {@link Quote}
106
287
  * @returns The created `ObligationResponse`. {@link ObligationResponse}
107
288
  */
108
289
  function from$14(obligation, quote) {
@@ -116,8 +297,14 @@ function from$14(obligation, quote) {
116
297
  oracle: c.oracle
117
298
  })),
118
299
  maturity: obligation.maturity,
119
- ask: { price: quote.ask.price.toString() },
120
- bid: { price: quote.bid.price.toString() }
300
+ ask: {
301
+ tick: quote.ask.tick,
302
+ price: quote.ask.price.toString()
303
+ },
304
+ bid: {
305
+ tick: quote.bid.tick,
306
+ price: quote.bid.price.toString()
307
+ }
121
308
  };
122
309
  }
123
310
 
@@ -163,18 +350,18 @@ const MorphoV2 = (0, viem.parseAbi)([
163
350
  "function setFeeSetter(address newFeeSetter)",
164
351
  "function setObligationTradingFee(bytes32 id, uint256 index, uint256 newTradingFee)",
165
352
  "function setOwner(address newOwner)",
166
- "function setTradingFeeRecipient(address recipient)",
353
+ "function setTradingFeeRecipient(address feeRecipient)",
167
354
  "function sharesOf(bytes32 id, address user) view returns (uint256)",
168
355
  "function shuffleSession()",
169
356
  "function supplyCollateral((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, address collateral, uint256 assets, address onBehalf)",
170
- "function take(uint256 buyerAssets, uint256 sellerAssets, uint256 obligationUnits, uint256 obligationShares, address taker, ((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, bool buy, address maker, uint256 assets, uint256 obligationUnits, uint256 obligationShares, uint256 start, uint256 expiry, uint256 tick, bytes32 group, bytes32 session, address callback, bytes callbackData) offer, (uint8 v, bytes32 r, bytes32 s) sig, bytes32 root, bytes32[] proof, address takerCallback, bytes takerCallbackData) returns (uint256, uint256, uint256, uint256)",
357
+ "function take(uint256 buyerAssets, uint256 sellerAssets, uint256 obligationUnits, uint256 obligationShares, address taker, address takerCallback, bytes takerCallbackData, address receiverIfTakerIsSeller, ((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, bool buy, address maker, uint256 assets, uint256 obligationUnits, uint256 obligationShares, uint256 start, uint256 expiry, uint256 tick, bytes32 group, bytes32 session, address callback, bytes callbackData, address receiverIfMakerIsSeller) offer, (uint8 v, bytes32 r, bytes32 s) sig, bytes32 root, bytes32[] proof) returns (uint256, uint256, uint256, uint256)",
171
358
  "function totalShares(bytes32 id) view returns (uint256)",
172
359
  "function totalUnits(bytes32 id) view returns (uint256)",
173
360
  "function touchObligation((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation) returns (bytes32)",
174
361
  "function tradingFee(bytes32 id, uint256 timeToMaturity) view returns (uint256)",
175
362
  "function tradingFeeRecipient() view returns (address)",
176
- "function withdraw((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, uint256 obligationUnits, uint256 shares, address onBehalf) returns (uint256, uint256)",
177
- "function withdrawCollateral((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, address collateral, uint256 assets, address onBehalf)",
363
+ "function withdraw((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, uint256 obligationUnits, uint256 shares, address onBehalf, address receiver) returns (uint256, uint256)",
364
+ "function withdrawCollateral((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, address collateral, uint256 assets, address onBehalf, address receiver)",
178
365
  "function withdrawable(bytes32 id) view returns (uint256)",
179
366
  "event Constructor(address indexed owner)",
180
367
  "event Consume(address indexed user, bytes32 indexed group, uint256 amount)",
@@ -186,12 +373,12 @@ const MorphoV2 = (0, viem.parseAbi)([
186
373
  "event SetFeeSetter(address indexed feeSetter)",
187
374
  "event SetObligationTradingFee(bytes32 indexed id, uint256 indexed index, uint256 newTradingFee)",
188
375
  "event SetOwner(address indexed owner)",
189
- "event SetTradingFeeRecipient(address indexed recipient)",
376
+ "event SetTradingFeeRecipient(address indexed feeRecipient)",
190
377
  "event ShuffleSession(address indexed user, bytes32 session)",
191
378
  "event SupplyCollateral(address caller, bytes32 indexed id, address indexed collateral, uint256 assets, address indexed onBehalf)",
192
- "event Take(address caller, bytes32 indexed id, address indexed maker, address indexed taker, bool offerIsBuy, uint256 buyerAssets, uint256 sellerAssets, uint256 obligationUnits, uint256 obligationShares, bool buyerIsLender, bool sellerIsBorrower, bytes32 group, uint256 consumed)",
193
- "event Withdraw(address indexed caller, bytes32 indexed id, uint256 obligationUnits, uint256 shares, address indexed onBehalf)",
194
- "event WithdrawCollateral(address caller, bytes32 indexed id, address indexed collateral, uint256 assets, address indexed onBehalf)"
379
+ "event Take(address caller, bytes32 indexed id, address indexed maker, address indexed taker, bool offerIsBuy, uint256 buyerAssets, uint256 sellerAssets, uint256 obligationUnits, uint256 obligationShares, bool buyerIsLender, bool sellerIsBorrower, address sellerReceiver, bytes32 group, uint256 consumed)",
380
+ "event Withdraw(address caller, bytes32 indexed id, uint256 obligationUnits, uint256 shares, address indexed onBehalf, address indexed receiver)",
381
+ "event WithdrawCollateral(address caller, bytes32 indexed id, address indexed collateral, uint256 assets, address indexed onBehalf, address receiver)"
195
382
  ]);
196
383
 
197
384
  //#endregion
@@ -404,105 +591,6 @@ function* batch$1(array, batchSize) {
404
591
  for (let i = 0; i < array.length; i += batchSize) yield array.slice(i, i + batchSize);
405
592
  }
406
593
 
407
- //#endregion
408
- //#region \0@oxc-project+runtime@0.110.0/helpers/typeof.js
409
- function _typeof(o) {
410
- "@babel/helpers - typeof";
411
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
412
- return typeof o;
413
- } : function(o) {
414
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
415
- }, _typeof(o);
416
- }
417
-
418
- //#endregion
419
- //#region \0@oxc-project+runtime@0.110.0/helpers/toPrimitive.js
420
- function toPrimitive(t, r) {
421
- if ("object" != _typeof(t) || !t) return t;
422
- var e = t[Symbol.toPrimitive];
423
- if (void 0 !== e) {
424
- var i = e.call(t, r || "default");
425
- if ("object" != _typeof(i)) return i;
426
- throw new TypeError("@@toPrimitive must return a primitive value.");
427
- }
428
- return ("string" === r ? String : Number)(t);
429
- }
430
-
431
- //#endregion
432
- //#region \0@oxc-project+runtime@0.110.0/helpers/toPropertyKey.js
433
- function toPropertyKey(t) {
434
- var i = toPrimitive(t, "string");
435
- return "symbol" == _typeof(i) ? i : i + "";
436
- }
437
-
438
- //#endregion
439
- //#region \0@oxc-project+runtime@0.110.0/helpers/defineProperty.js
440
- function _defineProperty(e, r, t) {
441
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
442
- value: t,
443
- enumerable: !0,
444
- configurable: !0,
445
- writable: !0
446
- }) : e[r] = t, e;
447
- }
448
-
449
- //#endregion
450
- //#region src/utils/Errors.ts
451
- var Errors_exports = /* @__PURE__ */ __exportAll({
452
- BaseError: () => BaseError,
453
- ReorgError: () => ReorgError
454
- });
455
- /**
456
- * Base error class inherited by all errors thrown by mempool.
457
- *
458
- * @example
459
- * ```ts
460
- * import { Errors } from 'mempool'
461
- * throw new Errors.BaseError('An error occurred')
462
- * ```
463
- */
464
- var BaseError = class BaseError extends Error {
465
- constructor(shortMessage, options = {}) {
466
- const details = (() => {
467
- if (options.cause instanceof BaseError) {
468
- if (options.cause.details) return options.cause.details;
469
- if (options.cause.shortMessage) return options.cause.shortMessage;
470
- }
471
- if (options.cause && "details" in options.cause && typeof options.cause.details === "string") return options.cause.details;
472
- if (options.cause?.message) return options.cause.message;
473
- return options.details;
474
- })();
475
- const message = [
476
- shortMessage || "An error occurred.",
477
- ...options.metaMessages ? ["", ...options.metaMessages] : [],
478
- ...details ? ["", details ? `Details: ${details}` : void 0] : []
479
- ].filter((x) => typeof x === "string").join("\n");
480
- super(message, options.cause ? { cause: options.cause } : void 0);
481
- _defineProperty(this, "details", void 0);
482
- _defineProperty(this, "shortMessage", void 0);
483
- _defineProperty(this, "cause", void 0);
484
- _defineProperty(this, "name", "BaseError");
485
- this.cause = options.cause;
486
- this.details = details;
487
- this.shortMessage = shortMessage;
488
- }
489
- walk(fn) {
490
- return walk(this, fn);
491
- }
492
- };
493
- /** @internal */
494
- function walk(err, fn) {
495
- if (fn?.(err)) return err;
496
- if (err && typeof err === "object" && "cause" in err && err.cause) return walk(err.cause, fn);
497
- return fn ? null : err;
498
- }
499
- var ReorgError = class extends BaseError {
500
- constructor(blockNumber) {
501
- super(`Reorg detected at block number ${blockNumber}`);
502
- _defineProperty(this, "name", "ReorgError");
503
- }
504
- };
505
-
506
594
  //#endregion
507
595
  //#region src/core/Chain.ts
508
596
  var Chain_exports = /* @__PURE__ */ __exportAll({
@@ -607,8 +695,8 @@ const chains$1 = {
607
695
  name: "ethereum-virtual-testnet",
608
696
  custom: {
609
697
  morpho: {
610
- address: "0x634b095371e4e45feed94c1a45c37798e173ea50",
611
- blockCreated: 23226700
698
+ address: "0xc9f3c65996fc46b9500608b2c9a9152c01c540f7",
699
+ blockCreated: 23226871
612
700
  },
613
701
  morphoBlue: {
614
702
  address: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
@@ -1549,7 +1637,7 @@ const OfferSchema = () => {
1549
1637
  assets: zod.bigint({ coerce: true }).min(0n).max(viem.maxUint256),
1550
1638
  obligationUnits: zod.bigint({ coerce: true }).min(0n).max(viem.maxUint256).optional().default(0n),
1551
1639
  obligationShares: zod.bigint({ coerce: true }).min(0n).max(viem.maxUint256).optional().default(0n),
1552
- price: zod.bigint({ coerce: true }).min(0n).max(viem.maxUint256),
1640
+ tick: zod.coerce.number().int().min(0).max(990),
1553
1641
  maturity: MaturitySchema,
1554
1642
  expiry: zod.number().int().max(Number.MAX_SAFE_INTEGER),
1555
1643
  start: zod.number().int().max(Number.MAX_SAFE_INTEGER),
@@ -1570,7 +1658,8 @@ const OfferSchema = () => {
1570
1658
  callback: zod.object({
1571
1659
  address: zod.string().transform(transformAddress),
1572
1660
  data: zod.string().transform(transformHex)
1573
- })
1661
+ }),
1662
+ receiverIfMakerIsSeller: zod.string().transform(transformAddress)
1574
1663
  }).refine((data) => data.start < data.expiry, {
1575
1664
  message: "start must be before expiry",
1576
1665
  path: ["start"]
@@ -1586,8 +1675,12 @@ const OfferSchema = () => {
1586
1675
  * @returns The created offer.
1587
1676
  */
1588
1677
  function from$9(input) {
1678
+ const normalizedInput = {
1679
+ ...input,
1680
+ receiverIfMakerIsSeller: input.receiverIfMakerIsSeller ?? input.maker
1681
+ };
1589
1682
  try {
1590
- return OfferSchema().parse(input);
1683
+ return OfferSchema().parse(normalizedInput);
1591
1684
  } catch (error) {
1592
1685
  throw new InvalidOfferError(error);
1593
1686
  }
@@ -1621,7 +1714,7 @@ const serialize = (offer) => ({
1621
1714
  assets: offer.assets.toString(),
1622
1715
  obligationUnits: offer.obligationUnits.toString(),
1623
1716
  obligationShares: offer.obligationShares.toString(),
1624
- price: offer.price.toString(),
1717
+ tick: offer.tick,
1625
1718
  maturity: Number(offer.maturity),
1626
1719
  expiry: Number(offer.expiry),
1627
1720
  start: Number(offer.start),
@@ -1639,6 +1732,7 @@ const serialize = (offer) => ({
1639
1732
  address: offer.callback.address,
1640
1733
  data: offer.callback.data
1641
1734
  },
1735
+ receiverIfMakerIsSeller: offer.receiverIfMakerIsSeller,
1642
1736
  hash: hash(offer)
1643
1737
  });
1644
1738
  /**
@@ -1666,14 +1760,13 @@ function random$1(config) {
1666
1760
  [.98, 2]
1667
1761
  ]));
1668
1762
  const buy = config?.buy !== void 0 ? config.buy : bool();
1669
- const ONE = 1000000000000000000n;
1670
- const qMin = buy ? 16 : 4;
1671
- const len = (buy ? 32 : 16) - qMin + 1;
1672
- const pricePairs = Array.from({ length: len }, (_, idx) => {
1673
- const q = qMin + idx;
1674
- return [BigInt(q) * (ONE / 4n), buy ? 1 + idx : 1 + (len - 1 - idx)];
1763
+ const tickMin = buy ? 0 : 495;
1764
+ const len = (buy ? 495 : 990) - tickMin + 1;
1765
+ const tickPairs = Array.from({ length: len }, (_, idx) => {
1766
+ const weight = buy ? 1 + idx : 1 + (len - 1 - idx);
1767
+ return [tickMin + idx, weight];
1675
1768
  });
1676
- const price = config?.price ?? weightedChoice(pricePairs);
1769
+ const tick = config?.tick ?? weightedChoice(tickPairs);
1677
1770
  const loanTokenDecimals = config?.assetsDecimals?.[loanToken] ?? 18;
1678
1771
  const unit = BigInt(10) ** BigInt(loanTokenDecimals);
1679
1772
  const amountBase = BigInt(100 + int(999901));
@@ -1682,12 +1775,13 @@ function random$1(config) {
1682
1775
  address: viem.zeroAddress,
1683
1776
  data: "0x"
1684
1777
  };
1778
+ const maker = config?.maker ?? address();
1685
1779
  return from$9({
1686
- maker: config?.maker ?? address(),
1780
+ maker,
1687
1781
  assets: assetsScaled,
1688
1782
  obligationUnits: config?.obligationUnits ?? 0n,
1689
1783
  obligationShares: config?.obligationShares ?? 0n,
1690
- price,
1784
+ tick,
1691
1785
  maturity,
1692
1786
  expiry: config?.expiry ?? maturity - 1,
1693
1787
  start: config?.start ?? maturity - 10,
@@ -1700,7 +1794,8 @@ function random$1(config) {
1700
1794
  ...random$3(),
1701
1795
  lltv
1702
1796
  })).sort((a, b) => a.asset.localeCompare(b.asset)),
1703
- callback: config?.callback ?? emptyCallback
1797
+ callback: config?.callback ?? emptyCallback,
1798
+ receiverIfMakerIsSeller: config?.receiverIfMakerIsSeller ?? maker
1704
1799
  });
1705
1800
  }
1706
1801
  const weightedChoice = (pairs) => {
@@ -1752,7 +1847,7 @@ const types = {
1752
1847
  type: "uint256"
1753
1848
  },
1754
1849
  {
1755
- name: "price",
1850
+ name: "tick",
1756
1851
  type: "uint256"
1757
1852
  },
1758
1853
  {
@@ -1786,6 +1881,10 @@ const types = {
1786
1881
  {
1787
1882
  name: "callback",
1788
1883
  type: "Callback"
1884
+ },
1885
+ {
1886
+ name: "receiverIfMakerIsSeller",
1887
+ type: "address"
1789
1888
  }
1790
1889
  ],
1791
1890
  Collateral: [
@@ -1820,7 +1919,7 @@ function hash(offer) {
1820
1919
  assets: offer.assets,
1821
1920
  obligationUnits: offer.obligationUnits,
1822
1921
  obligationShares: offer.obligationShares,
1823
- price: offer.price,
1922
+ tick: BigInt(offer.tick),
1824
1923
  maturity: BigInt(offer.maturity),
1825
1924
  expiry: BigInt(offer.expiry),
1826
1925
  group: offer.group,
@@ -1831,7 +1930,8 @@ function hash(offer) {
1831
1930
  callback: {
1832
1931
  address: offer.callback.address.toLowerCase(),
1833
1932
  data: offer.callback.data
1834
- }
1933
+ },
1934
+ receiverIfMakerIsSeller: offer.receiverIfMakerIsSeller.toLowerCase()
1835
1935
  },
1836
1936
  primaryType: "Offer",
1837
1937
  types
@@ -1871,7 +1971,7 @@ const OfferAbi = [
1871
1971
  type: "uint256"
1872
1972
  },
1873
1973
  {
1874
- name: "price",
1974
+ name: "tick",
1875
1975
  type: "uint256"
1876
1976
  },
1877
1977
  {
@@ -1934,6 +2034,10 @@ const OfferAbi = [
1934
2034
  name: "data",
1935
2035
  type: "bytes"
1936
2036
  }]
2037
+ },
2038
+ {
2039
+ name: "receiverIfMakerIsSeller",
2040
+ type: "address"
1937
2041
  }
1938
2042
  ];
1939
2043
  function encode$1(offer) {
@@ -1942,7 +2046,7 @@ function encode$1(offer) {
1942
2046
  offer.assets,
1943
2047
  offer.obligationUnits,
1944
2048
  offer.obligationShares,
1945
- offer.price,
2049
+ BigInt(offer.tick),
1946
2050
  BigInt(offer.maturity),
1947
2051
  BigInt(offer.expiry),
1948
2052
  offer.group,
@@ -1952,7 +2056,8 @@ function encode$1(offer) {
1952
2056
  offer.loanToken,
1953
2057
  BigInt(offer.start),
1954
2058
  offer.collaterals,
1955
- offer.callback
2059
+ offer.callback,
2060
+ offer.receiverIfMakerIsSeller
1956
2061
  ]);
1957
2062
  }
1958
2063
  function decode$1(data) {
@@ -1967,7 +2072,7 @@ function decode$1(data) {
1967
2072
  assets: decoded[1],
1968
2073
  obligationUnits: decoded[2],
1969
2074
  obligationShares: decoded[3],
1970
- price: decoded[4],
2075
+ tick: Number(decoded[4]),
1971
2076
  maturity: from$11(Number(decoded[5])),
1972
2077
  expiry: Number(decoded[6]),
1973
2078
  group: decoded[7],
@@ -1986,7 +2091,8 @@ function decode$1(data) {
1986
2091
  callback: {
1987
2092
  address: decoded[14].address,
1988
2093
  data: decoded[14].data
1989
- }
2094
+ },
2095
+ receiverIfMakerIsSeller: decoded[15]
1990
2096
  });
1991
2097
  }
1992
2098
  /**
@@ -2062,6 +2168,12 @@ const takeEvent = {
2062
2168
  indexed: false,
2063
2169
  internalType: "bool"
2064
2170
  },
2171
+ {
2172
+ name: "sellerReceiver",
2173
+ type: "address",
2174
+ indexed: false,
2175
+ internalType: "address"
2176
+ },
2065
2177
  {
2066
2178
  name: "group",
2067
2179
  type: "bytes32",
@@ -2251,16 +2363,16 @@ function from$7(parameters) {
2251
2363
  //#region src/core/Quote.ts
2252
2364
  var Quote_exports = /* @__PURE__ */ __exportAll({
2253
2365
  InvalidQuoteError: () => InvalidQuoteError,
2254
- QuoteSchema: () => QuoteSchema,
2255
2366
  from: () => from$6,
2256
2367
  fromSnakeCase: () => fromSnakeCase,
2257
2368
  random: () => random
2258
2369
  });
2259
- const QuoteSchema = zod.object({
2370
+ const SideInputSchema = zod.object({ tick: zod.number().int().min(0).max(TICK_RANGE).nullable() }).strict();
2371
+ const QuoteInputSchema = zod.object({
2260
2372
  obligationId: zod.string().transform(transformHex),
2261
- ask: zod.object({ price: zod.bigint({ coerce: true }).min(0n).max(viem.maxUint256) }),
2262
- bid: zod.object({ price: zod.bigint({ coerce: true }).min(0n).max(viem.maxUint256) })
2263
- });
2373
+ ask: SideInputSchema,
2374
+ bid: SideInputSchema
2375
+ }).strict();
2264
2376
  /**
2265
2377
  * Creates a quote for a given obligation.
2266
2378
  * @constructor
@@ -2270,16 +2382,16 @@ const QuoteSchema = zod.object({
2270
2382
  *
2271
2383
  * @example
2272
2384
  * ```ts
2273
- * const quote = Quote.from({ obligationId: "0x123", ask: { price: 100n }, bid: { price: 100n } });
2385
+ * const quote = Quote.from({ obligationId: "0x123", ask: { tick: 500 }, bid: { tick: 510 } });
2274
2386
  * ```
2275
2387
  */
2276
2388
  function from$6(parameters) {
2277
2389
  try {
2278
- const parsedQuote = QuoteSchema.parse(parameters);
2390
+ const parsedQuote = QuoteInputSchema.parse(parameters);
2279
2391
  return {
2280
2392
  obligationId: parsedQuote.obligationId,
2281
- ask: parsedQuote.ask,
2282
- bid: parsedQuote.bid
2393
+ ask: sideFromTick(parsedQuote.ask),
2394
+ bid: sideFromTick(parsedQuote.bid)
2283
2395
  };
2284
2396
  } catch (error) {
2285
2397
  throw new InvalidQuoteError(error);
@@ -2306,8 +2418,8 @@ function fromSnakeCase(snake) {
2306
2418
  function random() {
2307
2419
  return from$6({
2308
2420
  obligationId: id(random$2()),
2309
- ask: { price: BigInt(int(1e6)) },
2310
- bid: { price: BigInt(int(1e6)) }
2421
+ ask: { tick: int(TICK_RANGE + 1) },
2422
+ bid: { tick: int(TICK_RANGE + 1) }
2311
2423
  });
2312
2424
  }
2313
2425
  var InvalidQuoteError = class extends BaseError {
@@ -2316,6 +2428,12 @@ var InvalidQuoteError = class extends BaseError {
2316
2428
  _defineProperty(this, "name", "Quote.InvalidQuoteError");
2317
2429
  }
2318
2430
  };
2431
+ function sideFromTick(side) {
2432
+ return {
2433
+ tick: side.tick,
2434
+ price: side.tick === null ? 0n : tickToPrice(side.tick)
2435
+ };
2436
+ }
2319
2437
 
2320
2438
  //#endregion
2321
2439
  //#region src/core/TradingFee.ts
@@ -2868,11 +2986,12 @@ function from$2(input) {
2868
2986
  obligation_shares: input.obligationShares.toString(),
2869
2987
  start: input.start,
2870
2988
  expiry: input.expiry,
2871
- price: input.price.toString(),
2989
+ tick: input.tick,
2872
2990
  group: input.group,
2873
2991
  session: input.session,
2874
2992
  callback: input.callback.address,
2875
- callback_data: input.callback.data
2993
+ callback_data: input.callback.data,
2994
+ receiver_if_maker_is_seller: input.receiverIfMakerIsSeller
2876
2995
  },
2877
2996
  offer_hash: input.hash,
2878
2997
  obligation_id: id({
@@ -2922,7 +3041,7 @@ function __decorate(decorators, target, key, desc) {
2922
3041
  //#region src/api/Schema/openapi.ts
2923
3042
  const timestampExample = "2024-01-01T12:00:00.000Z";
2924
3043
  const offerCursorExample = "eyJvZmZzZXQiOjEwMH0";
2925
- const obligationCursorExample = "0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc";
3044
+ const obligationCursorExample = "eyJzb3J0IjpbImlkIl0sImlkIjoiMHgxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAiLCJhc2siOiIwIiwiYmlkIjoiMCIsIm1hdHVyaXR5IjoxNzYxOTIyODAwfQ";
2926
3045
  const offerExample = {
2927
3046
  offer: {
2928
3047
  obligation: {
@@ -2941,11 +3060,12 @@ const offerExample = {
2941
3060
  obligation_shares: "0",
2942
3061
  start: 1761922790,
2943
3062
  expiry: 1761922799,
2944
- price: "2750000000000000000",
3063
+ tick: 495,
2945
3064
  group: "0x000000000000000000000000000000000000000000000000000000000008b8f4",
2946
3065
  session: "0x0000000000000000000000000000000000000000000000000000000000000000",
2947
3066
  callback: "0x0000000000000000000000000000000000000000",
2948
- callback_data: "0x"
3067
+ callback_data: "0x",
3068
+ receiver_if_maker_is_seller: "0x7b093658BE7f90B63D7c359e8f408e503c2D9401"
2949
3069
  },
2950
3070
  offer_hash: "0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427",
2951
3071
  obligation_id: "0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc",
@@ -2982,7 +3102,7 @@ const validateOfferExample = {
2982
3102
  assets: "369216000000000000000000",
2983
3103
  obligation_units: "0",
2984
3104
  obligation_shares: "0",
2985
- price: "2750000000000000000",
3105
+ tick: 495,
2986
3106
  maturity: 1761922799,
2987
3107
  expiry: 1761922799,
2988
3108
  start: 1761922790,
@@ -2999,7 +3119,8 @@ const validateOfferExample = {
2999
3119
  callback: {
3000
3120
  address: "0x0000000000000000000000000000000000000000",
3001
3121
  data: "0x"
3002
- }
3122
+ },
3123
+ receiver_if_maker_is_seller: "0x7b093658BE7f90B63D7c359e8f408e503c2D9401"
3003
3124
  };
3004
3125
  const routerStatusExample = {
3005
3126
  status: "live",
@@ -3070,11 +3191,23 @@ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3070
3191
  example: validateOfferExample.callback.data
3071
3192
  })], ValidateCallbackRequest.prototype, "data", void 0);
3072
3193
  var AskResponse = class {};
3194
+ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3195
+ type: "number",
3196
+ nullable: true,
3197
+ example: 500,
3198
+ description: "Best ask tick. Null when there is no active ask quote."
3199
+ })], AskResponse.prototype, "tick", void 0);
3073
3200
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3074
3201
  type: "string",
3075
3202
  example: "1000000000000000000"
3076
3203
  })], AskResponse.prototype, "price", void 0);
3077
3204
  var BidResponse = class {};
3205
+ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3206
+ type: "number",
3207
+ nullable: true,
3208
+ example: 500,
3209
+ description: "Best bid tick. Null when there is no active bid quote."
3210
+ })], BidResponse.prototype, "tick", void 0);
3078
3211
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3079
3212
  type: "string",
3080
3213
  example: "1000000000000000000"
@@ -3126,9 +3259,11 @@ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3126
3259
  example: offerExample.offer.expiry
3127
3260
  })], OfferDataResponse.prototype, "expiry", void 0);
3128
3261
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3129
- type: "string",
3130
- example: offerExample.offer.price
3131
- })], OfferDataResponse.prototype, "price", void 0);
3262
+ type: "number",
3263
+ example: offerExample.offer.tick,
3264
+ minimum: 0,
3265
+ maximum: 990
3266
+ })], OfferDataResponse.prototype, "tick", void 0);
3132
3267
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3133
3268
  type: "string",
3134
3269
  example: offerExample.offer.group
@@ -3145,6 +3280,10 @@ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3145
3280
  type: "string",
3146
3281
  example: offerExample.offer.callback_data
3147
3282
  })], OfferDataResponse.prototype, "callback_data", void 0);
3283
+ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3284
+ type: "string",
3285
+ example: offerExample.offer.receiver_if_maker_is_seller
3286
+ })], OfferDataResponse.prototype, "receiver_if_maker_is_seller", void 0);
3148
3287
  var OfferListItemResponse = class {};
3149
3288
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3150
3289
  type: () => OfferDataResponse,
@@ -3369,9 +3508,11 @@ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3369
3508
  required: false
3370
3509
  })], ValidateOfferRequest.prototype, "obligation_shares", void 0);
3371
3510
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3372
- type: "string",
3373
- example: validateOfferExample.price
3374
- })], ValidateOfferRequest.prototype, "price", void 0);
3511
+ type: "number",
3512
+ example: validateOfferExample.tick,
3513
+ minimum: 0,
3514
+ maximum: 990
3515
+ })], ValidateOfferRequest.prototype, "tick", void 0);
3375
3516
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3376
3517
  type: "number",
3377
3518
  example: validateOfferExample.maturity
@@ -3412,6 +3553,10 @@ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3412
3553
  type: () => ValidateCallbackRequest,
3413
3554
  example: validateOfferExample.callback
3414
3555
  })], ValidateOfferRequest.prototype, "callback", void 0);
3556
+ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3557
+ type: "string",
3558
+ example: validateOfferExample.receiver_if_maker_is_seller
3559
+ })], ValidateOfferRequest.prototype, "receiver_if_maker_is_seller", void 0);
3415
3560
  var ValidateOffersRequest = class {};
3416
3561
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3417
3562
  type: () => [ValidateOfferRequest],
@@ -3471,9 +3616,16 @@ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3471
3616
  description: "List of validation issues. Returned when any offer fails validation."
3472
3617
  })], ValidationFailureResponse.prototype, "data", void 0);
3473
3618
  var BookLevelResponse = class {};
3619
+ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3620
+ type: "number",
3621
+ example: 495,
3622
+ minimum: 0,
3623
+ maximum: 990
3624
+ })], BookLevelResponse.prototype, "tick", void 0);
3474
3625
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3475
3626
  type: "string",
3476
- example: "2750000000000000000"
3627
+ example: "500000000000000000",
3628
+ description: "Price derived from tick, scaled by 1e18."
3477
3629
  })], BookLevelResponse.prototype, "price", void 0);
3478
3630
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3479
3631
  type: "string",
@@ -3487,6 +3639,7 @@ const positionExample = {
3487
3639
  chain_id: 1,
3488
3640
  contract: "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
3489
3641
  user: "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
3642
+ obligation_id: "0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",
3490
3643
  reserved: "200000000000000000000",
3491
3644
  block_number: 21345678
3492
3645
  };
@@ -3503,6 +3656,12 @@ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3503
3656
  type: "string",
3504
3657
  example: positionExample.user
3505
3658
  })], PositionListItemResponse.prototype, "user", void 0);
3659
+ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3660
+ type: "string",
3661
+ nullable: true,
3662
+ example: positionExample.obligation_id,
3663
+ description: "Obligation id this reserved amount belongs to, or null if no lots exist."
3664
+ })], PositionListItemResponse.prototype, "obligation_id", void 0);
3506
3665
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3507
3666
  type: "string",
3508
3667
  example: positionExample.reserved
@@ -3530,7 +3689,7 @@ __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3530
3689
  })], BookListResponse.prototype, "cursor", void 0);
3531
3690
  __decorate([(0, openapi_metadata_decorators.ApiProperty)({
3532
3691
  type: () => [BookLevelResponse],
3533
- description: "Aggregated book levels grouped by computed price."
3692
+ description: "Aggregated book levels grouped by offer tick."
3534
3693
  })], BookListResponse.prototype, "data", void 0);
3535
3694
  let BooksController = class BooksController {
3536
3695
  async getBook() {}
@@ -3540,7 +3699,7 @@ __decorate([
3540
3699
  methods: ["get"],
3541
3700
  path: "/v1/books/{obligationId}/{side}",
3542
3701
  summary: "Get aggregated book",
3543
- description: "Returns aggregated book data for a given obligation and side. Offers are grouped by computed price with summed takeable amounts. Book levels are sorted by price (ascending for buy side, descending for sell side)."
3702
+ description: "Returns aggregated book data for a given obligation and side. Offers are grouped by tick with summed takeable amounts, and each level includes the corresponding wad-scaled price. Book levels are sorted by tick (ascending for sell side, descending for buy side)."
3544
3703
  }),
3545
3704
  (0, openapi_metadata_decorators.ApiParam)({
3546
3705
  name: "obligationId",
@@ -3565,7 +3724,7 @@ __decorate([
3565
3724
  name: "limit",
3566
3725
  type: "number",
3567
3726
  example: 10,
3568
- description: "Maximum number of price levels to return."
3727
+ description: "Maximum number of tick levels to return."
3569
3728
  }),
3570
3729
  (0, openapi_metadata_decorators.ApiResponse)({
3571
3730
  status: 200,
@@ -3759,6 +3918,11 @@ const configRulesLoanTokenExample = {
3759
3918
  chain_id: 1,
3760
3919
  address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
3761
3920
  };
3921
+ const configRulesCollateralTokenExample = {
3922
+ type: "collateral_token",
3923
+ chain_id: 1,
3924
+ address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
3925
+ };
3762
3926
  const configRulesOracleExample = {
3763
3927
  type: "oracle",
3764
3928
  chain_id: 1,
@@ -3768,6 +3932,7 @@ const configRulesChecksumExample = "f1d2d2f924e986ac86fdf7b36c94bcdf";
3768
3932
  const configRulesPayloadExample = [
3769
3933
  configRulesMaturityExample,
3770
3934
  configRulesLoanTokenExample,
3935
+ configRulesCollateralTokenExample,
3771
3936
  configRulesOracleExample
3772
3937
  ];
3773
3938
  const configContractNames = [
@@ -3894,7 +4059,7 @@ __decorate([
3894
4059
  methods: ["get"],
3895
4060
  path: "/v1/config/rules",
3896
4061
  summary: "Get config rules",
3897
- description: "Returns configured rules (maturities, loan tokens, oracles) for supported chains."
4062
+ description: "Returns configured rules (maturities, loan tokens, collateral tokens, oracles) for supported chains."
3898
4063
  }),
3899
4064
  (0, openapi_metadata_decorators.ApiQuery)({
3900
4065
  name: "cursor",
@@ -3914,7 +4079,7 @@ __decorate([
3914
4079
  name: "types",
3915
4080
  type: ["string"],
3916
4081
  required: false,
3917
- example: "maturity,loan_token,oracle",
4082
+ example: "maturity,loan_token,collateral_token,oracle",
3918
4083
  description: "Filter by rule types (comma-separated).",
3919
4084
  style: "form",
3920
4085
  explode: false
@@ -3944,13 +4109,13 @@ __decorate([
3944
4109
  methods: ["get"],
3945
4110
  path: "/v1/obligations",
3946
4111
  summary: "List all obligations",
3947
- description: "Returns a list of obligations with their current best ask and bid. Obligations are sorted by their id in ascending order by default."
4112
+ description: "Returns a list of obligations with their current best ask and bid. Sorting is customizable with the sort parameter and defaults to id ascending."
3948
4113
  }),
3949
4114
  (0, openapi_metadata_decorators.ApiQuery)({
3950
4115
  name: "cursor",
3951
4116
  type: "string",
3952
4117
  example: obligationCursorExample,
3953
- description: "Obligation id cursor for pagination."
4118
+ description: "Pagination cursor in base64url-encoded format."
3954
4119
  }),
3955
4120
  (0, openapi_metadata_decorators.ApiQuery)({
3956
4121
  name: "limit",
@@ -3994,6 +4159,15 @@ __decorate([
3994
4159
  style: "form",
3995
4160
  explode: false
3996
4161
  }),
4162
+ (0, openapi_metadata_decorators.ApiQuery)({
4163
+ name: "sort",
4164
+ type: "string",
4165
+ required: false,
4166
+ example: "-ask,bid,maturity",
4167
+ description: "Sort order as comma-separated fields (`id`, `ask`, `bid`, `maturity`). Prefix with `-` for descending order. Max 3 fields.",
4168
+ style: "form",
4169
+ explode: false
4170
+ }),
3997
4171
  (0, openapi_metadata_decorators.ApiResponse)({
3998
4172
  status: 200,
3999
4173
  description: "Success",
@@ -4032,7 +4206,7 @@ __decorate([
4032
4206
  methods: ["get"],
4033
4207
  path: "/v1/users/{userAddress}/positions",
4034
4208
  summary: "Get user positions",
4035
- description: "Returns positions for a user with reserved balance. The reserved balance is the amount locked by active offers (max lot upper - offset - consumed)."
4209
+ description: "Returns positions for a user with reserved balance per obligation. Each (position, obligation) pair is returned as a separate row. Positions with no lots return a single row with obligation_id = null and reserved = 0."
4036
4210
  }),
4037
4211
  (0, openapi_metadata_decorators.ApiParam)({
4038
4212
  name: "userAddress",
@@ -4120,6 +4294,7 @@ function from$1(position) {
4120
4294
  chain_id: position.chainId,
4121
4295
  contract: position.contract,
4122
4296
  user: position.user,
4297
+ obligation_id: position.obligationId,
4123
4298
  reserved: position.reserved.toString(),
4124
4299
  block_number: position.blockNumber
4125
4300
  };
@@ -4129,10 +4304,12 @@ function from$1(position) {
4129
4304
  //#region src/api/Schema/requests.ts
4130
4305
  const MAX_LIMIT = 100;
4131
4306
  const DEFAULT_LIMIT = 20;
4307
+ const MAX_OBLIGATION_SORT_FIELDS = 3;
4132
4308
  const CONFIG_RULES_MAX_LIMIT = 1e3;
4133
4309
  const CONFIG_RULES_DEFAULT_LIMIT = 100;
4134
4310
  const CONFIG_CONTRACTS_MAX_LIMIT = 1e3;
4135
4311
  const CONFIG_CONTRACTS_DEFAULT_LIMIT = 1e3;
4312
+ const OBLIGATION_SORT_ENTRY_REGEX = /^-?(id|ask|bid|maturity)$/;
4136
4313
  /** Validate cursor is a valid base64url-encoded JSON object.
4137
4314
  * Domain layer handles semantic validation of cursor fields. */
4138
4315
  function isValidBase64urlJson(val) {
@@ -4173,10 +4350,11 @@ const ConfigRuleTypes = zod.enum([
4173
4350
  "maturity",
4174
4351
  "callback",
4175
4352
  "loan_token",
4353
+ "collateral_token",
4176
4354
  "oracle"
4177
4355
  ]);
4178
4356
  const GetConfigRulesQueryParams = zod.object({
4179
- cursor: zod.string().regex(/^(maturity|callback|loan_token|oracle):[1-9]\d*:.+$/, { message: "Cursor must be in the format type:chain_id:<value>" }).optional().meta({
4357
+ cursor: zod.string().regex(/^(maturity|callback|loan_token|collateral_token|oracle):[1-9]\d*:.+$/, { message: "Cursor must be in the format type:chain_id:<value>" }).optional().meta({
4180
4358
  description: "Pagination cursor in type:chain_id:<value> format",
4181
4359
  example: "maturity:1:1730415600:end_of_next_month"
4182
4360
  }),
@@ -4186,7 +4364,7 @@ const GetConfigRulesQueryParams = zod.object({
4186
4364
  }),
4187
4365
  types: csvArray(ConfigRuleTypes).meta({
4188
4366
  description: "Filter by rule types (comma-separated).",
4189
- example: "maturity,loan_token,oracle"
4367
+ example: "maturity,loan_token,collateral_token,oracle"
4190
4368
  }),
4191
4369
  chains: csvArray(zod.string().regex(/^[1-9]\d*$/, { message: "Chain must be a positive integer" }).transform((val) => Number.parseInt(val, 10))).meta({
4192
4370
  description: "Filter by chain IDs (comma-separated).",
@@ -4261,9 +4439,12 @@ const GetOffersQueryParams = PaginationQueryParams.omit({ cursor: true }).extend
4261
4439
  });
4262
4440
  const GetObligationsQueryParams = zod.object({
4263
4441
  ...PaginationQueryParams.shape,
4264
- cursor: zod.string().optional().meta({
4265
- description: "Obligation id cursor",
4266
- example: "0x1234567890123456789012345678901234567890123456789012345678901234"
4442
+ cursor: zod.string().optional().refine((val) => {
4443
+ if (!val) return true;
4444
+ return isValidBase64urlJson(val);
4445
+ }, { message: "Invalid cursor format. Must be a valid base64url-encoded cursor object" }).meta({
4446
+ description: "Pagination cursor in base64url-encoded format.",
4447
+ example: "eyJzb3J0IjpbImlkIl0sImlkIjoiMHgxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAiLCJhc2siOiIwIiwiYmlkIjoiMCIsIm1hdHVyaXR5IjoxNzYxOTIyODAwfQ"
4267
4448
  }),
4268
4449
  chains: csvArray(zod.string().regex(/^[1-9]\d*$/, { message: "Chain must be a positive integer" }).transform((val) => Number.parseInt(val, 10))).meta({
4269
4450
  description: "Filter by chain IDs (comma-separated).",
@@ -4280,18 +4461,35 @@ const GetObligationsQueryParams = zod.object({
4280
4461
  maturities: csvArray(zod.string().regex(/^[1-9]\d*$/, { message: "Maturity must be a positive integer" }).transform((val) => Number.parseInt(val, 10))).meta({
4281
4462
  description: "Filter by exact maturity timestamps (comma-separated, unix seconds).",
4282
4463
  example: "1761922800,1764524800"
4464
+ }),
4465
+ sort: csvArray(zod.string().regex(OBLIGATION_SORT_ENTRY_REGEX, { message: "Sort entries must be one of: id, ask, bid, maturity (optionally prefixed with '-')" })).refine((entries) => entries === void 0 || entries.length <= MAX_OBLIGATION_SORT_FIELDS, { message: `Sort cannot include more than ${MAX_OBLIGATION_SORT_FIELDS} fields` }).superRefine((entries, ctx) => {
4466
+ if (!entries) return;
4467
+ const seen = /* @__PURE__ */ new Set();
4468
+ for (const entry of entries) {
4469
+ const field = entry.startsWith("-") ? entry.slice(1) : entry;
4470
+ if (seen.has(field)) {
4471
+ ctx.addIssue({
4472
+ code: "custom",
4473
+ message: `Duplicate sort field: ${field}`
4474
+ });
4475
+ return;
4476
+ }
4477
+ seen.add(field);
4478
+ }
4479
+ }).meta({
4480
+ description: "Sort order as comma-separated fields. Prefix a field with '-' for descending order. Max 3 fields.",
4481
+ example: "-ask,bid,maturity"
4283
4482
  })
4284
4483
  });
4285
4484
  const GetObligationParams = zod.object({ obligation_id: zod.string({ error: "Obligation id is required and must be a valid 32-byte hex string" }).regex(/^0x[a-fA-F0-9]{64}$/, { error: "Obligation id must be a valid 32-byte hex string" }).transform((val) => val.toLowerCase()).meta({
4286
4485
  description: "Obligation id",
4287
4486
  example: "0x1234567890123456789012345678901234567890123456789012345678901234"
4288
4487
  }) });
4289
- /** Validate a book cursor format: {side, lastPrice, offersCursor} */
4488
+ /** Validate a book cursor format: {side, lastTick, offersCursor} */
4290
4489
  function isValidBookCursor(cursorString) {
4291
- const isNumericString = (value) => typeof value === "string" && /^-?\d+$/.test(value);
4292
4490
  try {
4293
4491
  const v = JSON.parse(Buffer.from(cursorString, "base64url").toString("utf8"));
4294
- return (v?.side === "buy" || v?.side === "sell") && isNumericString(v?.lastPrice) && (v?.offersCursor === null || typeof v?.offersCursor === "string");
4492
+ return (v?.side === "buy" || v?.side === "sell") && typeof v?.lastTick === "number" && Number.isInteger(v.lastTick) && (v?.offersCursor === null || typeof v?.offersCursor === "string");
4295
4493
  } catch {
4296
4494
  return false;
4297
4495
  }
@@ -4452,7 +4650,7 @@ async function getOffers(apiClient, parameters) {
4452
4650
  assets: offerData.assets,
4453
4651
  obligation_units: offerData.obligation_units,
4454
4652
  obligation_shares: offerData.obligation_shares,
4455
- price: offerData.price,
4653
+ tick: offerData.tick,
4456
4654
  maturity: from$11(offerData.obligation.maturity),
4457
4655
  expiry: offerData.expiry,
4458
4656
  start: offerData.start,
@@ -4469,7 +4667,8 @@ async function getOffers(apiClient, parameters) {
4469
4667
  callback: {
4470
4668
  address: offerData.callback,
4471
4669
  data: offerData.callback_data
4472
- }
4670
+ },
4671
+ receiver_if_maker_is_seller: offerData.receiver_if_maker_is_seller
4473
4672
  }),
4474
4673
  hash: item.offer_hash,
4475
4674
  consumed: BigInt(item.consumed),
@@ -4486,13 +4685,15 @@ async function getOffers(apiClient, parameters) {
4486
4685
  };
4487
4686
  }
4488
4687
  async function getObligations(apiClient, parameters) {
4688
+ const sort = parameters?.sort?.length ? parameters.sort.join(",") : void 0;
4489
4689
  const { data, error, response } = await apiClient.GET("/v1/obligations", { params: { query: {
4490
4690
  cursor: parameters?.cursor,
4491
4691
  limit: parameters?.limit,
4492
4692
  chains: parameters?.chainIds,
4493
4693
  loan_tokens: parameters?.loanTokens,
4494
4694
  collateral_tokens: parameters?.collateralTokens,
4495
- maturities: parameters?.maturities
4695
+ maturities: parameters?.maturities,
4696
+ sort
4496
4697
  } } });
4497
4698
  if (error !== void 0) {
4498
4699
  switch (response.status) {
@@ -4516,10 +4717,10 @@ async function getObligations(apiClient, parameters) {
4516
4717
  const { obligationId: _, ...returned } = {
4517
4718
  id: () => id(obligation),
4518
4719
  ...obligation,
4519
- ...fromSnakeCase({
4520
- obligation_id: item.id,
4521
- ask: item.ask,
4522
- bid: item.bid
4720
+ ...from$6({
4721
+ obligationId: item.id,
4722
+ ask: { tick: item.ask.tick },
4723
+ bid: { tick: item.bid.tick }
4523
4724
  })
4524
4725
  };
4525
4726
  return returned;
@@ -4800,6 +5001,33 @@ const assets = {
4800
5001
  "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
4801
5002
  ]
4802
5003
  };
5004
+ const collateralAssets = {
5005
+ [ChainId.ETHEREUM.toString()]: [
5006
+ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
5007
+ "0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",
5008
+ "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
5009
+ "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
5010
+ ],
5011
+ [ChainId.BASE.toString()]: [
5012
+ "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
5013
+ "0x4200000000000000000000000000000000000006",
5014
+ "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
5015
+ "0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452",
5016
+ "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42"
5017
+ ],
5018
+ [ChainId["ETHEREUM-VIRTUAL-TESTNET"].toString()]: [
5019
+ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
5020
+ "0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",
5021
+ "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
5022
+ "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
5023
+ ],
5024
+ [ChainId.ANVIL.toString()]: [
5025
+ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
5026
+ "0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",
5027
+ "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
5028
+ "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
5029
+ ]
5030
+ };
4803
5031
  const oracles = {
4804
5032
  [ChainId.ETHEREUM.toString()]: [
4805
5033
  "0xDddd770BADd886dF3864029e4B377B5F6a2B6b83",
@@ -4840,19 +5068,19 @@ const oracles = {
4840
5068
  const configs = {
4841
5069
  ethereum: {
4842
5070
  callbacks: [{ type: Type$1.BuyWithEmptyCallback }, { type: Type$1.SellWithEmptyCallback }],
4843
- maturities: [MaturityType.EndOfMonth, MaturityType.EndOfNextMonth]
5071
+ maturities: [MaturityType.EndOfWeek, MaturityType.EndOfNextWeek]
4844
5072
  },
4845
5073
  base: {
4846
5074
  callbacks: [{ type: Type$1.BuyWithEmptyCallback }, { type: Type$1.SellWithEmptyCallback }],
4847
- maturities: [MaturityType.EndOfMonth, MaturityType.EndOfNextMonth]
5075
+ maturities: [MaturityType.EndOfWeek, MaturityType.EndOfNextWeek]
4848
5076
  },
4849
5077
  "ethereum-virtual-testnet": {
4850
5078
  callbacks: [{ type: Type$1.BuyWithEmptyCallback }, { type: Type$1.SellWithEmptyCallback }],
4851
- maturities: [MaturityType.EndOfMonth, MaturityType.EndOfNextMonth]
5079
+ maturities: [MaturityType.EndOfWeek, MaturityType.EndOfNextWeek]
4852
5080
  },
4853
5081
  anvil: {
4854
5082
  callbacks: [{ type: Type$1.BuyWithEmptyCallback }, { type: Type$1.SellWithEmptyCallback }],
4855
- maturities: [MaturityType.EndOfMonth, MaturityType.EndOfNextMonth]
5083
+ maturities: [MaturityType.EndOfWeek, MaturityType.EndOfNextWeek]
4856
5084
  }
4857
5085
  };
4858
5086
 
@@ -4862,10 +5090,11 @@ var Rules_exports = /* @__PURE__ */ __exportAll({
4862
5090
  amountMutualExclusivity: () => amountMutualExclusivity,
4863
5091
  callback: () => callback,
4864
5092
  chains: () => chains,
5093
+ collateralToken: () => collateralToken,
5094
+ loanToken: () => loanToken,
4865
5095
  maturity: () => maturity,
4866
5096
  oracle: () => oracle,
4867
5097
  sameMaker: () => sameMaker,
4868
- token: () => token,
4869
5098
  validity: () => validity
4870
5099
  });
4871
5100
  /**
@@ -4885,7 +5114,7 @@ const chains = ({ chains }) => single("chain_ids", `Validates that offer chain i
4885
5114
  });
4886
5115
  const maturity = ({ maturities }) => single("maturity", `Validates that offer maturity is one of: [${maturities.join(", ")}]`, (offer) => {
4887
5116
  const allowedMaturities = maturities.map((m) => from$11(m));
4888
- if (!allowedMaturities.includes(offer.maturity)) return { message: `Maturity must be end of current month (${allowedMaturities[0]}) or end of next month (${allowedMaturities[1]}). Got: ${offer.maturity}` };
5117
+ if (!allowedMaturities.includes(offer.maturity)) return { message: `Maturity must be one of (${allowedMaturities.join(", ")}). Got: ${offer.maturity}` };
4889
5118
  });
4890
5119
  const callback = ({ callbacks }) => single("callback", `Validates callbacks: buy empty callback is ${callbacks.includes(Type$1.BuyWithEmptyCallback) ? "allowed" : "not allowed"}; sell empty callback is ${callbacks.includes(Type$1.SellWithEmptyCallback) ? "allowed" : "not allowed"}; non-empty callbacks are rejected`, (offer) => {
4891
5120
  if (!isEmptyCallback(offer)) return { message: "Non-empty callbacks are not supported." };
@@ -4893,15 +5122,25 @@ const callback = ({ callbacks }) => single("callback", `Validates callbacks: buy
4893
5122
  if (isEmptyCallback(offer) && !offer.buy && !callbacks.includes(Type$1.SellWithEmptyCallback)) return { message: "Sell offers with empty callback not allowed." };
4894
5123
  });
4895
5124
  /**
4896
- * A validation rule that checks if the offer's tokens are allowed for its chain.
4897
- * @param assetsByChainId - Allowed assets indexed by chain id.
5125
+ * A validation rule that checks if the offer's loan token is allowed for its chain.
5126
+ * @param assetsByChainId - Allowed loan tokens indexed by chain id.
5127
+ * @returns The issue that was found. If the offer is valid, this will be undefined.
5128
+ */
5129
+ const loanToken = ({ assetsByChainId }) => single("loan_token", "Validates that offer loan token is in the allowed token list for the offer chain", (offer) => {
5130
+ const allowedLoanTokens = assetsByChainId[offer.chainId]?.map((asset) => asset.toLowerCase());
5131
+ if (!allowedLoanTokens || allowedLoanTokens.length === 0) return { message: `No allowed loan tokens for chain ${offer.chainId}` };
5132
+ if (!allowedLoanTokens.includes(offer.loanToken.toLowerCase())) return { message: "Loan token is not allowed" };
5133
+ });
5134
+ /**
5135
+ * A validation rule that checks if the offer's collateral tokens are allowed for its chain.
5136
+ * @param collateralAssetsByChainId - Allowed collateral tokens indexed by chain id.
4898
5137
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4899
5138
  */
4900
- const token = ({ assetsByChainId }) => single("token", "Validates that offer loan token and collateral tokens are in the allowed assets list for the offer chain", (offer) => {
4901
- const allowedAssets = assetsByChainId[offer.chainId]?.map((asset) => asset.toLowerCase());
4902
- if (!allowedAssets || allowedAssets.length === 0) return { message: `No allowed assets for chain ${offer.chainId}` };
4903
- if (!allowedAssets.includes(offer.loanToken.toLowerCase())) return { message: "Loan token is not allowed" };
4904
- if (offer.collaterals.some((collateral) => !allowedAssets.includes(collateral.asset.toLowerCase()))) return { message: "Collateral is not allowed" };
5139
+ const collateralToken = ({ collateralAssetsByChainId }) => single("collateral_token", "Validates that offer collateral tokens are in the allowed token list for the offer chain", (offer) => {
5140
+ const allowedCollateralTokens = collateralAssetsByChainId[offer.chainId]?.map((asset) => asset.toLowerCase()) ?? [];
5141
+ if (allowedCollateralTokens.length === 0) return { message: `No allowed collateral tokens for chain ${offer.chainId}` };
5142
+ if (offer.collaterals.length === 0) return { message: "At least one collateral token is required" };
5143
+ if (offer.collaterals.some((collateral) => !allowedCollateralTokens.includes(collateral.asset.toLowerCase()))) return { message: "Collateral token is not allowed" };
4905
5144
  });
4906
5145
  /**
4907
5146
  * A validation rule that checks if the offer's oracle addresses are allowed for its chain.
@@ -4944,21 +5183,24 @@ const amountMutualExclusivity = () => single("amount_mutual_exclusivity", "Valid
4944
5183
  //#region src/gatekeeper/morphoRules.ts
4945
5184
  const morphoRules = (chains$2) => {
4946
5185
  const assetsByChainId = {};
5186
+ const collateralAssetsByChainId = {};
4947
5187
  const oraclesByChainId = {};
4948
5188
  for (const chain of chains$2) {
4949
5189
  assetsByChainId[chain.id] = assets[chain.id.toString()] ?? [];
5190
+ collateralAssetsByChainId[chain.id] = collateralAssets[chain.id.toString()] ?? [];
4950
5191
  oraclesByChainId[chain.id] = oracles[chain.id.toString()] ?? [];
4951
5192
  }
4952
5193
  return [
4953
5194
  sameMaker(),
4954
5195
  amountMutualExclusivity(),
4955
5196
  chains({ chains: chains$2 }),
4956
- maturity({ maturities: [MaturityType.EndOfMonth, MaturityType.EndOfNextMonth] }),
5197
+ maturity({ maturities: [MaturityType.EndOfWeek, MaturityType.EndOfNextWeek] }),
4957
5198
  callback({
4958
5199
  callbacks: [Type$1.BuyWithEmptyCallback, Type$1.SellWithEmptyCallback],
4959
5200
  allowedAddresses: []
4960
5201
  }),
4961
- token({ assetsByChainId }),
5202
+ loanToken({ assetsByChainId }),
5203
+ collateralToken({ collateralAssetsByChainId }),
4962
5204
  oracle({ oraclesByChainId })
4963
5205
  ];
4964
5206
  };
@@ -5417,6 +5659,12 @@ Object.defineProperty(exports, 'Rules', {
5417
5659
  return Rules_exports;
5418
5660
  }
5419
5661
  });
5662
+ Object.defineProperty(exports, 'Tick', {
5663
+ enumerable: true,
5664
+ get: function () {
5665
+ return Tick_exports;
5666
+ }
5667
+ });
5420
5668
  Object.defineProperty(exports, 'Time', {
5421
5669
  enumerable: true,
5422
5670
  get: function () {