@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.
- package/dist/index.browser.d.cts +5 -55
- package/dist/index.browser.d.ts +5 -55
- package/dist/index.browser.js +4 -95
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +6 -96
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +7 -57
- package/dist/index.node.d.ts +7 -57
- package/dist/index.node.js +4 -95
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +6 -96
- package/dist/index.node.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.browser.mjs
CHANGED
|
@@ -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 { parseUnits, maxUint256, formatUnits, parseAbi } from 'viem';
|
|
5
4
|
import { z } from 'zod/v4';
|
|
6
5
|
import { createDocument } from 'zod-openapi';
|
|
@@ -14,85 +13,6 @@ var __export = (target, all) => {
|
|
|
14
13
|
};
|
|
15
14
|
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
|
|
16
15
|
|
|
17
|
-
// src/Chain.ts
|
|
18
|
-
var Chain_exports = {};
|
|
19
|
-
__export(Chain_exports, {
|
|
20
|
-
ChainId: () => ChainId,
|
|
21
|
-
chainIds: () => chainIds,
|
|
22
|
-
chainNames: () => chainNames,
|
|
23
|
-
chains: () => chains,
|
|
24
|
-
getChain: () => getChain,
|
|
25
|
-
getWhitelistedChains: () => getWhitelistedChains
|
|
26
|
-
});
|
|
27
|
-
var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
28
|
-
var ChainId = {
|
|
29
|
-
ETHEREUM: BigInt(mainnet.id),
|
|
30
|
-
BASE: BigInt(base.id),
|
|
31
|
-
"ETHEREUM-VIRTUAL-TESTNET": 109111114n
|
|
32
|
-
};
|
|
33
|
-
var chainIds = new Set(Object.values(ChainId));
|
|
34
|
-
var chainNameLookup = new Map(Object.entries(ChainId).map(([key, value]) => [value, key]));
|
|
35
|
-
function getChain(chainId) {
|
|
36
|
-
const chainName = chainNameLookup.get(chainId)?.toLowerCase();
|
|
37
|
-
if (!chainName) {
|
|
38
|
-
return void 0;
|
|
39
|
-
}
|
|
40
|
-
return chains[chainName];
|
|
41
|
-
}
|
|
42
|
-
var getWhitelistedChains = () => {
|
|
43
|
-
return [chains.ethereum, chains.base, chains["ethereum-virtual-testnet"]];
|
|
44
|
-
};
|
|
45
|
-
var chains = {
|
|
46
|
-
ethereum: {
|
|
47
|
-
...mainnet,
|
|
48
|
-
id: ChainId.ETHEREUM,
|
|
49
|
-
name: "ethereum",
|
|
50
|
-
whitelistedAssets: new Set(
|
|
51
|
-
[
|
|
52
|
-
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
53
|
-
// USDC
|
|
54
|
-
"0x6B175474E89094C44Da98b954EedeAC495271d0F"
|
|
55
|
-
// DAI
|
|
56
|
-
].map((address) => address.toLowerCase())
|
|
57
|
-
),
|
|
58
|
-
morpho: "0x0000000000000000000000000000000000000000"
|
|
59
|
-
},
|
|
60
|
-
base: {
|
|
61
|
-
...base,
|
|
62
|
-
id: ChainId.BASE,
|
|
63
|
-
name: "base",
|
|
64
|
-
whitelistedAssets: new Set(
|
|
65
|
-
[
|
|
66
|
-
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
67
|
-
// USDC
|
|
68
|
-
"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"
|
|
69
|
-
// DAI
|
|
70
|
-
].map((address) => address.toLowerCase())
|
|
71
|
-
),
|
|
72
|
-
morpho: "0x0000000000000000000000000000000000000000"
|
|
73
|
-
},
|
|
74
|
-
"ethereum-virtual-testnet": {
|
|
75
|
-
...mainnet,
|
|
76
|
-
id: 109111114n,
|
|
77
|
-
name: "ethereum-virtual-testnet",
|
|
78
|
-
whitelistedAssets: new Set(
|
|
79
|
-
[
|
|
80
|
-
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
81
|
-
// USDC
|
|
82
|
-
"0x6B175474E89094C44Da98b954EedeAC495271d0F"
|
|
83
|
-
// DAI
|
|
84
|
-
].map((address) => address.toLowerCase())
|
|
85
|
-
),
|
|
86
|
-
morpho: "0x11a002d45db720ed47a80d2f3489cba5b833eaf5",
|
|
87
|
-
// @TODO: This is mock Consumed contract, update with Terms once stable
|
|
88
|
-
mempool: {
|
|
89
|
-
address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
|
|
90
|
-
deploymentBlock: 23223727,
|
|
91
|
-
reindexBuffer: 10
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
16
|
// src/core/router/Client.ts
|
|
97
17
|
var Client_exports = {};
|
|
98
18
|
__export(Client_exports, {
|
|
@@ -1080,7 +1000,6 @@ function memory(parameters) {
|
|
|
1080
1000
|
const map = parameters.offers;
|
|
1081
1001
|
const filled = parameters.filled;
|
|
1082
1002
|
const consumedIds = /* @__PURE__ */ new Set();
|
|
1083
|
-
const indexingProgress = /* @__PURE__ */ new Map();
|
|
1084
1003
|
const create = async (parameters2) => {
|
|
1085
1004
|
if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
|
|
1086
1005
|
map.set(parameters2.offer.hash.toLowerCase(), {
|
|
@@ -1151,7 +1070,7 @@ function memory(parameters) {
|
|
|
1151
1070
|
let {
|
|
1152
1071
|
creators,
|
|
1153
1072
|
side,
|
|
1154
|
-
chains
|
|
1073
|
+
chains,
|
|
1155
1074
|
loanTokens,
|
|
1156
1075
|
status = ["valid"],
|
|
1157
1076
|
callbackAddresses,
|
|
@@ -1222,7 +1141,7 @@ function memory(parameters) {
|
|
|
1222
1141
|
offers = offers.filter((o) => o.expiry >= now);
|
|
1223
1142
|
creators && (offers = offers.filter((o) => creators.includes(o.offering.toLowerCase())));
|
|
1224
1143
|
side && (offers = offers.filter((o) => o.buy === buy));
|
|
1225
|
-
|
|
1144
|
+
chains && (offers = offers.filter((o) => chains.includes(Number(o.chainId))));
|
|
1226
1145
|
loanTokens && (offers = offers.filter((o) => loanTokens.includes(o.loanToken.toLowerCase())));
|
|
1227
1146
|
status && (offers = offers.filter((o) => status.includes(o.status)));
|
|
1228
1147
|
callbackAddresses && (offers = offers.filter(
|
|
@@ -1428,15 +1347,6 @@ function memory(parameters) {
|
|
|
1428
1347
|
filledForOffering.set(nonce, current + parameters2.consumed);
|
|
1429
1348
|
filledForChain.set(address, filledForOffering);
|
|
1430
1349
|
filled.set(chainId, filledForChain);
|
|
1431
|
-
},
|
|
1432
|
-
saveLatestBlockNumberProcessed: async (parameters2) => {
|
|
1433
|
-
const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
|
|
1434
|
-
indexingProgress.set(key, parameters2.latestBlockNumber);
|
|
1435
|
-
},
|
|
1436
|
-
getLatestBlockNumberProcessed: async (parameters2) => {
|
|
1437
|
-
const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
|
|
1438
|
-
const value = indexingProgress.get(key);
|
|
1439
|
-
return value === void 0 ? null : { latestBlockNumber: value };
|
|
1440
1350
|
}
|
|
1441
1351
|
};
|
|
1442
1352
|
}
|
|
@@ -1575,7 +1485,7 @@ function morpho(parameters) {
|
|
|
1575
1485
|
);
|
|
1576
1486
|
const buyOffersPerLoanAsset = /* @__PURE__ */ new Map();
|
|
1577
1487
|
for (const offer of buyOffers) {
|
|
1578
|
-
const chainName = getChain(offer.chainId)?.name;
|
|
1488
|
+
const chainName = Chain.getChain(offer.chainId)?.name;
|
|
1579
1489
|
const loanTokens = buyOffersPerLoanAsset.get(chainName) ?? /* @__PURE__ */ new Map();
|
|
1580
1490
|
const offers2 = loanTokens.get(offer.loanToken.toLowerCase()) ?? [];
|
|
1581
1491
|
offers2.push(offer);
|
|
@@ -1586,7 +1496,7 @@ function morpho(parameters) {
|
|
|
1586
1496
|
Array.from(buyOffersPerLoanAsset.entries()).map(async ([name, loanTokens]) => {
|
|
1587
1497
|
const chainName = name;
|
|
1588
1498
|
const publicClient = publicClients[chainName];
|
|
1589
|
-
const morpho2 = morphoPerChain.get(chains[chainName].id);
|
|
1499
|
+
const morpho2 = morphoPerChain.get(Chain.chains[chainName].id);
|
|
1590
1500
|
if (!publicClient) {
|
|
1591
1501
|
const offers2 = Array.from(loanTokens.values()).flat();
|
|
1592
1502
|
for (const offer of offers2) {
|
|
@@ -1666,6 +1576,6 @@ function morpho(parameters) {
|
|
|
1666
1576
|
];
|
|
1667
1577
|
}
|
|
1668
1578
|
|
|
1669
|
-
export {
|
|
1579
|
+
export { OfferStore_exports as OfferStore, Client_exports as Router, RouterEvent_exports as RouterEvent, RouterOffer_exports as RouterOffer, utils_exports as Utils, Validation_exports as Validation, ValidationRule_exports as ValidationRule };
|
|
1670
1580
|
//# sourceMappingURL=index.browser.mjs.map
|
|
1671
1581
|
//# sourceMappingURL=index.browser.mjs.map
|