@morpho-dev/router 0.1.1 → 0.1.2

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.
@@ -1,52 +1,15 @@
1
1
  import * as _morpho_dev_mempool from '@morpho-dev/mempool';
2
- import { Compute, Offer, Errors, Format, Maturity, LLTV } from '@morpho-dev/mempool';
2
+ import { Offer, Errors, Format, Maturity, LLTV, Compute, Chain } from '@morpho-dev/mempool';
3
3
  export * from '@morpho-dev/mempool';
4
- import * as viem from 'viem';
5
- import { Address, Hex, PublicClient } from 'viem';
6
- import { Chain as Chain$2 } from 'viem/chains';
7
4
  import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
8
5
  import { z, ZodError } from 'zod/v4';
6
+ import * as viem from 'viem';
7
+ import { Address, Hex, PublicClient } from 'viem';
9
8
  import * as hono_utils_types from 'hono/utils/types';
10
9
  import * as hono from 'hono';
11
10
  import { Context } from 'hono';
12
11
  import * as hono_utils_http_status from 'hono/utils/http-status';
13
12
 
14
- declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
15
- type ChainName = (typeof chainNames)[number];
16
- declare const ChainId: {
17
- ETHEREUM: bigint;
18
- BASE: bigint;
19
- "ETHEREUM-VIRTUAL-TESTNET": bigint;
20
- };
21
- type ChainId = (typeof ChainId)[keyof typeof ChainId];
22
- declare const chainIds: Set<bigint>;
23
- type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
24
- id: ChainId;
25
- name: ChainName;
26
- whitelistedAssets: Set<Address>;
27
- morpho: Address;
28
- mempool?: {
29
- address: Address;
30
- deploymentBlock: number;
31
- reindexBuffer: number;
32
- };
33
- }>;
34
- declare function getChain(chainId: ChainId): Chain | undefined;
35
- declare const getWhitelistedChains: () => Chain[];
36
- declare const chains: Record<ChainName, Chain>;
37
-
38
- type Chain$1_Chain = Chain;
39
- type Chain$1_ChainId = ChainId;
40
- type Chain$1_ChainName = ChainName;
41
- declare const Chain$1_chainIds: typeof chainIds;
42
- declare const Chain$1_chainNames: typeof chainNames;
43
- declare const Chain$1_chains: typeof chains;
44
- declare const Chain$1_getChain: typeof getChain;
45
- declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
46
- declare namespace Chain$1 {
47
- 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 };
48
- }
49
-
50
13
  declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
51
14
 
52
15
  declare const schemas: {
@@ -473,19 +436,6 @@ type OfferStore = {
473
436
  nonce: Offer.Offer["nonce"];
474
437
  consumed: bigint;
475
438
  }) => Promise<void>;
476
- /** Persist latest indexing progress for a chain and event type. */
477
- saveLatestBlockNumberProcessed: (parameters: {
478
- chainId: Offer.Offer["chainId"];
479
- eventType: "offer_created" | "offer_consumed";
480
- latestBlockNumber: number;
481
- }) => Promise<void>;
482
- /** Retrieve latest indexing progress for a chain and event type. */
483
- getLatestBlockNumberProcessed: (parameters: {
484
- chainId: Offer.Offer["chainId"];
485
- eventType: "offer_created" | "offer_consumed";
486
- }) => Promise<{
487
- latestBlockNumber: number;
488
- } | null>;
489
439
  };
490
440
  type GetOffersFilters = {
491
441
  creators?: string[];
@@ -546,7 +496,7 @@ declare function memory(parameters: {
546
496
  status: OfferStatus;
547
497
  metadata?: OfferMetadata;
548
498
  }>;
549
- filled: Map<ChainId, Map<Address, Map<bigint, bigint>>>;
499
+ filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
550
500
  }): OfferStore;
551
501
 
552
502
  type index$2_FindMatchingOffersParams = FindMatchingOffersParams;
