@morpho-dev/router 0.0.26 → 0.0.27
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 +10 -9
- package/dist/index.browser.d.ts +10 -9
- package/dist/index.browser.js +37 -88
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +38 -89
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +17 -16
- package/dist/index.node.d.ts +17 -16
- package/dist/index.node.js +37 -88
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +38 -89
- 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"];
|
|
@@ -423,8 +424,8 @@ type GetOffersFilters = {
|
|
|
423
424
|
maxAmount?: bigint;
|
|
424
425
|
minRate?: bigint;
|
|
425
426
|
maxRate?: bigint;
|
|
426
|
-
minMaturity?:
|
|
427
|
-
maxMaturity?:
|
|
427
|
+
minMaturity?: number;
|
|
428
|
+
maxMaturity?: number;
|
|
428
429
|
minExpiry?: number;
|
|
429
430
|
maxExpiry?: number;
|
|
430
431
|
collateralAssets?: string[];
|
|
@@ -434,8 +435,8 @@ type GetOffersFilters = {
|
|
|
434
435
|
oracle?: string;
|
|
435
436
|
lltv?: LLTV.LLTV;
|
|
436
437
|
}>;
|
|
437
|
-
minLltv?:
|
|
438
|
-
maxLltv?:
|
|
438
|
+
minLltv?: number;
|
|
439
|
+
maxLltv?: number;
|
|
439
440
|
sortBy?: "rate" | "maturity" | "expiry" | "amount";
|
|
440
441
|
sortOrder?: "asc" | "desc";
|
|
441
442
|
cursor?: string;
|
|
@@ -450,9 +451,9 @@ type FindMatchingOffersParams = {
|
|
|
450
451
|
oracle: string;
|
|
451
452
|
lltv: LLTV.LLTV;
|
|
452
453
|
}>;
|
|
453
|
-
maturity?:
|
|
454
|
-
minMaturity?:
|
|
455
|
-
maxMaturity?:
|
|
454
|
+
maturity?: number;
|
|
455
|
+
minMaturity?: number;
|
|
456
|
+
maxMaturity?: number;
|
|
456
457
|
loanToken?: string;
|
|
457
458
|
creator?: string;
|
|
458
459
|
/** 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"];
|
|
@@ -423,8 +424,8 @@ type GetOffersFilters = {
|
|
|
423
424
|
maxAmount?: bigint;
|
|
424
425
|
minRate?: bigint;
|
|
425
426
|
maxRate?: bigint;
|
|
426
|
-
minMaturity?:
|
|
427
|
-
maxMaturity?:
|
|
427
|
+
minMaturity?: number;
|
|
428
|
+
maxMaturity?: number;
|
|
428
429
|
minExpiry?: number;
|
|
429
430
|
maxExpiry?: number;
|
|
430
431
|
collateralAssets?: string[];
|
|
@@ -434,8 +435,8 @@ type GetOffersFilters = {
|
|
|
434
435
|
oracle?: string;
|
|
435
436
|
lltv?: LLTV.LLTV;
|
|
436
437
|
}>;
|
|
437
|
-
minLltv?:
|
|
438
|
-
maxLltv?:
|
|
438
|
+
minLltv?: number;
|
|
439
|
+
maxLltv?: number;
|
|
439
440
|
sortBy?: "rate" | "maturity" | "expiry" | "amount";
|
|
440
441
|
sortOrder?: "asc" | "desc";
|
|
441
442
|
cursor?: string;
|
|
@@ -450,9 +451,9 @@ type FindMatchingOffersParams = {
|
|
|
450
451
|
oracle: string;
|
|
451
452
|
lltv: LLTV.LLTV;
|
|
452
453
|
}>;
|
|
453
|
-
maturity?:
|
|
454
|
-
minMaturity?:
|
|
455
|
-
maxMaturity?:
|
|
454
|
+
maturity?: number;
|
|
455
|
+
minMaturity?: number;
|
|
456
|
+
maxMaturity?: number;
|
|
456
457
|
loanToken?: string;
|
|
457
458
|
creator?: string;
|
|
458
459
|
/** 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["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"
|
|
@@ -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) {
|