@morpho-dev/router 0.0.26 → 0.0.27

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.
@@ -27,7 +27,6 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
27
27
  name: ChainName;
28
28
  whitelistedAssets: Set<Address>;
29
29
  morpho: Address;
30
- termsContract: Address;
31
30
  mempool?: {
32
31
  address: Address;
33
32
  deploymentBlock: number;
@@ -35,6 +34,7 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
35
34
  };
36
35
  }>;
37
36
  declare function getChain(chainId: ChainId): Chain | undefined;
37
+ declare const getWhitelistedChains: () => Chain[];
38
38
  declare const chains: Record<ChainName, Chain>;
39
39
 
40
40
  type Chain$1_Chain = Chain;
@@ -44,8 +44,9 @@ declare const Chain$1_chainIds: typeof chainIds;
44
44
  declare const Chain$1_chainNames: typeof chainNames;
45
45
  declare const Chain$1_chains: typeof chains;
46
46
  declare const Chain$1_getChain: typeof getChain;
47
+ declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
47
48
  declare namespace Chain$1 {
48
- export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain };
49
+ export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain, Chain$1_getWhitelistedChains as getWhitelistedChains };
49
50
  }
50
51
 
51
52
  declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
@@ -65,8 +66,8 @@ declare const schemas: {
65
66
  max_amount: z.ZodOptional<z.ZodBigInt>;
66
67
  min_rate: z.ZodOptional<z.ZodBigInt>;
67
68
  max_rate: z.ZodOptional<z.ZodBigInt>;
68
- min_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
69
- max_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
69
+ min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
70
+ max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
70
71
  min_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
71
72
  max_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
72
73
  collateral_assets: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
@@ -76,8 +77,8 @@ declare const schemas: {
76
77
  oracle: string | undefined;
77
78
  lltv: (bigint & _morpho_dev_mempool.Brand<"LLTV">) | undefined;
78
79
  }[], string>>>;
79
- min_lltv: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, number>>>;
80
- max_lltv: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, number>>>;
80
+ min_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
81
+ max_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
81
82
  sort_by: z.ZodOptional<z.ZodEnum<{
82
83
  amount: "amount";
83
84
  rate: "rate";
@@ -103,9 +104,9 @@ declare const schemas: {
103
104
  oracle: string;
104
105
  lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
105
106
  }[], string>>>;
106
- maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
107
- min_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
108
- max_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
107
+ maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
108
+ min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
109
+ max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
109
110
  loan_token: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
110
111
  creator: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
111
112
  status: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<("valid" | "callback_not_supported" | "callback_error" | "unverified")[], string>>>;
@@ -498,8 +499,8 @@ type GetOffersFilters = {
498
499
  maxAmount?: bigint;
499
500
  minRate?: bigint;
500
501
  maxRate?: bigint;
501
- minMaturity?: Maturity.Maturity;
502
- maxMaturity?: Maturity.Maturity;
502
+ minMaturity?: number;
503
+ maxMaturity?: number;
503
504
  minExpiry?: number;
504
505
  maxExpiry?: number;
505
506
  collateralAssets?: string[];
@@ -509,8 +510,8 @@ type GetOffersFilters = {
509
510
  oracle?: string;
510
511
  lltv?: LLTV.LLTV;
511
512
  }>;
512
- minLltv?: LLTV.LLTV;
513
- maxLltv?: LLTV.LLTV;
513
+ minLltv?: number;
514
+ maxLltv?: number;
514
515
  sortBy?: "rate" | "maturity" | "expiry" | "amount";
515
516
  sortOrder?: "asc" | "desc";
516
517
  cursor?: string;
@@ -525,9 +526,9 @@ type FindMatchingOffersParams = {
525
526
  oracle: string;
526
527
  lltv: LLTV.LLTV;
527
528
  }>;
528
- maturity?: Maturity.Maturity;
529
- minMaturity?: Maturity.Maturity;
530
- maxMaturity?: Maturity.Maturity;
529
+ maturity?: number;
530
+ minMaturity?: number;
531
+ maxMaturity?: number;
531
532
  loanToken?: string;
532
533
  creator?: string;
533
534
  /** Filter by offer status; if omitted defaults to ["valid"] */
@@ -27,7 +27,6 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
27
27
  name: ChainName;
28
28
  whitelistedAssets: Set<Address>;
29
29
  morpho: Address;
30
- termsContract: Address;
31
30
  mempool?: {
32
31
  address: Address;
33
32
  deploymentBlock: number;
@@ -35,6 +34,7 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
35
34
  };
36
35
  }>;
37
36
  declare function getChain(chainId: ChainId): Chain | undefined;
37
+ declare const getWhitelistedChains: () => Chain[];
38
38
  declare const chains: Record<ChainName, Chain>;
39
39
 
40
40
  type Chain$1_Chain = Chain;
@@ -44,8 +44,9 @@ declare const Chain$1_chainIds: typeof chainIds;
44
44
  declare const Chain$1_chainNames: typeof chainNames;
45
45
  declare const Chain$1_chains: typeof chains;
46
46
  declare const Chain$1_getChain: typeof getChain;
47
+ declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
47
48
  declare namespace Chain$1 {
48
- export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain };
49
+ export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain, Chain$1_getWhitelistedChains as getWhitelistedChains };
49
50
  }
