@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.
- package/dist/index.browser.d.cts +24 -26
- package/dist/index.browser.d.ts +24 -26
- package/dist/index.browser.js +33 -13
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +33 -13
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +24 -26
- package/dist/index.node.d.ts +24 -26
- package/dist/index.node.js +33 -13
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +33 -13
- package/dist/index.node.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.node.d.cts
CHANGED
|
@@ -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
|
-
}) =>
|
|
141
|
-
offering:
|
|
142
|
-
assets:
|
|
143
|
-
rate:
|
|
144
|
-
maturity:
|
|
145
|
-
expiry:
|
|
146
|
-
start:
|
|
147
|
-
nonce:
|
|
148
|
-
buy:
|
|
149
|
-
chainId:
|
|
150
|
-
loanToken:
|
|
151
|
-
collaterals:
|
|
152
|
-
asset:
|
|
153
|
-
oracle:
|
|
154
|
-
lltv:
|
|
155
|
-
},
|
|
156
|
-
callback:
|
|
157
|
-
address:
|
|
158
|
-
data:
|
|
159
|
-
gasLimit:
|
|
160
|
-
},
|
|
161
|
-
signature:
|
|
162
|
-
createdAt:
|
|
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
|
-
},
|
|
171
|
+
}, z.core.$strip>;
|
|
174
172
|
/**
|
|
175
173
|
* ABI for the Consumed event emitted by the terms contract.
|
|
176
174
|
*/
|
package/dist/index.node.d.ts
CHANGED
|
@@ -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
|
-
}) =>
|
|
141
|
-
offering:
|
|
142
|
-
assets:
|
|
143
|
-
rate:
|
|
144
|
-
maturity:
|
|
145
|
-
expiry:
|
|
146
|
-
start:
|
|
147
|
-
nonce:
|
|
148
|
-
buy:
|
|
149
|
-
chainId:
|
|
150
|
-
loanToken:
|
|
151
|
-
collaterals:
|
|
152
|
-
asset:
|
|
153
|
-
oracle:
|
|
154
|
-
lltv:
|
|
155
|
-
},
|
|
156
|
-
callback:
|
|
157
|
-
address:
|
|
158
|
-
data:
|
|
159
|
-
gasLimit:
|
|
160
|
-
},
|
|
161
|
-
signature:
|
|
162
|
-
createdAt:
|
|
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
|
-
},
|
|
171
|
+
}, z.core.$strip>;
|
|
174
172
|
/**
|
|
175
173
|
* ABI for the Consumed event emitted by the terms contract.
|
|
176
174
|
*/
|
package/dist/index.node.js
CHANGED
|
@@ -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().
|
|
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
|
-
|
|
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().
|
|
557
|
-
|
|
558
|
-
|
|
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().
|
|
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
|
-
|
|
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) {
|