@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,6 +1,5 @@
1
- import { Errors, LLTV, Offer, Format, Time, Maturity } from '@morpho-dev/mempool';
1
+ import { Errors, LLTV, Offer, Format, Time, Maturity, Chain } from '@morpho-dev/mempool';
2
2
  export * from '@morpho-dev/mempool';
3
- import { base, mainnet } from 'viem/chains';
4
3
  import { z } from 'zod/v4';
5
4
  import { createDocument } from 'zod-openapi';
6
5
  import { parseUnits, maxUint256, formatUnits, parseAbi } from 'viem';
@@ -15,85 +14,6 @@ var __export = (target, all) => {
15
14
  __defProp(target, name, { get: all[name], enumerable: true });
16
15
  };
17
16
 
18
- // src/Chain.ts
19
- var Chain_exports = {};
20
- __export(Chain_exports, {
21
- ChainId: () => ChainId,
22
- chainIds: () => chainIds,
23
- chainNames: () => chainNames,
24
- chains: () => chains,
25
- getChain: () => getChain,
26
- getWhitelistedChains: () => getWhitelistedChains
27
- });
28
- var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
29
- var ChainId = {
30
- ETHEREUM: BigInt(mainnet.id),
31
- BASE: BigInt(base.id),
32
- "ETHEREUM-VIRTUAL-TESTNET": 109111114n
33
- };
34
- var chainIds = new Set(Object.values(ChainId));
35
- var chainNameLookup = new Map(Object.entries(ChainId).map(([key, value]) => [value, key]));
36
- function getChain(chainId) {
37
- const chainName = chainNameLookup.get(chainId)?.toLowerCase();
38
- if (!chainName) {
39
- return void 0;
40
- }
41
- return chains[chainName];
42
- }
43
- var getWhitelistedChains = () => {
44
- return [chains.ethereum, chains.base, chains["ethereum-virtual-testnet"]];
45
- };
46
- var chains = {
47
- ethereum: {
48
- ...mainnet,
49
- id: ChainId.ETHEREUM,
50
- name: "ethereum",
51
- whitelistedAssets: new Set(
52
- [
53
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
54
- // USDC
55
- "0x6B175474E89094C44Da98b954EedeAC495271d0F"
56
- // DAI
57
- ].map((address) => address.toLowerCase())
58
- ),
59
- morpho: "0x0000000000000000000000000000000000000000"
60
- },
61
- base: {
62
- ...base,
63
- id: ChainId.BASE,
64
- name: "base",
65
- whitelistedAssets: new Set(
66
- [
67
- "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
68
- // USDC
69
- "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"
70
- // DAI
71
- ].map((address) => address.toLowerCase())
72
- ),
73
- morpho: "0x0000000000000000000000000000000000000000"
74
- },
75
- "ethereum-virtual-testnet": {
76
- ...mainnet,
77
- id: 109111114n,
78
- name: "ethereum-virtual-testnet",
79
- whitelistedAssets: new Set(
80
- [
81
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
82
- // USDC
83
- "0x6B175474E89094C44Da98b954EedeAC495271d0F"
84
- // DAI
85
- ].map((address) => address.toLowerCase())
86
- ),
87
- morpho: "0x11a002d45db720ed47a80d2f3489cba5b833eaf5",
88
- // @TODO: This is mock Consumed contract, update with Terms once stable
89
- mempool: {
90
- address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
91
- deploymentBlock: 23223727,
92
- reindexBuffer: 10
93
- }
94
- }
95
- };
96
-
97
17
  // src/core/apiSchema/index.ts
98
18
  var apiSchema_exports = {};
