@morpho-dev/router 0.0.27 → 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 +25 -26
- package/dist/index.browser.d.ts +25 -26
- package/dist/index.browser.js +35 -15
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +35 -15
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +29 -28
- package/dist/index.node.d.ts +29 -28
- package/dist/index.node.js +75 -24
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +75 -24
- package/dist/index.node.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.browser.d.cts
CHANGED
|
@@ -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
|
-
}) =>
|
|
67
|
-
offering:
|
|
68
|
-
assets:
|
|
69
|
-
rate:
|
|
70
|
-
maturity:
|
|
71
|
-
expiry:
|
|
72
|
-
start:
|
|
73
|
-
nonce:
|
|
74
|
-
buy:
|
|
75
|
-
chainId:
|
|
76
|
-
loanToken:
|
|
77
|
-
collaterals:
|
|
78
|
-
asset:
|
|
79
|
-
oracle:
|
|
80
|
-
lltv:
|
|
81
|
-
},
|
|
82
|
-
callback:
|
|
83
|
-
address:
|
|
84
|
-
data:
|
|
85
|
-
gasLimit:
|
|
86
|
-
},
|
|
87
|
-
signature:
|
|
88
|
-
createdAt:
|
|
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
|
-
},
|
|
97
|
+
}, z.core.$strip>;
|
|
100
98
|
/**
|
|
101
99
|
* ABI for the Consumed event emitted by the terms contract.
|
|
102
100
|
*/
|
|
@@ -285,6 +283,7 @@ type Client = Compute<RouterClientConfig & {
|
|
|
285
283
|
declare function connect(opts?: {
|
|
286
284
|
url?: string;
|
|
287
285
|
apiKey?: string;
|
|
286
|
+
headers?: Headers;
|
|
288
287
|
}): Client;
|
|
289
288
|
declare namespace connect {
|
|
290
289
|
type ErrorType = InvalidUrlError;
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -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
|
-
}) =>
|
|
67
|
-
offering:
|
|
68
|
-
assets:
|
|
69
|
-
rate:
|
|
70
|
-
maturity:
|
|
71
|
-
expiry:
|
|
72
|
-
start:
|
|
73
|
-
nonce:
|
|
74
|
-
buy:
|
|
75
|
-
chainId:
|
|
76
|
-
loanToken:
|
|
77
|
-
collaterals:
|
|
78
|
-
asset:
|
|
79
|
-
oracle:
|
|
80
|
-
lltv:
|
|
81
|
-
},
|
|
82
|
-
callback:
|
|
83
|
-
address:
|
|
84
|
-
data:
|
|
85
|
-
gasLimit:
|
|
86
|
-
},
|
|
87
|
-
signature:
|
|
88
|
-
createdAt:
|
|
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
|
-
},
|
|
97
|
+
}, z.core.$strip>;
|
|
100
98
|
/**
|
|
101
99
|
* ABI for the Consumed event emitted by the terms contract.
|
|
102
100
|
*/
|
|
@@ -285,6 +283,7 @@ type Client = Compute<RouterClientConfig & {
|
|
|
285
283
|
declare function connect(opts?: {
|
|
286
284
|
url?: string;
|
|
287
285
|
apiKey?: string;
|
|
286
|
+
headers?: Headers;
|
|
288
287
|
}): Client;
|
|
289
288
|
declare namespace connect {
|
|
290
289
|
type ErrorType = InvalidUrlError;
|
package/dist/index.browser.js
CHANGED
|
@@ -41,7 +41,7 @@ function getChain(chainId) {
|
|
|
41
41
|
return chains[chainName];
|
|
42
42
|
}
|
|
43
43
|
var getWhitelistedChains = () => {
|
|
44
|
-
return [chains.ethereum, chains["ethereum-virtual-testnet"]];
|
|
44
|
+
return [chains.ethereum, chains.base, chains["ethereum-virtual-testnet"]];
|
|
45
45
|
};
|
|
46
46
|
var chains = {
|
|
47
47
|
ethereum: {
|
|
@@ -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().
|
|
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
|
-
|
|
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().
|
|
559
|
-
|
|
560
|
-
|
|
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().
|
|
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
|
-
|
|
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) {
|
|
@@ -828,7 +848,7 @@ function connect(opts) {
|
|
|
828
848
|
if (u.protocol !== "http:" && u.protocol !== "https:") {
|
|
829
849
|
throw new InvalidUrlError(u.toString());
|
|
830
850
|
}
|
|
831
|
-
const headers = new Headers();
|
|
851
|
+
const headers = opts?.headers ?? new Headers();
|
|
832
852
|
headers.set("Content-Type", "application/json");
|
|
833
853
|
opts?.apiKey !== void 0 ? headers.set("X-API-Key", opts.apiKey) : null;
|
|
834
854
|
const config = {
|