@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.
@@ -5,9 +5,7 @@ import * as viem from 'viem';
5
5
  import { Address, Hex, PublicClient } from 'viem';
6
6
  import { Chain as Chain$2 } from 'viem/chains';
7
7
  import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
8
- import * as zod_v4 from 'zod/v4';
9
8
  import { z, ZodError } from 'zod/v4';
10
- import * as zod_v4_core from 'zod/v4/core';
11
9
  import * as hono_utils_types from 'hono/utils/types';
12
10
  import * as hono from 'hono';
13
11
  import { Context } from 'hono';
@@ -137,29 +135,29 @@ type OfferConsumed = {
137
135
  };
138
136
  declare const RouterOfferSchema: (parameters?: {
139
137
  omitHash?: boolean;
140
- }) => zod_v4.ZodObject<{
141
- offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
142
- assets: zod_v4.ZodBigInt;
143
- rate: zod_v4.ZodBigInt;
144
- maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
145
- expiry: zod_v4.ZodNumber;
146
- start: zod_v4.ZodNumber;
147
- nonce: zod_v4.ZodBigInt;
148
- buy: zod_v4.ZodBoolean;
149
- chainId: zod_v4.ZodBigInt;
150
- loanToken: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
151
- collaterals: zod_v4.ZodArray<zod_v4.ZodObject<{
152
- asset: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
153
- oracle: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
154
- lltv: zod_v4.ZodPipe<zod_v4.ZodBigInt, zod_v4.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
155
- }, zod_v4_core.$strip>>;
156
- callback: zod_v4.ZodObject<{
157
- address: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
158
- data: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
159
- gasLimit: zod_v4.ZodBigInt;
160
- }, zod_v4_core.$strip>;
161
- signature: zod_v4.ZodOptional<zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>>;
162
- createdAt: zod_v4.ZodOptional<zod_v4.ZodNumber>;
138
+ }) => z.ZodObject<{
139
+ offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
140
+ assets: z.ZodBigInt;
141
+ rate: z.ZodBigInt;
142
+ maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
143
+ expiry: z.ZodNumber;
144
+ start: z.ZodNumber;
145
+ nonce: z.ZodBigInt;
146
+ buy: z.ZodBoolean;
147
+ chainId: z.ZodBigInt;
148
+ loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
149
+ collaterals: z.ZodArray<z.ZodObject<{
150
+ asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
151
+ oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
152
+ lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
153
+ }, z.core.$strip>>;
154
+ callback: z.ZodObject<{
155
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
156
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
157
+ gasLimit: z.ZodBigInt;
158
+ }, z.core.$strip>;
159
+ signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
160
+ createdAt: z.ZodOptional<z.ZodNumber>;
163
161
  consumed: z.ZodBigInt;
164
162
  status: z.ZodEnum<{
165
163
  valid: "valid";
@@ -170,7 +168,7 @@ declare const RouterOfferSchema: (parameters?: {
170
168
  metadata: z.ZodOptional<z.ZodObject<{
171
169
  issue: z.ZodString;
172
170
  }, z.core.$strip>>;
173
- }, zod_v4_core.$strip>;
171
+ }, z.core.$strip>;
174
172
  /**
175
173
  * ABI for the Consumed event emitted by the terms contract.
176
174
  */
@@ -5,9 +5,7 @@ import * as viem from 'viem';
5
5
  import { Address, Hex, PublicClient } from 'viem';
6
6
  import { Chain as Chain$2 } from 'viem/chains';
7
7
  import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
8
- import * as zod_v4 from 'zod/v4';
9
8
  import { z, ZodError } from 'zod/v4';
10
- import * as zod_v4_core from 'zod/v4/core';
11
9
  import * as hono_utils_types from 'hono/utils/types';
12
10
  import * as hono from 'hono';
13
11
  import { Context } from 'hono';
@@ -137,29 +135,29 @@ type OfferConsumed = {
137
135
  };
138
136
  declare const RouterOfferSchema: (parameters?: {
139
137
  omitHash?: boolean;
140
- }) => zod_v4.ZodObject<{
141
- offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
142
- assets: zod_v4.ZodBigInt;
143
- rate: zod_v4.ZodBigInt;
144
- maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
145
- expiry: zod_v4.ZodNumber;
146
- start: zod_v4.ZodNumber;
147
- nonce: zod_v4.ZodBigInt;
148
- buy: zod_v4.ZodBoolean;
149
- chainId: zod_v4.ZodBigInt;
150
- loanToken: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
151
- collaterals: zod_v4.ZodArray<zod_v4.ZodObject<{
152
- asset: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
153
- oracle: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
154
- lltv: zod_v4.ZodPipe<zod_v4.ZodBigInt, zod_v4.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
155
- }, zod_v4_core.$strip>>;
156
- callback: zod_v4.ZodObject<{
157
- address: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
158
- data: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
159
- gasLimit: zod_v4.ZodBigInt;
160
- }, zod_v4_core.$strip>;
161
- signature: zod_v4.ZodOptional<zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>>;
162
- createdAt: zod_v4.ZodOptional<zod_v4.ZodNumber>;
138
+ }) => z.ZodObject<{
139
+ offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
140
+ assets: z.ZodBigInt;
141
+ rate: z.ZodBigInt;
142
+ maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
143
+ expiry: z.ZodNumber;
144
+ start: z.ZodNumber;
145
+ nonce: z.ZodBigInt;
146
+ buy: z.ZodBoolean;
147
+ chainId: z.ZodBigInt;
148
+ loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
149
+ collaterals: z.ZodArray<z.ZodObject<{
150
+ asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
151
+ oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
152
+ lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
153
+ }, z.core.$strip>>;
154
+ callback: z.ZodObject<{
155
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
156
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
157
+ gasLimit: z.ZodBigInt;
158
+ }, z.core.$strip>;
159
+ signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
160
+ createdAt: z.ZodOptional<z.ZodNumber>;
163
161
  consumed: z.ZodBigInt;
164
162
  status: z.ZodEnum<{
165
163
  valid: "valid";
@@ -170,7 +168,7 @@ declare const RouterOfferSchema: (parameters?: {
170
168
  metadata: z.ZodOptional<z.ZodObject<{
171
169
  issue: z.ZodString;
172
170
  }, z.core.$strip>>;
173
- }, zod_v4_core.$strip>;
171
+ }, z.core.$strip>;
174
172
  /**
175
173
  * ABI for the Consumed event emitted by the terms contract.
176
174
  */
@@ -418,12 +418,15 @@ var GetOffersQueryParams = v4.z.object({
418
418
  description: "Filter by multiple rate oracles (comma-separated)",
419
419
  example: "0x1234567890123456789012345678901234567890,0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"
420
420
  }),
421
- collateral_tuple: v4.z.string().regex(
422
- /^(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]+)?)?)*$/,
423
- {
424
- 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)."
421
+ collateral_tuple: v4.z.string().transform((val, ctx) => {
422
+ 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]+)?)?)*$/;
423
+ if (!pattern.test(val)) {
424
+ ctx.addIssue({
425
+ code: "custom",
426
+ message: "collateral_tuple has an invalid format",
427
+ input: val
428
+ });
425
429
  }
