@morpho-dev/router 0.0.21 → 0.0.23

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Router Client
2
2
 
3
- A TypeScript client for the Morpho Router API.
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({
@@ -8,11 +8,12 @@ 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;
15
15
  BASE: bigint;
16
+ "ETHEREUM-VIRTUAL-TESTNET": bigint;
16
17
  };
17
18
  type ChainId = (typeof ChainId)[keyof typeof ChainId];
18
19
  declare const chainIds: Set<bigint>;
@@ -21,6 +22,11 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
21
22
  name: ChainName;
22
23
  whitelistedAssets: Set<Address>;
23
24
  morpho: Address;
25
+ mempool?: {
26
+ address: Address;
27
+ deploymentBlock: number;
28
+ reindexBuffer: number;
29
+ };
24
30
  }>;
25
31
  declare function getChain(chainId: ChainId): Chain | undefined;
26
32
  declare const chains: Record<ChainName, Chain>;
@@ -347,6 +353,19 @@ type OfferStore = {
347
353
  nonce: Offer.Offer["nonce"];
348
354
  consumed: bigint;
349
355
  }) => Promise<void>;
356
+ /** Persist latest indexing progress for a chain and event type. */
357
+ saveLatestBlockNumberProcessed: (parameters: {
358
+ chainId: Offer.Offer["chainId"];
359
+ eventType: "offer_created" | "offer_matched";
360
+ latestBlockNumber: number;
361
+ }) => Promise<void>;
362
+ /** Retrieve latest indexing progress for a chain and event type. */
363
+ getLatestBlockNumberProcessed: (parameters: {
364
+ chainId: Offer.Offer["chainId"];
365
+ eventType: "offer_created" | "offer_matched";
366
+ }) => Promise<{
367
+ latestBlockNumber: number;
368
+ } | null>;
350
369
  };
351
370
  type GetOffersFilters = {
352
371
  creators?: string[];
@@ -8,11 +8,12 @@ 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;
15
15
  BASE: bigint;
16
+ "ETHEREUM-VIRTUAL-TESTNET": bigint;
16
17
  };
17
18
  type ChainId = (typeof ChainId)[keyof typeof ChainId];
18
19
  declare const chainIds: Set<bigint>;
@@ -21,6 +22,11 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
21
22
  name: ChainName;
22
23
  whitelistedAssets: Set<Address>;
23
24
  morpho: Address;
25
+ mempool?: {
26
+ address: Address;
27
+ deploymentBlock: number;
28
+ reindexBuffer: number;
29
+ };
24
30
  }>;
25
31
  declare function getChain(chainId: ChainId): Chain | undefined;
26
32
  declare const chains: Record<ChainName, Chain>;
@@ -347,6 +353,19 @@ type OfferStore = {
347
353
  nonce: Offer.Offer["nonce"];
348
354
  consumed: bigint;
349
355
  }) => Promise<void>;
356
+ /** Persist latest indexing progress for a chain and event type. */
357
+ saveLatestBlockNumberProcessed: (parameters: {
358
+ chainId: Offer.Offer["chainId"];
359
+ eventType: "offer_created" | "offer_matched";
360
+ latestBlockNumber: number;
361
+ }) => Promise<void>;
362
+ /** Retrieve latest indexing progress for a chain and event type. */
363
+ getLatestBlockNumberProcessed: (parameters: {
364
+ chainId: Offer.Offer["chainId"];
365
+ eventType: "offer_created" | "offer_matched";
366
+ }) => Promise<{
367
+ latestBlockNumber: number;
368
+ } | null>;
350
369
  };
351
370
  type GetOffersFilters = {
352
371
  creators?: string[];
@@ -24,10 +24,11 @@ __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
- BASE: BigInt(chains$1.base.id)
30
+ BASE: BigInt(chains$1.base.id),
31
+ "ETHEREUM-VIRTUAL-TESTNET": 121212n
31
32
  };
32
33
  var chainIds = new Set(Object.values(ChainId));
33
34
  var chainNameLookup = new Map(Object.entries(ChainId).map(([key, value]) => [value, key]));
@@ -66,6 +67,25 @@ var chains = {
66
67
  ].map((address) => address.toLowerCase())
67
68
  ),
68
69
  morpho: "0x0000000000000000000000000000000000000000"
70
+ },
71
+ "ethereum-virtual-testnet": {
72
+ ...chains$1.mainnet,
73
+ id: 121212n,
74
+ name: "ethereum-virtual-testnet",
75
+ whitelistedAssets: new Set(
76
+ [
77
+ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
78
+ // USDC
79
+ "0x6B175474E89094C44Da98b954EedeAC495271d0F"
80
+ // DAI
81
+ ].map((address) => address.toLowerCase())
82
+ ),
83
+ morpho: "0x0000000000000000000000000000000000000000",
84
+ mempool: {
85
+ address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
86
+ deploymentBlock: 23225668,
87
+ reindexBuffer: 10
88
+ }
69
89
  }
70
90
  };
71
91
 
@@ -1070,6 +1090,7 @@ __export(OfferStore_exports, {
1070
1090
  function memory(parameters) {
1071
1091
  const map = parameters.offers;
1072
1092
  const filled = parameters.filled;
1093
+ const indexingProgress = /* @__PURE__ */ new Map();
1073
1094
  const create = async (parameters2) => {
1074
1095
  if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
1075
1096
  map.set(parameters2.offer.hash.toLowerCase(), {
@@ -1410,6 +1431,15 @@ function memory(parameters) {
1410
1431
  filledForOffering.set(nonce, parameters2.consumed);
1411
1432
  filledForChain.set(address, filledForOffering);
1412
1433
  filled.set(chainId, filledForChain);
1434
+ },
1435
+ saveLatestBlockNumberProcessed: async (parameters2) => {
1436
+ const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
1437
+ indexingProgress.set(key, parameters2.latestBlockNumber);
1438
+ },
1439
+ getLatestBlockNumberProcessed: async (parameters2) => {
1440
+ const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
1441
+ const value = indexingProgress.get(key);
1442
+ return value === void 0 ? null : { latestBlockNumber: value };
1413
1443
  }
1414
1444
  };
1415
1445
  }