@morpho-dev/router 0.1.0 → 0.1.1

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.
@@ -4,8 +4,6 @@ export * from '@morpho-dev/mempool';
4
4
  import * as viem from 'viem';
5
5
  import { Address, Hex, PublicClient } from 'viem';
6
6
  import { Chain as Chain$2 } from 'viem/chains';
7
- import * as zod_v4_core from 'zod/v4/core';
8
- import * as zod_v4 from 'zod/v4';
9
7
  import { z, ZodError } from 'zod/v4';
10
8
 
11
9
  declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
@@ -63,29 +61,29 @@ type OfferConsumed = {
63
61
  };
64
62
  declare const RouterOfferSchema: (parameters?: {
65
63
  omitHash?: boolean;
66
- }) => zod_v4.ZodObject<{
67
- offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
68
- assets: zod_v4.ZodBigInt;
69
- rate: zod_v4.ZodBigInt;
70
- maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
71
- expiry: zod_v4.ZodNumber;
72
- start: zod_v4.ZodNumber;
73
- nonce: zod_v4.ZodBigInt;
74
- buy: zod_v4.ZodBoolean;
75
- chainId: zod_v4.ZodBigInt;
76
- loanToken: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
77
- collaterals: zod_v4.ZodArray<zod_v4.ZodObject<{
78
- asset: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
79
- oracle: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
80
- lltv: zod_v4.ZodPipe<zod_v4.ZodBigInt, zod_v4.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
81
- }, zod_v4_core.$strip>>;
82
- callback: zod_v4.ZodObject<{
83
- address: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
84
- data: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
85
- gasLimit: zod_v4.ZodBigInt;
86
- }, zod_v4_core.$strip>;
87
- signature: zod_v4.ZodOptional<zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>>;
88
- createdAt: zod_v4.ZodOptional<zod_v4.ZodNumber>;
64
+ }) => z.ZodObject<{
65
+ offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
66
+ assets: z.ZodBigInt;
67
+ rate: z.ZodBigInt;
68
+ maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
69
+ expiry: z.ZodNumber;
70
+ start: z.ZodNumber;
71
+ nonce: z.ZodBigInt;
72
+ buy: z.ZodBoolean;
73
+ chainId: z.ZodBigInt;
74
+ loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
75
+ collaterals: z.ZodArray<z.ZodObject<{
76
+ asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
77
+ oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
78
+ lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
79
+ }, z.core.$strip>>;
80
+ callback: z.ZodObject<{
81
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
82
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
83
+ gasLimit: z.ZodBigInt;
84
+ }, z.core.$strip>;
85
+ signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
86
+ createdAt: z.ZodOptional<z.ZodNumber>;
89
87
  consumed: z.ZodBigInt;
90
88
  status: z.ZodEnum<{
91
89
  valid: "valid";
@@ -96,7 +94,7 @@ declare const RouterOfferSchema: (parameters?: {
96
94
  metadata: z.ZodOptional<z.ZodObject<{
97
95
  issue: z.ZodString;
98
96
  }, z.core.$strip>>;
99
- }, zod_v4_core.$strip>;
97
+ }, z.core.$strip>;
100
98
  /**
101
99
  * ABI for the Consumed event emitted by the terms contract.
102
100
  */
@@ -4,8 +4,6 @@ export * from '@morpho-dev/mempool';
4
4
  import * as viem from 'viem';
5
5
  import { Address, Hex, PublicClient } from 'viem';
6
6
  import { Chain as Chain$2 } from 'viem/chains';
7
- import * as zod_v4_core from 'zod/v4/core';
8
- import * as zod_v4 from 'zod/v4';
9
7
  import { z, ZodError } from 'zod/v4';
10
8
 
11
9
  declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
@@ -63,29 +61,29 @@ type OfferConsumed = {
63
61
  };
64
62
  declare const RouterOfferSchema: (parameters?: {
65
63
  omitHash?: boolean;
66
- }) => zod_v4.ZodObject<{
67
- offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
68
- assets: zod_v4.ZodBigInt;
69
- rate: zod_v4.ZodBigInt;
70
- maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
71
- expiry: zod_v4.ZodNumber;
72
- start: zod_v4.ZodNumber;
73
- nonce: zod_v4.ZodBigInt;
74
- buy: zod_v4.ZodBoolean;
75
- chainId: zod_v4.ZodBigInt;
76
- loanToken: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
77
- collaterals: zod_v4.ZodArray<zod_v4.ZodObject<{
78
- asset: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
79
- oracle: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
80
- lltv: zod_v4.ZodPipe<zod_v4.ZodBigInt, zod_v4.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
81
- }, zod_v4_core.$strip>>;
82
- callback: zod_v4.ZodObject<{
83
- address: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
84
- data: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
85
- gasLimit: zod_v4.ZodBigInt;
86
- }, zod_v4_core.$strip>;
87
- signature: zod_v4.ZodOptional<zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>>;
88
- createdAt: zod_v4.ZodOptional<zod_v4.ZodNumber>;
64
+ }) => z.ZodObject<{
65
+ offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
66
+ assets: z.ZodBigInt;
67
+ rate: z.ZodBigInt;
68
+ maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
69
+ expiry: z.ZodNumber;
70
+ start: z.ZodNumber;
71
+ nonce: z.ZodBigInt;
72
+ buy: z.ZodBoolean;
73
+ chainId: z.ZodBigInt;
74
+ loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
75
+ collaterals: z.ZodArray<z.ZodObject<{
76
+ asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
77
+ oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
78
+ lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
79
+ }, z.core.$strip>>;
80
+ callback: z.ZodObject<{
81
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
82
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
83
+ gasLimit: z.ZodBigInt;
84
+ }, z.core.$strip>;
85
+ signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
86
+ createdAt: z.ZodOptional<z.ZodNumber>;
89
87
  consumed: z.ZodBigInt;
90
88
  status: z.ZodEnum<{
91
89
  valid: "valid";
@@ -96,7 +94,7 @@ declare const RouterOfferSchema: (parameters?: {
96
94
  metadata: z.ZodOptional<z.ZodObject<{
97
95
  issue: z.ZodString;
98
96
  }, z.core.$strip>>;
99
- }, zod_v4_core.$strip>;
97
+ }, z.core.$strip>;
100
98
  /**
101
99
  * ABI for the Consumed event emitted by the terms contract.
102
100
  */
@@ -420,12 +420,15 @@ var GetOffersQueryParams = v4.z.object({
420
420
  description: "Filter by multiple rate oracles (comma-separated)",
421
421
  example: "0x1234567890123456789012345678901234567890,0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"
422
422
  }),
423
- collateral_tuple: v4.z.string().regex(
424
- /^(0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)(#0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)*$/,
425
- {
426
- message: "Collateral tuple must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. Oracle and lltv are optional. Asset must be 0x + 40 hex chars, oracle must be 0x + 40 hex chars, lltv must be a number (e.g., 80.5)."
423
+ collateral_tuple: v4.z.string().transform((val, ctx) => {
424
+ const pattern = /^(0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)(#0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)*$/;
425
+ if (!pattern.test(val)) {
426
+ ctx.addIssue({
427
+ code: "custom",
428
+ message: "collateral_tuple has an invalid format",
429
+ input: val
430
+ });
427
431
  }
428
- ).transform((val, ctx) => {
429
432
  return val.split("#").map((tuple) => {
430
433
  const parts = tuple.split(":");
431
434
  if (parts.length === 0 || !parts[0]) {
@@ -555,9 +558,23 @@ var MatchOffersQueryParams = v4.z.object({
555
558
  description: "The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell. If your intent is to sell, buy offers will be returned, and vice versa.",
556
559
  example: "buy"
557
560
  }),
558
- chain_id: v4.z.string().regex(/^\d+$/, {
559
- message: "Chain ID must be a positive integer"
560
- }).transform((val) => Number.parseInt(val, 10)).pipe(v4.z.number().positive()).meta({
561
+ chain_id: v4.z.string().transform((val, ctx) => {
562
+ const numericLike = /^-?\d+$/.test(val);
563
+ if (!numericLike) {
564
+ ctx.addIssue({
565
+ code: "custom",
566
+ message: "chain_id has an invalid format",
567
+ input: val
568
+ });
569
+ ctx.addIssue({
570
+ code: "custom",
571
+ message: "Invalid input: expected number, received NaN",
572
+ input: val
573
+ });
574
+ return v4.z.NEVER;
575
+ }
576
+ return Number.parseInt(val, 10);
577
+ }).pipe(v4.z.number().positive()).meta({
561
578
  description: "The blockchain network chain ID",
562
579
  example: "1"
563
580
  }),
@@ -569,12 +586,15 @@ var MatchOffersQueryParams = v4.z.object({
569
586
  example: "1000000000000000000"
570
587
  }),
571
588
  // Collateral filtering
572
- collaterals: v4.z.string().regex(
573
- /^(0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)(#0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)*$/,
574
- {
575
- message: "Collaterals must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. All fields are required for each collateral."
589
+ collaterals: v4.z.string().transform((val, ctx) => {
590
+ const pattern = /^(0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)(#0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)*$/;
591
+ if (!pattern.test(val)) {
592
+ ctx.addIssue({
593
+ code: "custom",
594
+ message: "Collaterals must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. All fields are required for each collateral.",
595
+ input: val
596
+ });
576
597
  }
577
- ).transform((val, ctx) => {
578
598
  return val.split("#").map((collateral) => {
579
599
  const parts = collateral.split(":");
580
600
  if (parts.length !== 3) {