@morpho-dev/router 0.0.20 → 0.0.22
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/README.md +5 -16
- package/dist/index.browser.d.cts +16 -28
- package/dist/index.browser.d.ts +16 -28
- package/dist/index.browser.js +19 -14
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +19 -14
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +119 -70
- package/dist/index.node.d.ts +119 -70
- package/dist/index.node.js +1466 -56992
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +1469 -56970
- package/dist/index.node.mjs.map +1 -1
- package/package.json +5 -6
- package/dist/bytecode/erc20.txt +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Router Client
|
|
2
2
|
|
|
3
|
-
A TypeScript client
|
|
3
|
+
A TypeScript client to interact with the Morpho Router.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -29,14 +29,10 @@ import { Router } from "@morpho-dev/router";
|
|
|
29
29
|
const router = Router.connect();
|
|
30
30
|
|
|
31
31
|
// With custom URL
|
|
32
|
-
const router = Router.connect({
|
|
33
|
-
url: "https://router.morpho.dev"
|
|
34
|
-
});
|
|
32
|
+
const router = Router.connect({ url: "https://router.morpho.dev" });
|
|
35
33
|
|
|
36
34
|
// Connect to local server
|
|
37
|
-
const router = Router.connect({
|
|
38
|
-
url: "http://localhost:8081"
|
|
39
|
-
});
|
|
35
|
+
const router = Router.connect({ url: "http://localhost:8081" });
|
|
40
36
|
```
|
|
41
37
|
|
|
42
38
|
### Get Offers
|
|
@@ -46,11 +42,7 @@ const router = Router.connect({
|
|
|
46
42
|
const result = await router.get({});
|
|
47
43
|
|
|
48
44
|
// Get buy offers on Ethereum mainnet
|
|
49
|
-
const result = await router.get({
|
|
50
|
-
side: "buy",
|
|
51
|
-
chains: [1],
|
|
52
|
-
limit: 10
|
|
53
|
-
});
|
|
45
|
+
const result = await router.get({ side: "buy", chains: [1], limit: 10 });
|
|
54
46
|
|
|
55
47
|
// Get offers with specific filters
|
|
56
48
|
const result = await router.get({
|
|
@@ -70,10 +62,7 @@ const result = await router.get({
|
|
|
70
62
|
|
|
71
63
|
```typescript
|
|
72
64
|
// Match offers for buy on Ethereum mainnet
|
|
73
|
-
const result = await router.match({
|
|
74
|
-
side: "buy",
|
|
75
|
-
chainId: 1
|
|
76
|
-
});
|
|
65
|
+
const result = await router.match({ side: "buy", chainId: 1 });
|
|
77
66
|
|
|
78
67
|
// Match with specific requirements
|
|
79
68
|
const result = await router.match({
|
package/dist/index.browser.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ import * as zod_v4_core from 'zod/v4/core';
|
|
|
8
8
|
import * as zod_v4 from 'zod/v4';
|
|
9
9
|
import { z, ZodError } from 'zod/v4';
|
|
10
10
|
|
|
11
|
-
declare const chainNames: readonly ["ethereum", "base"];
|
|
11
|
+
declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
12
12
|
type ChainName = (typeof chainNames)[number];
|
|
13
13
|
declare const ChainId: {
|
|
14
14
|
ETHEREUM: bigint;
|
|
@@ -88,8 +88,8 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
88
88
|
* @param input - The router offer to create.
|
|
89
89
|
* @returns The created router offer with its hash.
|
|
90
90
|
*/
|
|
91
|
-
declare function from(input: Omit<RouterOffer, "hash">): RouterOffer;
|
|
92
|
-
declare namespace from {
|
|
91
|
+
declare function from$1(input: Omit<RouterOffer, "hash">): RouterOffer;
|
|
92
|
+
declare namespace from$1 {
|
|
93
93
|
type ErrorType = InvalidRouterOfferError;
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
@@ -121,12 +121,11 @@ type RouterOffer$1_OfferStatus = OfferStatus;
|
|
|
121
121
|
declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
|
|
122
122
|
type RouterOffer$1_RouterOffer = RouterOffer;
|
|
123
123
|
declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
|
|
124
|
-
declare const RouterOffer$1_from: typeof from;
|
|
125
124
|
declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
|
|
126
125
|
declare const RouterOffer$1_random: typeof random;
|
|
127
126
|
declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
|
|
128
127
|
declare namespace RouterOffer$1 {
|
|
129
|
-
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema,
|
|
128
|
+
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, from$1 as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
type OfferResponse = {
|
|
@@ -422,37 +421,26 @@ declare namespace index$1 {
|
|
|
422
421
|
|
|
423
422
|
declare const types: readonly ["offer_created", "offer_matched", "offer_validation"];
|
|
424
423
|
type Type = (typeof types)[number];
|
|
425
|
-
type
|
|
426
|
-
offer_created: {
|
|
427
|
-
readonly offer: Offer.Offer;
|
|
428
|
-
};
|
|
429
|
-
offer_matched: {
|
|
430
|
-
readonly offer: Offer.Offer;
|
|
431
|
-
};
|
|
432
|
-
offer_validation: {
|
|
433
|
-
readonly offer: Offer.Offer;
|
|
434
|
-
};
|
|
435
|
-
};
|
|
436
|
-
type BaseEvent<T extends Type> = {
|
|
424
|
+
type BaseEvent<type extends Type = Type> = {
|
|
437
425
|
readonly id: string;
|
|
438
|
-
readonly type:
|
|
426
|
+
readonly type: type;
|
|
439
427
|
};
|
|
440
|
-
type RouterEvent = Compute<{
|
|
441
|
-
|
|
442
|
-
}
|
|
428
|
+
type RouterEvent<type extends Type = Type> = type extends "offer_created" | "offer_matched" | "offer_validation" ? Compute<BaseEvent<type> & {
|
|
429
|
+
readonly offer: Offer.Offer;
|
|
430
|
+
}> : never;
|
|
443
431
|
/**
|
|
444
|
-
*
|
|
445
|
-
* For `offer_created` it returns `offer_created:${offer.hash.toLowerCase()}`.
|
|
446
|
-
* For `offer_matched` it returns `offer_matched:${offer.hash.toLowerCase()}`.
|
|
432
|
+
* Creates a RouterEvent with a deterministic id.
|
|
447
433
|
*/
|
|
448
|
-
declare function
|
|
434
|
+
declare function from<T extends Type = Type>(base: Omit<RouterEvent<T>, "id" | "type"> & {
|
|
435
|
+
type: T;
|
|
436
|
+
}): Compute<RouterEvent<T>>;
|
|
449
437
|
|
|
450
|
-
type RouterEvent$1_RouterEvent = RouterEvent
|
|
438
|
+
type RouterEvent$1_RouterEvent<type extends Type = Type> = RouterEvent<type>;
|
|
451
439
|
type RouterEvent$1_Type = Type;
|
|
452
|
-
declare const RouterEvent$
|
|
440
|
+
declare const RouterEvent$1_from: typeof from;
|
|
453
441
|
declare const RouterEvent$1_types: typeof types;
|
|
454
442
|
declare namespace RouterEvent$1 {
|
|
455
|
-
export { type RouterEvent$1_RouterEvent as RouterEvent, type RouterEvent$1_Type as Type, RouterEvent$
|
|
443
|
+
export { type RouterEvent$1_RouterEvent as RouterEvent, type RouterEvent$1_Type as Type, RouterEvent$1_from as from, RouterEvent$1_types as types };
|
|
456
444
|
}
|
|
457
445
|
|
|
458
446
|
/**
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as zod_v4_core from 'zod/v4/core';
|
|
|
8
8
|
import * as zod_v4 from 'zod/v4';
|
|
9
9
|
import { z, ZodError } from 'zod/v4';
|
|
10
10
|
|
|
11
|
-
declare const chainNames: readonly ["ethereum", "base"];
|
|
11
|
+
declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
12
12
|
type ChainName = (typeof chainNames)[number];
|
|
13
13
|
declare const ChainId: {
|
|
14
14
|
ETHEREUM: bigint;
|
|
@@ -88,8 +88,8 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
88
88
|
* @param input - The router offer to create.
|
|
89
89
|
* @returns The created router offer with its hash.
|
|
90
90
|
*/
|
|
91
|
-
declare function from(input: Omit<RouterOffer, "hash">): RouterOffer;
|
|
92
|
-
declare namespace from {
|
|
91
|
+
declare function from$1(input: Omit<RouterOffer, "hash">): RouterOffer;
|
|
92
|
+
declare namespace from$1 {
|
|
93
93
|
type ErrorType = InvalidRouterOfferError;
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
@@ -121,12 +121,11 @@ type RouterOffer$1_OfferStatus = OfferStatus;
|
|
|
121
121
|
declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
|
|
122
122
|
type RouterOffer$1_RouterOffer = RouterOffer;
|
|
123
123
|
declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
|
|
124
|
-
declare const RouterOffer$1_from: typeof from;
|
|
125
124
|
declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
|
|
126
125
|
declare const RouterOffer$1_random: typeof random;
|
|
127
126
|
declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
|
|
128
127
|
declare namespace RouterOffer$1 {
|
|
129
|
-
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema,
|
|
128
|
+
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, from$1 as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
type OfferResponse = {
|
|
@@ -422,37 +421,26 @@ declare namespace index$1 {
|
|
|
422
421
|
|
|
423
422
|
declare const types: readonly ["offer_created", "offer_matched", "offer_validation"];
|
|
424
423
|
type Type = (typeof types)[number];
|
|
425
|
-
type
|
|
426
|
-
offer_created: {
|
|
427
|
-
readonly offer: Offer.Offer;
|
|
428
|
-
};
|
|
429
|
-
offer_matched: {
|
|
430
|
-
readonly offer: Offer.Offer;
|
|
431
|
-
};
|
|
432
|
-
offer_validation: {
|
|
433
|
-
readonly offer: Offer.Offer;
|
|
434
|
-
};
|
|
435
|
-
};
|
|
436
|
-
type BaseEvent<T extends Type> = {
|
|
424
|
+
type BaseEvent<type extends Type = Type> = {
|
|
437
425
|
readonly id: string;
|
|
438
|
-
readonly type:
|
|
426
|
+
readonly type: type;
|
|
439
427
|
};
|
|
440
|
-
type RouterEvent = Compute<{
|
|
441
|
-
|
|
442
|
-
}
|
|
428
|
+
type RouterEvent<type extends Type = Type> = type extends "offer_created" | "offer_matched" | "offer_validation" ? Compute<BaseEvent<type> & {
|
|
429
|
+
readonly offer: Offer.Offer;
|
|
430
|
+
}> : never;
|
|
443
431
|
/**
|
|
444
|
-
*
|
|
445
|
-
* For `offer_created` it returns `offer_created:${offer.hash.toLowerCase()}`.
|
|
446
|
-
* For `offer_matched` it returns `offer_matched:${offer.hash.toLowerCase()}`.
|
|
432
|
+
* Creates a RouterEvent with a deterministic id.
|
|
447
433
|
*/
|
|
448
|
-
declare function
|
|
434
|
+
declare function from<T extends Type = Type>(base: Omit<RouterEvent<T>, "id" | "type"> & {
|
|
435
|
+
type: T;
|
|
436
|
+
}): Compute<RouterEvent<T>>;
|
|
449
437
|
|
|
450
|
-
type RouterEvent$1_RouterEvent = RouterEvent
|
|
438
|
+
type RouterEvent$1_RouterEvent<type extends Type = Type> = RouterEvent<type>;
|
|
451
439
|
type RouterEvent$1_Type = Type;
|
|
452
|
-
declare const RouterEvent$
|
|
440
|
+
declare const RouterEvent$1_from: typeof from;
|
|
453
441
|
declare const RouterEvent$1_types: typeof types;
|
|
454
442
|
declare namespace RouterEvent$1 {
|
|
455
|
-
export { type RouterEvent$1_RouterEvent as RouterEvent, type RouterEvent$1_Type as Type, RouterEvent$
|
|
443
|
+
export { type RouterEvent$1_RouterEvent as RouterEvent, type RouterEvent$1_Type as Type, RouterEvent$1_from as from, RouterEvent$1_types as types };
|
|
456
444
|
}
|
|
457
445
|
|
|
458
446
|
/**
|
package/dist/index.browser.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(Chain_exports, {
|
|
|
24
24
|
chains: () => chains,
|
|
25
25
|
getChain: () => getChain
|
|
26
26
|
});
|
|
27
|
-
var chainNames = ["ethereum", "base"];
|
|
27
|
+
var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
28
28
|
var ChainId = {
|
|
29
29
|
ETHEREUM: BigInt(chains$1.mainnet.id),
|
|
30
30
|
BASE: BigInt(chains$1.base.id)
|
|
@@ -66,6 +66,20 @@ var chains = {
|
|
|
66
66
|
].map((address) => address.toLowerCase())
|
|
67
67
|
),
|
|
68
68
|
morpho: "0x0000000000000000000000000000000000000000"
|
|
69
|
+
},
|
|
70
|
+
"ethereum-virtual-testnet": {
|
|
71
|
+
...chains$1.mainnet,
|
|
72
|
+
id: 1111n,
|
|
73
|
+
name: "ethereum-virtual-testnet",
|
|
74
|
+
whitelistedAssets: new Set(
|
|
75
|
+
[
|
|
76
|
+
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
77
|
+
// USDC
|
|
78
|
+
"0x6B175474E89094C44Da98b954EedeAC495271d0F"
|
|
79
|
+
// DAI
|
|
80
|
+
].map((address) => address.toLowerCase())
|
|
81
|
+
),
|
|
82
|
+
morpho: "0x0000000000000000000000000000000000000000"
|
|
69
83
|
}
|
|
70
84
|
};
|
|
71
85
|
|
|
@@ -1417,22 +1431,13 @@ function memory(parameters) {
|
|
|
1417
1431
|
// src/RouterEvent.ts
|
|
1418
1432
|
var RouterEvent_exports = {};
|
|
1419
1433
|
__export(RouterEvent_exports, {
|
|
1420
|
-
|
|
1434
|
+
from: () => from2,
|
|
1421
1435
|
types: () => types
|
|
1422
1436
|
});
|
|
1423
1437
|
var types = ["offer_created", "offer_matched", "offer_validation"];
|
|
1424
|
-
function
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
return `offer_created:${event.offer.hash.toLowerCase()}`;
|
|
1428
|
-
case "offer_matched":
|
|
1429
|
-
return `offer_matched:${event.offer.hash.toLowerCase()}`;
|
|
1430
|
-
case "offer_validation":
|
|
1431
|
-
return `offer_validation:${event.offer.hash.toLowerCase()}`;
|
|
1432
|
-
default: {
|
|
1433
|
-
throw new Error("Unhandled event type");
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1438
|
+
function from2(base) {
|
|
1439
|
+
const id = `${base.type}:${base.offer.hash.toLowerCase()}`;
|
|
1440
|
+
return { id, ...base };
|
|
1436
1441
|
}
|
|
1437
1442
|
|
|
1438
1443
|
// src/Validation.ts
|