50
51
 
51
52
  declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
@@ -65,8 +66,8 @@ declare const schemas: {
65
66
  max_amount: z.ZodOptional<z.ZodBigInt>;
66
67
  min_rate: z.ZodOptional<z.ZodBigInt>;
67
68
  max_rate: z.ZodOptional<z.ZodBigInt>;
68
- min_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
69
- max_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
69
+ min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
70
+ max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
70
71
  min_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
71
72
  max_expiry: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
72
73
  collateral_assets: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
@@ -76,8 +77,8 @@ declare const schemas: {
76
77
  oracle: string | undefined;
77
78
  lltv: (bigint & _morpho_dev_mempool.Brand<"LLTV">) | undefined;
78
79
  }[], string>>>;
79
- min_lltv: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, number>>>;
80
- max_lltv: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, number>>>;
80
+ min_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
81
+ max_lltv: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
81
82
  sort_by: z.ZodOptional<z.ZodEnum<{
82
83
  amount: "amount";
83
84
  rate: "rate";
@@ -103,9 +104,9 @@ declare const schemas: {
103
104
  oracle: string;
104
105
  lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
105
106
  }[], string>>>;
106
- maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
107
- min_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
108
- max_maturity: z.ZodOptional<z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>>;
107
+ maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
108
+ min_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
109
+ max_maturity: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
109
110
  loan_token: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
110
111
  creator: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
111
112
  status: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<("valid" | "callback_not_supported" | "callback_error" | "unverified")[], string>>>;
@@ -498,8 +499,8 @@ type GetOffersFilters = {
498
499
  maxAmount?: bigint;
499
500
  minRate?: bigint;
500
501
  maxRate?: bigint;
501
- minMaturity?: Maturity.Maturity;
502
- maxMaturity?: Maturity.Maturity;
502
+ minMaturity?: number;
503
+ maxMaturity?: number;
503
504
  minExpiry?: number;
504
505
  maxExpiry?: number;
505
506
  collateralAssets?: string[];
@@ -509,8 +510,8 @@ type GetOffersFilters = {
509
510
  oracle?: string;
510
511
  lltv?: LLTV.LLTV;
511
512
  }>;
512
- minLltv?: LLTV.LLTV;
513
- maxLltv?: LLTV.LLTV;
513
+ minLltv?: number;
514
+ maxLltv?: number;
514
515
  sortBy?: "rate" | "maturity" | "expiry" | "amount";
515
516
  sortOrder?: "asc" | "desc";
516
517
  cursor?: string;
@@ -525,9 +526,9 @@ type FindMatchingOffersParams = {
525
526
  oracle: string;
526
527
  lltv: LLTV.LLTV;
527
528
  }>;
528
- maturity?: Maturity.Maturity;
529
- minMaturity?: Maturity.Maturity;
530
- maxMaturity?: Maturity.Maturity;
529
+ maturity?: number;
530
+ minMaturity?: number;
531
+ maxMaturity?: number;
531
532
  loanToken?: string;
532
533
  creator?: string;
533
534
  /** Filter by offer status; if omitted defaults to ["valid"] */
@@ -23,7 +23,8 @@ __export(Chain_exports, {
23
23
  chainIds: () => chainIds,
24
24
  chainNames: () => chainNames,
25
25
  chains: () => chains,
26
- getChain: () => getChain
26
+ getChain: () => getChain,
27
+ getWhitelistedChains: () => getWhitelistedChains
27
28
  });
28
29
  var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
29
30
  var ChainId = {
@@ -40,6 +41,9 @@ function getChain(chainId) {
40
41
  }
41
42
  return chains[chainName];
42
43
  }
44
+ var getWhitelistedChains = () => {
45
+ return [chains.ethereum, chains["ethereum-virtual-testnet"]];
46
+ };
43
47
  var chains = {
44
48
  ethereum: {
45
49
  ...chains$1.mainnet,
@@ -53,8 +57,7 @@ var chains = {
53
57
  // DAI
54
58
  ].map((address) => address.toLowerCase())
55
59
  ),
56
- morpho: "0x0000000000000000000000000000000000000000",
57
- termsContract: "0x0000000000000000000000000000000000000000"
60
+ morpho: "0x0000000000000000000000000000000000000000"
58
61
  },
59
62
  base: {
60
63
  ...chains$1.base,
@@ -68,8 +71,7 @@ var chains = {
68
71
  // DAI
69
72
  ].map((address) => address.toLowerCase())
70
73
  ),
71
- morpho: "0x0000000000000000000000000000000000000000",
72
- termsContract: "0x0000000000000000000000000000000000000000"
74
+ morpho: "0x0000000000000000000000000000000000000000"
73
75
  },
74
76
  "ethereum-virtual-testnet": {
75
77
  ...chains$1.mainnet,
@@ -83,8 +85,8 @@ var chains = {
83
85
  // DAI
84
86
  ].map((address) => address.toLowerCase())
85
87
  ),
86
- morpho: "0x0000000000000000000000000000000000000000",
87
- termsContract: "0xa85d462ceb11d6f91f003072fdc701b0a1bbd8bd",
88
+ morpho: "0x11a002d45db720ed47a80d2f3489cba5b833eaf5",
89
+ // @TODO: This is mock Consumed contract, update with Terms once stable
88
90
  mempool: {
89
91
  address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
90
92
  deploymentBlock: 23223727,
@@ -387,28 +389,14 @@ var GetOffersQueryParams = v4.z.object({
387
389
  example: "1500000000000000000"
388
390
  }),
389
391
  // Time range
390
- min_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
391
- try {
392
- return mempool.Maturity.from(maturity);
393
- } catch (e) {
394
- ctx.addIssue({
395
- code: "custom",
396
- message: e.message
397
- });
398
- return v4.z.NEVER;
399
- }
400
- }).optional(),
401
- max_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
402
- try {
403
- return mempool.Maturity.from(maturity);
404
- } catch (e) {
405
- ctx.addIssue({
406
- code: "custom",
407
- message: e.message
408
- });
409
- return v4.z.NEVER;
410
- }
411
- }).optional(),
392
+ min_maturity: v4.z.coerce.number().int().min(0).optional().meta({
393
+ description: "Minimum maturity timestamp (Unix timestamp in seconds)",
394
+ example: "1700000000"
395
+ }),
396
+ max_maturity: v4.z.coerce.number().int().min(0).optional().meta({
397
+ description: "Maximum maturity timestamp (Unix timestamp in seconds)",
398
+ example: "1800000000"
399
+ }),
412
400
  min_expiry: v4.z.coerce.number().int().optional().meta({
413
401
  description: "Minimum expiry timestamp (Unix timestamp in seconds)",
414
402
  example: "1700000000"
@@ -483,33 +471,11 @@ var GetOffersQueryParams = v4.z.object({
483
471
  description: "Filter by collateral combinations in format: asset:oracle:lltv#asset2:oracle2:lltv2. Oracle and lltv are optional. Use # to separate multiple combinations.",
484
472
  example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:86#0x9876543210987654321098765432109876543210:94.5"
485
473
  }),
486
- min_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).transform((lltv, ctx) => {
487
- try {
488
- return mempool.LLTV.from(viem.parseUnits(lltv.toString(), 16));
489
- } catch (e) {
490
- ctx.addIssue({
491
- code: "custom",
492
- message: e.message,
493
- input: lltv
494
- });
495
- return v4.z.NEVER;
496
- }
497
- }).optional().meta({
474
+ min_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).optional().meta({
498
475
  description: "Minimum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal, e.g., 80.5 = 80.5%)",
499
476
  example: "80.5"
500
477
  }),
501
- max_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).transform((lltv, ctx) => {
502
- try {
503
- return mempool.LLTV.from(viem.parseUnits(lltv.toString(), 16));
504
- } catch (e) {
505
- ctx.addIssue({
506
- code: "custom",
507
- message: e.message,
508
- input: lltv
509
- });
510
- return v4.z.NEVER;
511
- }
512
- }).optional().meta({
478
+ max_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).optional().meta({
513
479
  description: "Maximum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal, e.g., 95.5 = 95.5%)",
514
480
  example: "95.5"
515
481
  }),
@@ -652,39 +618,18 @@ var MatchOffersQueryParams = v4.z.object({
652
618
  example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:86#0x9876543210987654321098765432109876543210:0xfedcbafedcbafedcbafedcbafedcbafedcbafedc:94.5"
653
619
  }),
654
620
  // Maturity filtering
655
- maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
656
- try {
657
- return mempool.Maturity.from(maturity);
658
- } catch (e) {
659
- ctx.addIssue({
660
- code: "custom",
661
- message: e.message
662
- });
663
- return v4.z.NEVER;
664
- }
665
- }).optional(),
666
- min_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
667
- try {
668
- return mempool.Maturity.from(maturity);
669
- } catch (e) {
670
- ctx.addIssue({
671
- code: "custom",
672
- message: e.message
673
- });
674
- return v4.z.NEVER;
675
- }
676
- }).optional(),
677
- max_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
678
- try {
679
- return mempool.Maturity.from(maturity);
680
- } catch (e) {
681
- ctx.addIssue({
682
- code: "custom",
683
- message: e.message
684
- });
685
- return v4.z.NEVER;
686
- }
687
- }).optional(),
621
+ maturity: v4.z.coerce.number().int().min(0).optional().meta({
622
+ description: "Maturity timestamp (Unix timestamp in seconds)",
623
+ example: "1700000000"
624
+ }),
625
+ min_maturity: v4.z.coerce.number().int().min(0).optional().meta({
626
+ description: "Minimum maturity timestamp (Unix timestamp in seconds)",
627
+ example: "1700000000"
628
+ }),
629
+ max_maturity: v4.z.coerce.number().int().min(0).optional().meta({
630
+ description: "Maximum maturity timestamp (Unix timestamp in seconds)",
631
+ example: "1800000000"
632
+ }),
688
633
  // Asset and creator filtering
689
634
  loan_token: v4.z.string().regex(/^0x[a-fA-F0-9]{40}$/, {
690
635
  message: "Loan asset must be a valid Ethereum address"
@@ -1306,8 +1251,12 @@ function memory(parameters) {
1306
1251
  )
1307
1252
  )
1308
1253
  ));
1309
- minLltv && (offers = offers.filter((o) => o.collaterals.every((c) => c.lltv >= minLltv)));
1310
- maxLltv && (offers = offers.filter((o) => o.collaterals.every((c) => c.lltv <= maxLltv)));
1254
+ minLltv && (offers = offers.filter(
1255
+ (o) => o.collaterals.every((c) => c.lltv >= viem.parseUnits(minLltv.toString(), 16))
1256
+ ));
1257
+ maxLltv && (offers = offers.filter(
1258
+ (o) => o.collaterals.every((c) => c.lltv <= viem.parseUnits(maxLltv.toString(), 16))
1259
+ ));
1311
1260
  offers = offers.sort((a, b) => sort(sortBy, sortOrder, a, b));
1312
1261
  let nextCursor = null;
1313
1262
  if (offers.length > limit) {