99
19
  __export(apiSchema_exports, {
@@ -1101,7 +1021,6 @@ function memory(parameters) {
1101
1021
  const map = parameters.offers;
1102
1022
  const filled = parameters.filled;
1103
1023
  const consumedIds = /* @__PURE__ */ new Set();
1104
- const indexingProgress = /* @__PURE__ */ new Map();
1105
1024
  const create = async (parameters2) => {
1106
1025
  if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
1107
1026
  map.set(parameters2.offer.hash.toLowerCase(), {
@@ -1172,7 +1091,7 @@ function memory(parameters) {
1172
1091
  let {
1173
1092
  creators,
1174
1093
  side,
1175
- chains: chains2,
1094
+ chains,
1176
1095
  loanTokens,
1177
1096
  status = ["valid"],
1178
1097
  callbackAddresses,
@@ -1243,7 +1162,7 @@ function memory(parameters) {
1243
1162
  offers = offers.filter((o) => o.expiry >= now);
1244
1163
  creators && (offers = offers.filter((o) => creators.includes(o.offering.toLowerCase())));
1245
1164
  side && (offers = offers.filter((o) => o.buy === buy));
1246
- chains2 && (offers = offers.filter((o) => chains2.includes(Number(o.chainId))));
1165
+ chains && (offers = offers.filter((o) => chains.includes(Number(o.chainId))));
1247
1166
  loanTokens && (offers = offers.filter((o) => loanTokens.includes(o.loanToken.toLowerCase())));
1248
1167
  status && (offers = offers.filter((o) => status.includes(o.status)));
1249
1168
  callbackAddresses && (offers = offers.filter(
@@ -1449,15 +1368,6 @@ function memory(parameters) {
1449
1368
  filledForOffering.set(nonce, current + parameters2.consumed);
1450
1369
  filledForChain.set(address, filledForOffering);
1451
1370
  filled.set(chainId, filledForChain);
1452
- },
1453
- saveLatestBlockNumberProcessed: async (parameters2) => {
1454
- const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
1455
- indexingProgress.set(key, parameters2.latestBlockNumber);
1456
- },
1457
- getLatestBlockNumberProcessed: async (parameters2) => {
1458
- const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
1459
- const value = indexingProgress.get(key);
1460
- return value === void 0 ? null : { latestBlockNumber: value };
1461
1371
  }
1462
1372
  };
1463
1373
  }
@@ -1845,7 +1755,7 @@ function morpho(parameters) {
1845
1755
  );
1846
1756
  const buyOffersPerLoanAsset = /* @__PURE__ */ new Map();
1847
1757
  for (const offer of buyOffers) {
1848
- const chainName = getChain(offer.chainId)?.name;
1758
+ const chainName = Chain.getChain(offer.chainId)?.name;
1849
1759
  const loanTokens = buyOffersPerLoanAsset.get(chainName) ?? /* @__PURE__ */ new Map();
1850
1760
  const offers2 = loanTokens.get(offer.loanToken.toLowerCase()) ?? [];
1851
1761
  offers2.push(offer);
@@ -1856,7 +1766,7 @@ function morpho(parameters) {
1856
1766
  Array.from(buyOffersPerLoanAsset.entries()).map(async ([name, loanTokens]) => {
1857
1767
  const chainName = name;
1858
1768
  const publicClient = publicClients[chainName];
1859
- const morpho2 = morphoPerChain.get(chains[chainName].id);
1769
+ const morpho2 = morphoPerChain.get(Chain.chains[chainName].id);
1860
1770
  if (!publicClient) {
1861
1771
  const offers2 = Array.from(loanTokens.values()).flat();
1862
1772
  for (const offer of offers2) {
@@ -1936,6 +1846,6 @@ function morpho(parameters) {
1936
1846
  ];
1937
1847
  }
1938
1848
 
1939
- export { apiSchema_exports as ApiSchema, Chain_exports as Chain, Logger_exports as Logger, OfferStore_exports as OfferStore, router_exports as Router, RouterEvent_exports as RouterEvent, RouterOffer_exports as RouterOffer, utils_exports as Utils, Validation_exports as Validation, ValidationRule_exports as ValidationRule };
1849
+ export { apiSchema_exports as ApiSchema, Logger_exports as Logger, OfferStore_exports as OfferStore, router_exports as Router, RouterEvent_exports as RouterEvent, RouterOffer_exports as RouterOffer, utils_exports as Utils, Validation_exports as Validation, ValidationRule_exports as ValidationRule };
1940
1850
  //# sourceMappingURL=index.node.mjs.map
1941
1851
  //# sourceMappingURL=index.node.mjs.map