@morpho-dev/router 0.0.26 → 0.1.0
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 +11 -9
- package/dist/index.browser.d.ts +11 -9
- package/dist/index.browser.js +38 -89
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +39 -90
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +22 -18
- package/dist/index.node.d.ts +22 -18
- package/dist/index.node.js +78 -98
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +79 -99
- package/dist/index.node.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.browser.d.cts
CHANGED
|
@@ -22,7 +22,6 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
|
22
22
|
name: ChainName;
|
|
23
23
|
whitelistedAssets: Set<Address>;
|
|
24
24
|
morpho: Address;
|
|
25
|
-
termsContract: Address;
|
|
26
25
|
mempool?: {
|
|
27
26
|
address: Address;
|
|
28
27
|
deploymentBlock: number;
|
|
@@ -30,6 +29,7 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
|
30
29
|
};
|
|
31
30
|
}>;
|
|
32
31
|
declare function getChain(chainId: ChainId): Chain | undefined;
|
|
32
|
+
declare const getWhitelistedChains: () => Chain[];
|
|
33
33
|
declare const chains: Record<ChainName, Chain>;
|
|
34
34
|
|
|
35
35
|
type Chain$1_Chain = Chain;
|
|
@@ -39,8 +39,9 @@ declare const Chain$1_chainIds: typeof chainIds;
|
|
|
39
39
|
declare const Chain$1_chainNames: typeof chainNames;
|
|
40
40
|
declare const Chain$1_chains: typeof chains;
|
|
41
41
|
declare const Chain$1_getChain: typeof getChain;
|
|
42
|
+
declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
|
|
42
43
|
declare namespace Chain$1 {
|
|
43
|
-
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 };
|
|
44
|
+
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 };
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
|
|
@@ -284,6 +285,7 @@ type Client = Compute<RouterClientConfig & {
|
|
|
284
285
|
declare function connect(opts?: {
|
|
285
286
|
url?: string;
|
|
286
287
|
apiKey?: string;
|
|
288
|
+
headers?: Headers;
|
|
287
289
|
}): Client;
|
|
288
290
|
declare namespace connect {
|
|
289
291
|
type ErrorType = InvalidUrlError;
|
|
@@ -423,8 +425,8 @@ type GetOffersFilters = {
|
|
|
423
425
|
maxAmount?: bigint;
|
|
424
426
|
minRate?: bigint;
|
|
425
427
|
maxRate?: bigint;
|
|
426
|
-
minMaturity?:
|
|
427
|
-
maxMaturity?:
|
|
428
|
+
minMaturity?: number;
|
|
429
|
+
maxMaturity?: number;
|
|
428
430
|
minExpiry?: number;
|
|
429
431
|
maxExpiry?: number;
|
|
430
432
|
collateralAssets?: string[];
|
|
@@ -434,8 +436,8 @@ type GetOffersFilters = {
|
|
|
434
436
|
oracle?: string;
|
|
435
437
|
lltv?: LLTV.LLTV;
|
|
436
438
|
}>;
|
|
437
|
-
minLltv?:
|
|
438
|
-
maxLltv?:
|
|
439
|
+
minLltv?: number;
|
|
440
|
+
maxLltv?: number;
|
|
439
441
|
sortBy?: "rate" | "maturity" | "expiry" | "amount";
|
|
440
442
|
sortOrder?: "asc" | "desc";
|
|
441
443
|
cursor?: string;
|
|
@@ -450,9 +452,9 @@ type FindMatchingOffersParams = {
|
|
|
450
452
|
oracle: string;
|
|
451
453
|
lltv: LLTV.LLTV;
|
|
452
454
|
}>;
|
|
453
|
-
maturity?:
|
|
454
|
-
minMaturity?:
|
|
455
|
-
maxMaturity?:
|
|
455
|
+
maturity?: number;
|
|
456
|
+
minMaturity?: number;
|
|
457
|
+
maxMaturity?: number;
|
|
456
458
|
loanToken?: string;
|
|
457
459
|
creator?: string;
|
|
458
460
|
/** Filter by offer status; if omitted defaults to ["valid"] */
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
|
22
22
|
name: ChainName;
|
|
23
23
|
whitelistedAssets: Set<Address>;
|
|
24
24
|
morpho: Address;
|
|
25
|
-
termsContract: Address;
|
|
26
25
|
mempool?: {
|
|
27
26
|
address: Address;
|
|
28
27
|
deploymentBlock: number;
|
|
@@ -30,6 +29,7 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
|
30
29
|
};
|
|
31
30
|
}>;
|
|
32
31
|
declare function getChain(chainId: ChainId): Chain | undefined;
|
|
32
|
+
declare const getWhitelistedChains: () => Chain[];
|
|
33
33
|
declare const chains: Record<ChainName, Chain>;
|
|
34
34
|
|
|
35
35
|
type Chain$1_Chain = Chain;
|
|
@@ -39,8 +39,9 @@ declare const Chain$1_chainIds: typeof chainIds;
|
|
|
39
39
|
declare const Chain$1_chainNames: typeof chainNames;
|
|
40
40
|
declare const Chain$1_chains: typeof chains;
|
|
41
41
|
declare const Chain$1_getChain: typeof getChain;
|
|
42
|
+
declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
|
|
42
43
|
declare namespace Chain$1 {
|
|
43
|
-
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 };
|
|
44
|
+
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 };
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
|
|
@@ -284,6 +285,7 @@ type Client = Compute<RouterClientConfig & {
|
|
|
284
285
|
declare function connect(opts?: {
|
|
285
286
|
url?: string;
|
|
286
287
|
apiKey?: string;
|
|
288
|
+
headers?: Headers;
|
|
287
289
|
}): Client;
|
|
288
290
|
declare namespace connect {
|
|
289
291
|
type ErrorType = InvalidUrlError;
|
|
@@ -423,8 +425,8 @@ type GetOffersFilters = {
|
|
|
423
425
|
maxAmount?: bigint;
|
|
424
426
|
minRate?: bigint;
|
|
425
427
|
maxRate?: bigint;
|
|
426
|
-
minMaturity?:
|
|
427
|
-
maxMaturity?:
|
|
428
|
+
minMaturity?: number;
|
|
429
|
+
maxMaturity?: number;
|
|
428
430
|
minExpiry?: number;
|
|
429
431
|
maxExpiry?: number;
|
|
430
432
|
collateralAssets?: string[];
|
|
@@ -434,8 +436,8 @@ type GetOffersFilters = {
|
|
|
434
436
|
oracle?: string;
|
|
435
437
|
lltv?: LLTV.LLTV;
|
|
436
438
|
}>;
|
|
437
|
-
minLltv?:
|
|
438
|
-
maxLltv?:
|
|
439
|
+
minLltv?: number;
|
|
440
|
+
maxLltv?: number;
|
|
439
441
|
sortBy?: "rate" | "maturity" | "expiry" | "amount";
|
|
440
442
|
sortOrder?: "asc" | "desc";
|
|
441
443
|
cursor?: string;
|
|
@@ -450,9 +452,9 @@ type FindMatchingOffersParams = {
|
|
|
450
452
|
oracle: string;
|
|
451
453
|
lltv: LLTV.LLTV;
|
|
452
454
|
}>;
|
|
453
|
-
maturity?:
|
|
454
|
-
minMaturity?:
|
|
455
|
-
maxMaturity?:
|
|
455
|
+
maturity?: number;
|
|
456
|
+
minMaturity?: number;
|
|
457
|
+
maxMaturity?: number;
|
|
456
458
|
loanToken?: string;
|
|
457
459
|
creator?: string;
|
|
458
460
|
/** Filter by offer status; if omitted defaults to ["valid"] */
|
package/dist/index.browser.js
CHANGED
|
@@ -22,7 +22,8 @@ __export(Chain_exports, {
|
|
|
22
22
|
chainIds: () => chainIds,
|
|
23
23
|
chainNames: () => chainNames,
|
|
24
24
|
chains: () => chains,
|
|
25
|
-
getChain: () => getChain
|
|
25
|
+
getChain: () => getChain,
|
|
26
|
+
getWhitelistedChains: () => getWhitelistedChains
|
|
26
27
|
});
|
|
27
28
|
var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
28
29
|
var ChainId = {
|
|
@@ -39,6 +40,9 @@ function getChain(chainId) {
|
|
|
39
40
|
}
|
|
40
41
|
return chains[chainName];
|
|
41
42
|
}
|
|
43
|
+
var getWhitelistedChains = () => {
|
|
44
|
+
return [chains.ethereum, chains.base, chains["ethereum-virtual-testnet"]];
|
|
45
|
+
};
|
|
42
46
|
var chains = {
|
|
43
47
|
ethereum: {
|
|
44
48
|
...chains$1.mainnet,
|
|
@@ -52,8 +56,7 @@ var chains = {
|
|
|
52
56
|
// DAI
|
|
53
57
|
].map((address) => address.toLowerCase())
|
|
54
58
|
),
|
|
55
|
-
morpho: "0x0000000000000000000000000000000000000000"
|
|
56
|
-
termsContract: "0x0000000000000000000000000000000000000000"
|
|
59
|
+
morpho: "0x0000000000000000000000000000000000000000"
|
|
57
60
|
},
|
|
58
61
|
base: {
|
|
59
62
|
...chains$1.base,
|
|
@@ -67,8 +70,7 @@ var chains = {
|
|
|
67
70
|
// DAI
|
|
68
71
|
].map((address) => address.toLowerCase())
|
|
69
72
|
),
|
|
70
|
-
morpho: "0x0000000000000000000000000000000000000000"
|
|
71
|
-
termsContract: "0x0000000000000000000000000000000000000000"
|
|
73
|
+
morpho: "0x0000000000000000000000000000000000000000"
|
|
72
74
|
},
|
|
73
75
|
"ethereum-virtual-testnet": {
|
|
74
76
|
...chains$1.mainnet,
|
|
@@ -82,8 +84,8 @@ var chains = {
|
|
|
82
84
|
// DAI
|
|
83
85
|
].map((address) => address.toLowerCase())
|
|
84
86
|
),
|
|
85
|
-
morpho: "
|
|
86
|
-
|
|
87
|
+
morpho: "0x11a002d45db720ed47a80d2f3489cba5b833eaf5",
|
|
88
|
+
// @TODO: This is mock Consumed contract, update with Terms once stable
|
|
87
89
|
mempool: {
|
|
88
90
|
address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
|
|
89
91
|
deploymentBlock: 23223727,
|
|
@@ -389,28 +391,14 @@ var GetOffersQueryParams = v4.z.object({
|
|
|
389
391
|
example: "1500000000000000000"
|
|
390
392
|
}),
|
|
391
393
|
// Time range
|
|
392
|
-
min_maturity: v4.z.coerce.number().int().
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
return v4.z.NEVER;
|
|
401
|
-
}
|
|
402
|
-
}).optional(),
|
|
403
|
-
max_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
|
|
404
|
-
try {
|
|
405
|
-
return mempool.Maturity.from(maturity);
|
|
406
|
-
} catch (e) {
|
|
407
|
-
ctx.addIssue({
|
|
408
|
-
code: "custom",
|
|
409
|
-
message: e.message
|
|
410
|
-
});
|
|
411
|
-
return v4.z.NEVER;
|
|
412
|
-
}
|
|
413
|
-
}).optional(),
|
|
394
|
+
min_maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
395
|
+
description: "Minimum maturity timestamp (Unix timestamp in seconds)",
|
|
396
|
+
example: "1700000000"
|
|
397
|
+
}),
|
|
398
|
+
max_maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
399
|
+
description: "Maximum maturity timestamp (Unix timestamp in seconds)",
|
|
400
|
+
example: "1800000000"
|
|
401
|
+
}),
|
|
414
402
|
min_expiry: v4.z.coerce.number().int().optional().meta({
|
|
415
403
|
description: "Minimum expiry timestamp (Unix timestamp in seconds)",
|
|
416
404
|
example: "1700000000"
|
|
@@ -485,33 +473,11 @@ var GetOffersQueryParams = v4.z.object({
|
|
|
485
473
|
description: "Filter by collateral combinations in format: asset:oracle:lltv#asset2:oracle2:lltv2. Oracle and lltv are optional. Use # to separate multiple combinations.",
|
|
486
474
|
example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:86#0x9876543210987654321098765432109876543210:94.5"
|
|
487
475
|
}),
|
|
488
|
-
min_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).
|
|
489
|
-
try {
|
|
490
|
-
return mempool.LLTV.from(viem.parseUnits(lltv.toString(), 16));
|
|
491
|
-
} catch (e) {
|
|
492
|
-
ctx.addIssue({
|
|
493
|
-
code: "custom",
|
|
494
|
-
message: e.message,
|
|
495
|
-
input: lltv
|
|
496
|
-
});
|
|
497
|
-
return v4.z.NEVER;
|
|
498
|
-
}
|
|
499
|
-
}).optional().meta({
|
|
476
|
+
min_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).optional().meta({
|
|
500
477
|
description: "Minimum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal, e.g., 80.5 = 80.5%)",
|
|
501
478
|
example: "80.5"
|
|
502
479
|
}),
|
|
503
|
-
max_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).
|
|
504
|
-
try {
|
|
505
|
-
return mempool.LLTV.from(viem.parseUnits(lltv.toString(), 16));
|
|
506
|
-
} catch (e) {
|
|
507
|
-
ctx.addIssue({
|
|
508
|
-
code: "custom",
|
|
509
|
-
message: e.message,
|
|
510
|
-
input: lltv
|
|
511
|
-
});
|
|
512
|
-
return v4.z.NEVER;
|
|
513
|
-
}
|
|
514
|
-
}).optional().meta({
|
|
480
|
+
max_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).optional().meta({
|
|
515
481
|
description: "Maximum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal, e.g., 95.5 = 95.5%)",
|
|
516
482
|
example: "95.5"
|
|
517
483
|
}),
|
|
@@ -654,39 +620,18 @@ var MatchOffersQueryParams = v4.z.object({
|
|
|
654
620
|
example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:86#0x9876543210987654321098765432109876543210:0xfedcbafedcbafedcbafedcbafedcbafedcbafedc:94.5"
|
|
655
621
|
}),
|
|
656
622
|
// Maturity filtering
|
|
657
|
-
maturity: v4.z.coerce.number().int().
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
try {
|
|
670
|
-
return mempool.Maturity.from(maturity);
|
|
671
|
-
} catch (e) {
|
|
672
|
-
ctx.addIssue({
|
|
673
|
-
code: "custom",
|
|
674
|
-
message: e.message
|
|
675
|
-
});
|
|
676
|
-
return v4.z.NEVER;
|
|
677
|
-
}
|
|
678
|
-
}).optional(),
|
|
679
|
-
max_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
|
|
680
|
-
try {
|
|
681
|
-
return mempool.Maturity.from(maturity);
|
|
682
|
-
} catch (e) {
|
|
683
|
-
ctx.addIssue({
|
|
684
|
-
code: "custom",
|
|
685
|
-
message: e.message
|
|
686
|
-
});
|
|
687
|
-
return v4.z.NEVER;
|
|
688
|
-
}
|
|
689
|
-
}).optional(),
|
|
623
|
+
maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
624
|
+
description: "Maturity timestamp (Unix timestamp in seconds)",
|
|
625
|
+
example: "1700000000"
|
|
626
|
+
}),
|
|
627
|
+
min_maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
628
|
+
description: "Minimum maturity timestamp (Unix timestamp in seconds)",
|
|
629
|
+
example: "1700000000"
|
|
630
|
+
}),
|
|
631
|
+
max_maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
632
|
+
description: "Maximum maturity timestamp (Unix timestamp in seconds)",
|
|
633
|
+
example: "1800000000"
|
|
634
|
+
}),
|
|
690
635
|
// Asset and creator filtering
|
|
691
636
|
loan_token: v4.z.string().regex(/^0x[a-fA-F0-9]{40}$/, {
|
|
692
637
|
message: "Loan asset must be a valid Ethereum address"
|
|
@@ -883,7 +828,7 @@ function connect(opts) {
|
|
|
883
828
|
if (u.protocol !== "http:" && u.protocol !== "https:") {
|
|
884
829
|
throw new InvalidUrlError(u.toString());
|
|
885
830
|
}
|
|
886
|
-
const headers = new Headers();
|
|
831
|
+
const headers = opts?.headers ?? new Headers();
|
|
887
832
|
headers.set("Content-Type", "application/json");
|
|
888
833
|
opts?.apiKey !== void 0 ? headers.set("X-API-Key", opts.apiKey) : null;
|
|
889
834
|
const config = {
|
|
@@ -1285,8 +1230,12 @@ function memory(parameters) {
|
|
|
1285
1230
|
)
|
|
1286
1231
|
)
|
|
1287
1232
|
));
|
|
1288
|
-
minLltv && (offers = offers.filter(
|
|
1289
|
-
|
|
1233
|
+
minLltv && (offers = offers.filter(
|
|
1234
|
+
(o) => o.collaterals.every((c) => c.lltv >= viem.parseUnits(minLltv.toString(), 16))
|
|
1235
|
+
));
|
|
1236
|
+
maxLltv && (offers = offers.filter(
|
|
1237
|
+
(o) => o.collaterals.every((c) => c.lltv <= viem.parseUnits(maxLltv.toString(), 16))
|
|
1238
|
+
));
|
|
1290
1239
|
offers = offers.sort((a, b) => sort(sortBy, sortOrder, a, b));
|
|
1291
1240
|
let nextCursor = null;
|
|
1292
1241
|
if (offers.length > limit) {
|