426
- ).transform((val, ctx) => {
427
430
  return val.split("#").map((tuple) => {
428
431
  const parts = tuple.split(":");
429
432
  if (parts.length === 0 || !parts[0]) {
@@ -553,9 +556,23 @@ var MatchOffersQueryParams = v4.z.object({
553
556
  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.",
554
557
  example: "buy"
555
558
  }),
556
- chain_id: v4.z.string().regex(/^\d+$/, {
557
- message: "Chain ID must be a positive integer"
558
- }).transform((val) => Number.parseInt(val, 10)).pipe(v4.z.number().positive()).meta({
559
+ chain_id: v4.z.string().transform((val, ctx) => {
560
+ const numericLike = /^-?\d+$/.test(val);
561
+ if (!numericLike) {
562
+ ctx.addIssue({
563
+ code: "custom",
564
+ message: "chain_id has an invalid format",
565
+ input: val
566
+ });
567
+ ctx.addIssue({
568
+ code: "custom",
569
+ message: "Invalid input: expected number, received NaN",
570
+ input: val
571
+ });
572
+ return v4.z.NEVER;
573
+ }
574
+ return Number.parseInt(val, 10);
575
+ }).pipe(v4.z.number().positive()).meta({
559
576
  description: "The blockchain network chain ID",
560
577
  example: "1"
561
578
  }),
@@ -567,12 +584,15 @@ var MatchOffersQueryParams = v4.z.object({
567
584
  example: "1000000000000000000"
568
585
  }),
569
586
  // Collateral filtering
570
- collaterals: v4.z.string().regex(
571
- /^(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]+)?)*$/,
572
- {
573
- message: "Collaterals must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. All fields are required for each collateral."
587
+ collaterals: v4.z.string().transform((val, ctx) => {
588
+ 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]+)?)*$/;
589
+ if (!pattern.test(val)) {
590
+ ctx.addIssue({
591
+ code: "custom",
592
+ message: "Collaterals must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. All fields are required for each collateral.",
593
+ input: val
594
+ });
574
595
  }
575
- ).transform((val, ctx) => {
576
596
  return val.split("#").map((collateral) => {
577
597
  const parts = collateral.split(":");
578
598
  if (parts.length !== 3) {