@@ -848,10 +798,10 @@ declare function single<Name extends string, T, Ctx = void>(name: Name, run: Sin
848
798
  */
849
799
  declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
850
800
  type MorphoContext = {
851
- publicClients: Partial<Record<ChainName, PublicClient>>;
801
+ publicClients: Partial<Record<Chain.ChainName, PublicClient>>;
852
802
  };
853
803
  declare function morpho(parameters: {
854
- whitelistedChains: Chain[];
804
+ whitelistedChains: Chain.Chain[];
855
805
  }): (Rule<{
856
806
  readonly offering: Address;
857
807
  readonly assets: bigint;
@@ -1051,4 +1001,4 @@ declare namespace Validation {
1051
1001
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
1052
1002
  }
1053
1003
 
1054
- export { index$3 as ApiSchema, Chain$1 as Chain, Logger$1 as Logger, index$2 as OfferStore, index$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
1004
+ export { index$3 as ApiSchema, Logger$1 as Logger, index$2 as OfferStore, index$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
@@ -1,52 +1,15 @@
1
1
  import * as _morpho_dev_mempool from '@morpho-dev/mempool';
2
- import { Compute, Offer, Errors, Format, Maturity, LLTV } from '@morpho-dev/mempool';
2
+ import { Offer, Errors, Format, Maturity, LLTV, Compute, Chain } from '@morpho-dev/mempool';
3
3
  export * from '@morpho-dev/mempool';
4
- import * as viem from 'viem';
5
- import { Address, Hex, PublicClient } from 'viem';
6
- import { Chain as Chain$2 } from 'viem/chains';
7
4
  import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
8
5
  import { z, ZodError } from 'zod/v4';
6
+ import * as viem from 'viem';
7
+ import { Address, Hex, PublicClient } from 'viem';
9
8
  import * as hono_utils_types from 'hono/utils/types';
10
9
  import * as hono from 'hono';
11
10
  import { Context } from 'hono';
12
11
  import * as hono_utils_http_status from 'hono/utils/http-status';
13
12
 
14
- declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
15
- type ChainName = (typeof chainNames)[number];
16
- declare const ChainId: {
17
- ETHEREUM: bigint;
18
- BASE: bigint;
19
- "ETHEREUM-VIRTUAL-TESTNET": bigint;
20
- };
21
- type ChainId = (typeof ChainId)[keyof typeof ChainId];
22
- declare const chainIds: Set<bigint>;
23
- type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
24
- id: ChainId;
25
- name: ChainName;
26
- whitelistedAssets: Set<Address>;
27
- morpho: Address;
28
- mempool?: {
29
- address: Address;
30
- deploymentBlock: number;
31
- reindexBuffer: number;
32
- };
33
- }>;
34
- declare function getChain(chainId: ChainId): Chain | undefined;
35
- declare const getWhitelistedChains: () => Chain[];
36
- declare const chains: Record<ChainName, Chain>;
37
-
38
- type Chain$1_Chain = Chain;
39
- type Chain$1_ChainId = ChainId;
40
- type Chain$1_ChainName = ChainName;
41
- declare const Chain$1_chainIds: typeof chainIds;
42
- declare const Chain$1_chainNames: typeof chainNames;
43
- declare const Chain$1_chains: typeof chains;
44
- declare const Chain$1_getChain: typeof getChain;
45
- declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
46
- declare namespace Chain$1 {
47
- 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 };
48
- }
49
-
50
13
  declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
51
14
 
52
15
  declare const schemas: {
@@ -473,19 +436,6 @@ type OfferStore = {
473
436
  nonce: Offer.Offer["nonce"];
474
437
  consumed: bigint;
475
438
  }) => Promise<void>;
476
- /** Persist latest indexing progress for a chain and event type. */
477
- saveLatestBlockNumberProcessed: (parameters: {
478
- chainId: Offer.Offer["chainId"];
479
- eventType: "offer_created" | "offer_consumed";
480
- latestBlockNumber: number;
481
- }) => Promise<void>;
482
- /** Retrieve latest indexing progress for a chain and event type. */
483
- getLatestBlockNumberProcessed: (parameters: {
484
- chainId: Offer.Offer["chainId"];
485
- eventType: "offer_created" | "offer_consumed";
486
- }) => Promise<{
487
- latestBlockNumber: number;
488
- } | null>;
489
439
  };
490
440
  type GetOffersFilters = {
491
441
  creators?: string[];
@@ -546,7 +496,7 @@ declare function memory(parameters: {
546
496
  status: OfferStatus;
547
497
  metadata?: OfferMetadata;
548
498
  }>;
549
- filled: Map<ChainId, Map<Address, Map<bigint, bigint>>>;
499
+ filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
550
500
  }): OfferStore;
551
501
 
552
502
  type index$2_FindMatchingOffersParams = FindMatchingOffersParams;
@@ -848,10 +798,10 @@ declare function single<Name extends string, T, Ctx = void>(name: Name, run: Sin
848
798
  */
849
799
  declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
850
800
  type MorphoContext = {
851
- publicClients: Partial<Record<ChainName, PublicClient>>;
801
+ publicClients: Partial<Record<Chain.ChainName, PublicClient>>;
852
802
  };
853
803
  declare function morpho(parameters: {
854
- whitelistedChains: Chain[];
804
+ whitelistedChains: Chain.Chain[];
855
805
  }): (Rule<{
856
806
  readonly offering: Address;
857
807
  readonly assets: bigint;
@@ -1051,4 +1001,4 @@ declare namespace Validation {
1051
1001
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
1052
1002
  }
1053
1003
 
1054
- export { index$3 as ApiSchema, Chain$1 as Chain, Logger$1 as Logger, index$2 as OfferStore, index$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
1004
+ export { index$3 as ApiSchema, Logger$1 as Logger, index$2 as OfferStore, index$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var mempool = require('@morpho-dev/mempool');
4
- var chains$1 = require('viem/chains');
5
4
  var v4 = require('zod/v4');
6
5
  var zodOpenapi = require('zod-openapi');
7
6
  var viem = require('viem');
@@ -16,85 +15,6 @@ var __export = (target, all) => {
16
15
  __defProp(target, name, { get: all[name], enumerable: true });
17
16
  };
18
17
 
19
- // src/Chain.ts
20
- var Chain_exports = {};
21
- __export(Chain_exports, {
22
- ChainId: () => ChainId,
23
- chainIds: () => chainIds,
24
- chainNames: () => chainNames,
25
- chains: () => chains,
26
- getChain: () => getChain,
27
- getWhitelistedChains: () => getWhitelistedChains
28
- });
29
- var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
30
- var ChainId = {
31
- ETHEREUM: BigInt(chains$1.mainnet.id),
32
- BASE: BigInt(chains$1.base.id),
33
- "ETHEREUM-VIRTUAL-TESTNET": 109111114n
34
- };
35
- var chainIds = new Set(Object.values(ChainId));
36
- var chainNameLookup = new Map(Object.entries(ChainId).map(([key, value]) => [value, key]));
37
- function getChain(chainId) {
38
- const chainName = chainNameLookup.get(chainId)?.toLowerCase();
39
- if (!chainName) {
40
- return void 0;
41
- }
42
- return chains[chainName];
43
- }
44
- var getWhitelistedChains = () => {
45
- return [chains.ethereum, chains.base, chains["ethereum-virtual-testnet"]];
46
- };
47
- var chains = {
48
- ethereum: {
49
- ...chains$1.mainnet,
50
- id: ChainId.ETHEREUM,
51
- name: "ethereum",
52
- whitelistedAssets: new Set(
53
- [
54
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
55
- // USDC
56
- "0x6B175474E89094C44Da98b954EedeAC495271d0F"
57
- // DAI
58
- ].map((address) => address.toLowerCase())
59
- ),
60
- morpho: "0x0000000000000000000000000000000000000000"
61
- },
62
- base: {
63
- ...chains$1.base,
64
- id: ChainId.BASE,
65
- name: "base",
66
- whitelistedAssets: new Set(
67
- [
68
- "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
69
- // USDC
70
- "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"
71
- // DAI
72
- ].map((address) => address.toLowerCase())
73
- ),
74
- morpho: "0x0000000000000000000000000000000000000000"
75
- },
76
- "ethereum-virtual-testnet": {
77
- ...chains$1.mainnet,
78
- id: 109111114n,
79
- name: "ethereum-virtual-testnet",
80
- whitelistedAssets: new Set(
81
- [
82
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
83
- // USDC
84
- "0x6B175474E89094C44Da98b954EedeAC495271d0F"
85
- // DAI
86
- ].map((address) => address.toLowerCase())
87
- ),
88
- morpho: "0x11a002d45db720ed47a80d2f3489cba5b833eaf5",
89
- // @TODO: This is mock Consumed contract, update with Terms once stable
90
- mempool: {
91
- address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
92
- deploymentBlock: 23223727,
93
- reindexBuffer: 10
94
- }
95
- }
96
- };
97
-
98
18
  // src/core/apiSchema/index.ts
99
19
  var apiSchema_exports = {};
100
20
  __export(apiSchema_exports, {
@@ -1102,7 +1022,6 @@ function memory(parameters) {
1102
1022
  const map = parameters.offers;
1103
1023
  const filled = parameters.filled;
1104
1024
  const consumedIds = /* @__PURE__ */ new Set();
1105
- const indexingProgress = /* @__PURE__ */ new Map();
1106
1025
  const create = async (parameters2) => {
1107
1026
  if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
1108
1027
  map.set(parameters2.offer.hash.toLowerCase(), {
@@ -1173,7 +1092,7 @@ function memory(parameters) {
1173
1092
  let {
1174
1093
  creators,
1175
1094
  side,
1176
- chains: chains2,
1095
+ chains,
1177
1096
  loanTokens,
1178
1097
  status = ["valid"],
1179
1098
  callbackAddresses,
@@ -1244,7 +1163,7 @@ function memory(parameters) {
1244
1163
  offers = offers.filter((o) => o.expiry >= now);
1245
1164
  creators && (offers = offers.filter((o) => creators.includes(o.offering.toLowerCase())));
1246
1165
  side && (offers = offers.filter((o) => o.buy === buy));
1247
- chains2 && (offers = offers.filter((o) => chains2.includes(Number(o.chainId))));
1166
+ chains && (offers = offers.filter((o) => chains.includes(Number(o.chainId))));
1248
1167
  loanTokens && (offers = offers.filter((o) => loanTokens.includes(o.loanToken.toLowerCase())));
1249
1168
  status && (offers = offers.filter((o) => status.includes(o.status)));
1250
1169
  callbackAddresses && (offers = offers.filter(
@@ -1450,15 +1369,6 @@ function memory(parameters) {
1450
1369
  filledForOffering.set(nonce, current + parameters2.consumed);
1451
1370
  filledForChain.set(address, filledForOffering);
1452
1371
  filled.set(chainId, filledForChain);
1453
- },
1454
- saveLatestBlockNumberProcessed: async (parameters2) => {
1455
- const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
1456
- indexingProgress.set(key, parameters2.latestBlockNumber);
1457
- },
1458
- getLatestBlockNumberProcessed: async (parameters2) => {
1459
- const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
1460
- const value = indexingProgress.get(key);
1461
- return value === void 0 ? null : { latestBlockNumber: value };
1462
1372
  }
1463
1373
  };
1464
1374
  }
@@ -1846,7 +1756,7 @@ function morpho(parameters) {
1846
1756
  );
1847
1757
  const buyOffersPerLoanAsset = /* @__PURE__ */ new Map();
1848
1758
  for (const offer of buyOffers) {
1849
- const chainName = getChain(offer.chainId)?.name;
1759
+ const chainName = mempool.Chain.getChain(offer.chainId)?.name;
1850
1760
  const loanTokens = buyOffersPerLoanAsset.get(chainName) ?? /* @__PURE__ */ new Map();
1851
1761
  const offers2 = loanTokens.get(offer.loanToken.toLowerCase()) ?? [];
1852
1762
  offers2.push(offer);
@@ -1857,7 +1767,7 @@ function morpho(parameters) {
1857
1767
  Array.from(buyOffersPerLoanAsset.entries()).map(async ([name, loanTokens]) => {
1858
1768
  const chainName = name;
1859
1769
  const publicClient = publicClients[chainName];
1860
- const morpho2 = morphoPerChain.get(chains[chainName].id);
1770
+ const morpho2 = morphoPerChain.get(mempool.Chain.chains[chainName].id);
1861
1771
  if (!publicClient) {
1862
1772
  const offers2 = Array.from(loanTokens.values()).flat();
1863
1773
  for (const offer of offers2) {
@@ -1938,7 +1848,6 @@ function morpho(parameters) {
1938
1848
  }
1939
1849
 
1940
1850
  exports.ApiSchema = apiSchema_exports;
1941
- exports.Chain = Chain_exports;
1942
1851
  exports.Logger = Logger_exports;
1943
1852
  exports.OfferStore = OfferStore_exports;
1944
1853
  exports.Router = router_exports;