@morpho-dev/router 0.0.15 → 0.0.17

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.
@@ -1,4 +1,5 @@
1
- import { Offer, Errors, Format } from '@morpho-dev/mempool';
1
+ import * as _morpho_dev_mempool from '@morpho-dev/mempool';
2
+ import { Compute, Offer, Errors, Format } from '@morpho-dev/mempool';
2
3
  export * from '@morpho-dev/mempool';
3
4
  import * as viem from 'viem';
4
5
  import { Address, PublicClient } from 'viem';
@@ -7,10 +8,6 @@ import * as zod_v4_core from 'zod/v4/core';
7
8
  import * as zod_v4 from 'zod/v4';
8
9
  import { z, ZodError } from 'zod/v4';
9
10
 
10
- type Compute<type> = {
11
- [key in keyof type]: type[key];
12
- } & unknown;
13
-
14
11
  declare const chainNames: readonly ["ethereum", "base"];
15
12
  type ChainName = (typeof chainNames)[number];
16
13
  declare const ChainId: {
@@ -55,7 +52,7 @@ declare const RouterOfferSchema: (parameters?: {
55
52
  offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
56
53
  assets: zod_v4.ZodBigInt;
57
54
  rate: zod_v4.ZodBigInt;
58
- maturity: zod_v4.ZodNumber;
55
+ maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
59
56
  expiry: zod_v4.ZodNumber;
60
57
  start: zod_v4.ZodNumber;
61
58
  nonce: zod_v4.ZodBigInt;
@@ -65,7 +62,7 @@ declare const RouterOfferSchema: (parameters?: {
65
62
  collaterals: zod_v4.ZodArray<zod_v4.ZodObject<{
66
63
  asset: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
67
64
  oracle: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
68
- lltv: zod_v4.ZodBigInt;
65
+ lltv: zod_v4.ZodPipe<zod_v4.ZodBigInt, zod_v4.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
69
66
  }, zod_v4_core.$strip>>;
70
67
  callback: zod_v4.ZodObject<{
71
68
  address: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
@@ -132,6 +129,13 @@ declare namespace RouterOffer$1 {
132
129
  export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_from as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
133
130
  }
134
131
 
132
+ type OfferResponse = {
133
+ offer: Offer.Offer;
134
+ consumed: bigint;
135
+ status: OfferStatus;
136
+ metadata?: OfferMetadata;
137
+ };
138
+
135
139
  type GetParameters = {
136
140
  /** Filter by multiple creator addresses (comma-separated) */
137
141
  creators?: string[];
@@ -221,11 +225,11 @@ type RouterClientConfig = {
221
225
  type Client = Compute<RouterClientConfig & {
222
226
  get: (parameters: GetParameters) => Promise<{
223
227
  cursor: string | null;
224
- offers: RouterOffer[];
228
+ offers: OfferResponse[];
225
229
  }>;
226
230
  match: (parameters: MatchParameters) => Promise<{
227
231
  cursor: string | null;
228
- offers: RouterOffer[];
232
+ offers: OfferResponse[];
229
233
  }>;
230
234
  }>;
231
235
  declare function connect(opts?: {
@@ -241,7 +245,7 @@ declare namespace connect {
241
245
  */
242
246
  declare function get(config: RouterClientConfig, parameters: GetParameters): Promise<{
243
247
  cursor: string | null;
244
- offers: RouterOffer[];
248
+ offers: OfferResponse[];
245
249
  }>;
246
250
  declare namespace get {
247
251
  type ErrorType = GetApiErrorType;
@@ -252,7 +256,7 @@ declare namespace get {
252
256
  */
253
257
  declare function match(config: RouterClientConfig, parameters: MatchParameters): Promise<{
254
258
  cursor: string | null;
255
- offers: RouterOffer[];
259
+ offers: OfferResponse[];
256
260
  }>;
257
261
  declare namespace match {
258
262
  type ErrorType = GetApiErrorType;
@@ -433,7 +437,7 @@ declare function morpho(parameters: {
433
437
  readonly offering: Address;
434
438
  readonly assets: bigint;
435
439
  readonly rate: bigint;
436
- readonly maturity: number;
440
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
437
441
  readonly expiry: number;
438
442
  readonly nonce: bigint;
439
443
  readonly buy: boolean;
@@ -443,7 +447,7 @@ declare function morpho(parameters: {
443
447
  readonly collaterals: readonly {
444
448
  asset: Address;
445
449
  oracle: Address;
446
- lltv: bigint;
450
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
447
451
  }[];
448
452
  readonly callback: {
449
453
  readonly address: Address;
@@ -457,7 +461,7 @@ declare function morpho(parameters: {
457
461
  readonly offering: Address;
458
462
  readonly assets: bigint;
459
463
  readonly rate: bigint;
460
- readonly maturity: number;
464
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
461
465
  readonly expiry: number;
462
466
  readonly nonce: bigint;
463
467
  readonly buy: boolean;
@@ -467,7 +471,7 @@ declare function morpho(parameters: {
467
471
  readonly collaterals: readonly {
468
472
  asset: Address;
469
473
  oracle: Address;
470
- lltv: bigint;
474
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
471
475
  }[];
472
476
  readonly callback: {
473
477
  readonly address: Address;
@@ -481,7 +485,7 @@ declare function morpho(parameters: {
481
485
  readonly offering: Address;
482
486
  readonly assets: bigint;
483
487
  readonly rate: bigint;
484
- readonly maturity: number;
488
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
485
489
  readonly expiry: number;
486
490
  readonly nonce: bigint;
487
491
  readonly buy: boolean;
@@ -491,7 +495,7 @@ declare function morpho(parameters: {
491
495
  readonly collaterals: readonly {
492
496
  asset: Address;
493
497
  oracle: Address;
494
- lltv: bigint;
498
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
495
499
  }[];
496
500
  readonly callback: {
497
501
  readonly address: Address;
@@ -505,7 +509,7 @@ declare function morpho(parameters: {
505
509
  readonly offering: Address;
506
510
  readonly assets: bigint;
507
511
  readonly rate: bigint;
508
- readonly maturity: number;
512
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
509
513
  readonly expiry: number;
510
514
  readonly nonce: bigint;
511
515
  readonly buy: boolean;
@@ -515,7 +519,7 @@ declare function morpho(parameters: {
515
519
  readonly collaterals: readonly {
516
520
  asset: Address;
517
521
  oracle: Address;
518
- lltv: bigint;
522
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
519
523
  }[];
520
524
  readonly callback: {
521
525
  readonly address: Address;
@@ -529,7 +533,7 @@ declare function morpho(parameters: {
529
533
  readonly offering: Address;
530
534
  readonly assets: bigint;
531
535
  readonly rate: bigint;
532
- readonly maturity: number;
536
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
533
537
  readonly expiry: number;
534
538
  readonly nonce: bigint;
535
539
  readonly buy: boolean;
@@ -539,7 +543,7 @@ declare function morpho(parameters: {
539
543
  readonly collaterals: readonly {
540
544
  asset: Address;
541
545
  oracle: Address;
542
- lltv: bigint;
546
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
543
547
  }[];
544
548
  readonly callback: {
545
549
  readonly address: Address;
@@ -553,7 +557,7 @@ declare function morpho(parameters: {
553
557
  readonly offering: Address;
554
558
  readonly assets: bigint;
555
559
  readonly rate: bigint;
556
- readonly maturity: number;
560
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
557
561
  readonly expiry: number;
558
562
  readonly nonce: bigint;
559
563
  readonly buy: boolean;
@@ -563,7 +567,7 @@ declare function morpho(parameters: {
563
567
  readonly collaterals: readonly {
564
568
  asset: Address;
565
569
  oracle: Address;
566
- lltv: bigint;
570
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
567
571
  }[];
568
572
  readonly callback: {
569
573
  readonly address: Address;
@@ -628,4 +632,4 @@ declare namespace Validation {
628
632
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
629
633
  }
630
634
 
631
- export { Chain$1 as Chain, type Compute, type Cursor, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, decodeCursor, encodeCursor, poll, validateCursor, wait };
635
+ export { Chain$1 as Chain, type Cursor, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, decodeCursor, encodeCursor, poll, validateCursor, wait };
@@ -1,4 +1,5 @@
1
- import { Offer, Errors, Format } from '@morpho-dev/mempool';
1
+ import * as _morpho_dev_mempool from '@morpho-dev/mempool';
2
+ import { Compute, Offer, Errors, Format } from '@morpho-dev/mempool';
2
3
  export * from '@morpho-dev/mempool';
3
4
  import * as viem from 'viem';
4
5
  import { Address, PublicClient } from 'viem';
@@ -7,10 +8,6 @@ import * as zod_v4_core from 'zod/v4/core';
7
8
  import * as zod_v4 from 'zod/v4';
8
9
  import { z, ZodError } from 'zod/v4';
9
10
 
10
- type Compute<type> = {
11
- [key in keyof type]: type[key];
12
- } & unknown;
13
-
14
11
  declare const chainNames: readonly ["ethereum", "base"];
15
12
  type ChainName = (typeof chainNames)[number];
16
13
  declare const ChainId: {
@@ -55,7 +52,7 @@ declare const RouterOfferSchema: (parameters?: {
55
52
  offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
56
53
  assets: zod_v4.ZodBigInt;
57
54
  rate: zod_v4.ZodBigInt;
58
- maturity: zod_v4.ZodNumber;
55
+ maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
59
56
  expiry: zod_v4.ZodNumber;
60
57
  start: zod_v4.ZodNumber;
61
58
  nonce: zod_v4.ZodBigInt;
@@ -65,7 +62,7 @@ declare const RouterOfferSchema: (parameters?: {
65
62
  collaterals: zod_v4.ZodArray<zod_v4.ZodObject<{
66
63
  asset: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
67
64
  oracle: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
68
- lltv: zod_v4.ZodBigInt;
65
+ lltv: zod_v4.ZodPipe<zod_v4.ZodBigInt, zod_v4.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
69
66
  }, zod_v4_core.$strip>>;
70
67
  callback: zod_v4.ZodObject<{
71
68
  address: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
@@ -132,6 +129,13 @@ declare namespace RouterOffer$1 {
132
129
  export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_from as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
133
130
  }
134
131
 
132
+ type OfferResponse = {
133
+ offer: Offer.Offer;
134
+ consumed: bigint;
135
+ status: OfferStatus;
136
+ metadata?: OfferMetadata;
137
+ };
138
+
135
139
  type GetParameters = {
136
140
  /** Filter by multiple creator addresses (comma-separated) */
137
141
  creators?: string[];
@@ -221,11 +225,11 @@ type RouterClientConfig = {
221
225
  type Client = Compute<RouterClientConfig & {
222
226
  get: (parameters: GetParameters) => Promise<{
223
227
  cursor: string | null;
224
- offers: RouterOffer[];
228
+ offers: OfferResponse[];
225
229
  }>;
226
230
  match: (parameters: MatchParameters) => Promise<{
227
231
  cursor: string | null;
228
- offers: RouterOffer[];
232
+ offers: OfferResponse[];
229
233
  }>;
230
234
  }>;
231
235
  declare function connect(opts?: {
@@ -241,7 +245,7 @@ declare namespace connect {
241
245
  */
242
246
  declare function get(config: RouterClientConfig, parameters: GetParameters): Promise<{
243
247
  cursor: string | null;
244
- offers: RouterOffer[];
248
+ offers: OfferResponse[];
245
249
  }>;
246
250
  declare namespace get {
247
251
  type ErrorType = GetApiErrorType;
@@ -252,7 +256,7 @@ declare namespace get {
252
256
  */
253
257
  declare function match(config: RouterClientConfig, parameters: MatchParameters): Promise<{
254
258
  cursor: string | null;
255
- offers: RouterOffer[];
259
+ offers: OfferResponse[];
256
260
  }>;
257
261
  declare namespace match {
258
262
  type ErrorType = GetApiErrorType;
@@ -433,7 +437,7 @@ declare function morpho(parameters: {
433
437
  readonly offering: Address;
434
438
  readonly assets: bigint;
435
439
  readonly rate: bigint;
436
- readonly maturity: number;
440
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
437
441
  readonly expiry: number;
438
442
  readonly nonce: bigint;
439
443
  readonly buy: boolean;
@@ -443,7 +447,7 @@ declare function morpho(parameters: {
443
447
  readonly collaterals: readonly {
444
448
  asset: Address;
445
449
  oracle: Address;
446
- lltv: bigint;
450
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
447
451
  }[];
448
452
  readonly callback: {
449
453
  readonly address: Address;
@@ -457,7 +461,7 @@ declare function morpho(parameters: {
457
461
  readonly offering: Address;
458
462
  readonly assets: bigint;
459
463
  readonly rate: bigint;
460
- readonly maturity: number;
464
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
461
465
  readonly expiry: number;
462
466
  readonly nonce: bigint;
463
467
  readonly buy: boolean;
@@ -467,7 +471,7 @@ declare function morpho(parameters: {
467
471
  readonly collaterals: readonly {
468
472
  asset: Address;
469
473
  oracle: Address;
470
- lltv: bigint;
474
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
471
475
  }[];
472
476
  readonly callback: {
473
477
  readonly address: Address;
@@ -481,7 +485,7 @@ declare function morpho(parameters: {
481
485
  readonly offering: Address;
482
486
  readonly assets: bigint;
483
487
  readonly rate: bigint;
484
- readonly maturity: number;
488
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
485
489
  readonly expiry: number;
486
490
  readonly nonce: bigint;
487
491
  readonly buy: boolean;
@@ -491,7 +495,7 @@ declare function morpho(parameters: {
491
495
  readonly collaterals: readonly {
492
496
  asset: Address;
493
497
  oracle: Address;
494
- lltv: bigint;
498
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
495
499
  }[];
496
500
  readonly callback: {
497
501
  readonly address: Address;
@@ -505,7 +509,7 @@ declare function morpho(parameters: {
505
509
  readonly offering: Address;
506
510
  readonly assets: bigint;
507
511
  readonly rate: bigint;
508
- readonly maturity: number;
512
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
509
513
  readonly expiry: number;
510
514
  readonly nonce: bigint;
511
515
  readonly buy: boolean;
@@ -515,7 +519,7 @@ declare function morpho(parameters: {
515
519
  readonly collaterals: readonly {
516
520
  asset: Address;
517
521
  oracle: Address;
518
- lltv: bigint;
522
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
519
523
  }[];
520
524
  readonly callback: {
521
525
  readonly address: Address;
@@ -529,7 +533,7 @@ declare function morpho(parameters: {
529
533
  readonly offering: Address;
530
534
  readonly assets: bigint;
531
535
  readonly rate: bigint;
532
- readonly maturity: number;
536
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
533
537
  readonly expiry: number;
534
538
  readonly nonce: bigint;
535
539
  readonly buy: boolean;
@@ -539,7 +543,7 @@ declare function morpho(parameters: {
539
543
  readonly collaterals: readonly {
540
544
  asset: Address;
541
545
  oracle: Address;
542
- lltv: bigint;
546
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
543
547
  }[];
544
548
  readonly callback: {
545
549
  readonly address: Address;
@@ -553,7 +557,7 @@ declare function morpho(parameters: {
553
557
  readonly offering: Address;
554
558
  readonly assets: bigint;
555
559
  readonly rate: bigint;
556
- readonly maturity: number;
560
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
557
561
  readonly expiry: number;
558
562
  readonly nonce: bigint;
559
563
  readonly buy: boolean;
@@ -563,7 +567,7 @@ declare function morpho(parameters: {
563
567
  readonly collaterals: readonly {
564
568
  asset: Address;
565
569
  oracle: Address;
566
- lltv: bigint;
570
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
567
571
  }[];
568
572
  readonly callback: {
569
573
  readonly address: Address;
@@ -628,4 +632,4 @@ declare namespace Validation {
628
632
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
629
633
  }
630
634
 
631
- export { Chain$1 as Chain, type Compute, type Cursor, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, decodeCursor, encodeCursor, poll, validateCursor, wait };
635
+ export { Chain$1 as Chain, type Cursor, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, decodeCursor, encodeCursor, poll, validateCursor, wait };
@@ -720,6 +720,26 @@ zodOpenapi.createDocument({
720
720
  paths
721
721
  });
722
722
 
723
+ // src/core/apiSchema/utils.ts
724
+ function toResponse(routerOffer) {
725
+ const { consumed, status, metadata, ...offer } = routerOffer;
726
+ return {
727
+ offer,
728
+ consumed,
729
+ status,
730
+ metadata
731
+ };
732
+ }
733
+ function fromResponse(offerResponse) {
734
+ const { offer, consumed, status, metadata } = offerResponse;
735
+ return {
736
+ ...offer,
737
+ consumed,
738
+ status,
739
+ metadata
740
+ };
741
+ }
742
+
723
743
  // src/core/Client.ts
724
744
  function connect(opts) {
725
745
  const u = new URL(opts?.url || "https://router.morpho.dev");
@@ -821,9 +841,10 @@ async function get(config, parameters) {
821
841
  url.searchParams.set("limit", parameters.limit.toString());
822
842
  }
823
843
  const { cursor: returnedCursor, data: offers } = await getApi(config, url);
844
+ const routerOffers = offers.map(mempool.Format.fromSnakeCase).map(fromResponse);
824
845
  return {
825
846
  cursor: returnedCursor,
826
- offers: offers.map(fromSnakeCase)
847
+ offers: routerOffers.map(from).map(toResponse)
827
848
  };
828
849
  }
829
850
  async function match(config, parameters) {
@@ -862,9 +883,10 @@ async function match(config, parameters) {
862
883
  url.searchParams.set("limit", parameters.limit.toString());
863
884
  }
864
885
  const { cursor: returnedCursor, data: offers } = await getApi(config, url);
886
+ const routerOffers = offers.map(mempool.Format.fromSnakeCase).map(fromResponse);
865
887
  return {
866
888
  cursor: returnedCursor,
867
- offers: offers.map(fromSnakeCase)
889
+ offers: routerOffers.map(from).map(toResponse)
868
890
  };
869
891
  }
870
892
  async function getApi(config, url) {