@morpho-dev/router 0.0.17 → 0.0.19

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.
Files changed (32) hide show
  1. package/dist/index.browser.d.cts +139 -12
  2. package/dist/index.browser.d.ts +139 -12
  3. package/dist/index.browser.js +533 -92
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.browser.mjs +534 -89
  6. package/dist/index.browser.mjs.map +1 -1
  7. package/dist/index.node.d.cts +132 -750
  8. package/dist/index.node.d.ts +132 -750
  9. package/dist/index.node.js +895 -1302
  10. package/dist/index.node.js.map +1 -1
  11. package/dist/index.node.mjs +894 -1291
  12. package/dist/index.node.mjs.map +1 -1
  13. package/package.json +3 -12
  14. package/dist/drizzle/0000_add-offers-table.sql +0 -37
  15. package/dist/drizzle/0001_create_offer_status_relation.sql +0 -10
  16. package/dist/drizzle/0002_add_created_at_in_offer_status_relation.sql +0 -3
  17. package/dist/drizzle/0003_add-cursor-indices-to-offers.sql +0 -6
  18. package/dist/drizzle/0004_offer-start.sql +0 -1
  19. package/dist/drizzle/0005_rename-price-token-buy.sql +0 -8
  20. package/dist/drizzle/0006_rename-buy.sql +0 -3
  21. package/dist/drizzle/0007_rename-offering.sql +0 -3
  22. package/dist/drizzle/0008_add-consumed-relation.sql +0 -10
  23. package/dist/drizzle/meta/0000_snapshot.json +0 -344
  24. package/dist/drizzle/meta/0001_snapshot.json +0 -426
  25. package/dist/drizzle/meta/0002_snapshot.json +0 -439
  26. package/dist/drizzle/meta/0003_snapshot.json +0 -553
  27. package/dist/drizzle/meta/0004_snapshot.json +0 -559
  28. package/dist/drizzle/meta/0005_snapshot.json +0 -559
  29. package/dist/drizzle/meta/0006_snapshot.json +0 -559
  30. package/dist/drizzle/meta/0007_snapshot.json +0 -559
  31. package/dist/drizzle/meta/0008_snapshot.json +0 -635
  32. package/dist/drizzle/meta/_journal.json +0 -69
@@ -7,17 +7,8 @@ var zodOpenapi = require('zod-openapi');
7
7
  var viem = require('viem');
8
8
  var nodeServer = require('@hono/node-server');
9
9
  var hono = require('hono');
10
- var drizzle_orm_star = require('drizzle-orm');
11
- var path = require('path');
12
- var pglite = require('@electric-sql/pglite');
13
- var nodePostgres = require('drizzle-orm/node-postgres');
14
- var migrator$1 = require('drizzle-orm/node-postgres/migrator');
15
- var pglite$1 = require('drizzle-orm/pglite');
16
- var migrator = require('drizzle-orm/pglite/migrator');
17
- var pg = require('pg');
18
- var pgCore = require('drizzle-orm/pg-core');
19
- var blueSdkViem = require('@morpho-org/blue-sdk-viem');
20
10
  var fs = require('fs');
11
+ var path = require('path');
21
12
  var nc = require('crypto');
22
13
  var accounts = require('viem/accounts');
23
14
  var utils = require('viem/utils');
@@ -44,9 +35,8 @@ function _interopNamespace(e) {
44
35
  return Object.freeze(n);
45
36
  }
46
37
 
47
- var drizzle_orm_star__namespace = /*#__PURE__*/_interopNamespace(drizzle_orm_star);
48
- var path__default = /*#__PURE__*/_interopDefault(path);
49
38
  var fs__default = /*#__PURE__*/_interopDefault(fs);
39
+ var path__default = /*#__PURE__*/_interopDefault(path);
50
40
  var nc__namespace = /*#__PURE__*/_interopNamespace(nc);
51
41
 
52
42
  var __create = Object.create;
@@ -68,15 +58,14 @@ var __export = (target, all) => {
68
58
  for (var name in all)
69
59
  __defProp(target, name, { get: all[name], enumerable: true });
70
60
  };
71
- var __copyProps = (to, from2, except, desc3) => {
61
+ var __copyProps = (to, from2, except, desc) => {
72
62
  if (from2 && typeof from2 === "object" || typeof from2 === "function") {
73
63
  for (let key of __getOwnPropNames(from2))
74
64
  if (!__hasOwnProp.call(to, key) && key !== except)
75
- __defProp(to, key, { get: () => from2[key], enumerable: !(desc3 = __getOwnPropDesc(from2, key)) || desc3.enumerable });
65
+ __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
76
66
  }
77
67
  return to;
78
68
  };
79
- var __reExport = (target, mod5, secondTarget) => (__copyProps(target, mod5, "default"), secondTarget);
80
69
  var __toESM = (mod5, isNodeMode, target) => (target = mod5 != null ? __create(__getProtoOf(mod5)) : {}, __copyProps(
81
70
  // If the importer is in node compatibility mode or this is not an ESM
82
71
  // file that has been converted to a CommonJS file using a Babel-
@@ -410,18 +399,18 @@ var require_common = __commonJS({
410
399
  if (typeof args[0] !== "string") {
411
400
  args.unshift("%O");
412
401
  }
413
- let index2 = 0;
402
+ let index = 0;
414
403
  args[0] = args[0].replace(/%([a-zA-Z%])/g, (match2, format) => {
415
404
  if (match2 === "%%") {
416
405
  return "%";
417
406
  }
418
- index2++;
407
+ index++;
419
408
  const formatter = createDebug.formatters[format];
420
409
  if (typeof formatter === "function") {
421
- const val = args[index2];
410
+ const val = args[index];
422
411
  match2 = formatter.call(self2, val);
423
- args.splice(index2, 1);
424
- index2--;
412
+ args.splice(index, 1);
413
+ index--;
425
414
  }
426
415
  return match2;
427
416
  });
@@ -656,15 +645,15 @@ var require_browser = __commonJS({
656
645
  }
657
646
  const c = "color: " + this.color;
658
647
  args.splice(1, 0, c, "color: inherit");
659
- let index2 = 0;
648
+ let index = 0;
660
649
  let lastC = 0;
661
650
  args[0].replace(/%[a-zA-Z%]/g, (match2) => {
662
651
  if (match2 === "%%") {
663
652
  return;
664
653
  }
665
- index2++;
654
+ index++;
666
655
  if (match2 === "%c") {
667
- lastC = index2;
656
+ lastC = index;
668
657
  }
669
658
  });
670
659
  args.splice(lastC, 0, c);
@@ -1266,8 +1255,8 @@ var require_req = __commonJS({
1266
1255
  if (req.originalUrl) {
1267
1256
  _req.url = req.originalUrl;
1268
1257
  } else {
1269
- const path3 = req.path;
1270
- _req.url = typeof path3 === "string" ? path3 : req.url ? req.url.path || req.url : void 0;
1258
+ const path2 = req.path;
1259
+ _req.url = typeof path2 === "string" ? path2 : req.url ? req.url.path || req.url : void 0;
1271
1260
  }
1272
1261
  if (req.query) {
1273
1262
  _req.query = req.query;
@@ -1450,17 +1439,17 @@ var require_parse = __commonJS({
1450
1439
  const wildcards = [];
1451
1440
  var wcLen = 0;
1452
1441
  const secret = paths2.reduce(function(o, strPath, ix) {
1453
- var path3 = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ""));
1442
+ var path2 = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ""));
1454
1443
  const leadingBracket = strPath[0] === "[";
1455
- path3 = path3.map((p) => {
1444
+ path2 = path2.map((p) => {
1456
1445
  if (p[0] === "[") return p.substr(1, p.length - 2);
1457
1446
  else return p;
1458
1447
  });
1459
- const star = path3.indexOf("*");
1448
+ const star = path2.indexOf("*");
1460
1449
  if (star > -1) {
1461
- const before = path3.slice(0, star);
1450
+ const before = path2.slice(0, star);
1462
1451
  const beforeStr = before.join(".");
1463
- const after = path3.slice(star + 1, path3.length);
1452
+ const after = path2.slice(star + 1, path2.length);
1464
1453
  const nested = after.length > 0;
1465
1454
  wcLen++;
1466
1455
  wildcards.push({
@@ -1471,7 +1460,7 @@ var require_parse = __commonJS({
1471
1460
  });
1472
1461
  } else {
1473
1462
  o[strPath] = {
1474
- path: path3,
1463
+ path: path2,
1475
1464
  val: void 0,
1476
1465
  precensored: false,
1477
1466
  circle: "",
@@ -1516,20 +1505,20 @@ var require_redactor = __commonJS({
1516
1505
  return redact;
1517
1506
  }
1518
1507
  function redactTmpl(secret, isCensorFct, censorFctTakesPath) {
1519
- return Object.keys(secret).map((path3) => {
1520
- const { escPath, leadingBracket, path: arrPath } = secret[path3];
1508
+ return Object.keys(secret).map((path2) => {
1509
+ const { escPath, leadingBracket, path: arrPath } = secret[path2];
1521
1510
  const skip = leadingBracket ? 1 : 0;
1522
1511
  const delim = leadingBracket ? "" : ".";
1523
1512
  const hops = [];
1524
1513
  var match2;
1525
- while ((match2 = rx.exec(path3)) !== null) {
1514
+ while ((match2 = rx.exec(path2)) !== null) {
1526
1515
  const [, ix] = match2;
1527
- const { index: index2, input } = match2;
1528
- if (index2 > skip) hops.push(input.substring(0, index2 - (ix ? 0 : 1)));
1516
+ const { index, input } = match2;
1517
+ if (index > skip) hops.push(input.substring(0, index - (ix ? 0 : 1)));
1529
1518
  }
1530
1519
  var existence = hops.map((p) => `o${delim}${p}`).join(" && ");
1531
- if (existence.length === 0) existence += `o${delim}${path3} != null`;
1532
- else existence += ` && o${delim}${path3} != null`;
1520
+ if (existence.length === 0) existence += `o${delim}${path2} != null`;
1521
+ else existence += ` && o${delim}${path2} != null`;
1533
1522
  const circularDetection = `
1534
1523
  switch (true) {
1535
1524
  ${hops.reverse().map((p) => `
@@ -1542,12 +1531,12 @@ var require_redactor = __commonJS({
1542
1531
  const censorArgs = censorFctTakesPath ? `val, ${JSON.stringify(arrPath)}` : `val`;
1543
1532
  return `
1544
1533
  if (${existence}) {
1545
- const val = o${delim}${path3}
1534
+ const val = o${delim}${path2}
1546
1535
  if (val === censor) {
1547
1536
  secret[${escPath}].precensored = true
1548
1537
  } else {
1549
1538
  secret[${escPath}].val = val
1550
- o${delim}${path3} = ${isCensorFct ? `censor(${censorArgs})` : "censor"}
1539
+ o${delim}${path2} = ${isCensorFct ? `censor(${censorArgs})` : "censor"}
1551
1540
  ${circularDetection}
1552
1541
  }
1553
1542
  }
@@ -1598,13 +1587,13 @@ var require_modifiers = __commonJS({
1598
1587
  target[k] = values[i];
1599
1588
  }
1600
1589
  }
1601
- function groupRedact(o, path3, censor, isCensorFct, censorFctTakesPath) {
1602
- const target = get2(o, path3);
1590
+ function groupRedact(o, path2, censor, isCensorFct, censorFctTakesPath) {
1591
+ const target = get2(o, path2);
1603
1592
  if (target == null || typeof target === "string") return { keys: null, values: null, target, flat: true };
1604
1593
  const keys = Object.keys(target);
1605
1594
  const keysLength = keys.length;
1606
- const pathLength = path3.length;
1607
- const pathWithKey = censorFctTakesPath ? [...path3] : void 0;
1595
+ const pathLength = path2.length;
1596
+ const pathWithKey = censorFctTakesPath ? [...path2] : void 0;
1608
1597
  const values = new Array(keysLength);
1609
1598
  for (var i = 0; i < keysLength; i++) {
1610
1599
  const key = keys[i];
@@ -1622,29 +1611,29 @@ var require_modifiers = __commonJS({
1622
1611
  }
1623
1612
  function nestedRestore(instructions) {
1624
1613
  for (let i = 0; i < instructions.length; i++) {
1625
- const { target, path: path3, value } = instructions[i];
1614
+ const { target, path: path2, value } = instructions[i];
1626
1615
  let current = target;
1627
- for (let i2 = path3.length - 1; i2 > 0; i2--) {
1628
- current = current[path3[i2]];
1616
+ for (let i2 = path2.length - 1; i2 > 0; i2--) {
1617
+ current = current[path2[i2]];
1629
1618
  }
1630
- current[path3[0]] = value;
1619
+ current[path2[0]] = value;
1631
1620
  }
1632
1621
  }
1633
- function nestedRedact(store, o, path3, ns, censor, isCensorFct, censorFctTakesPath) {
1634
- const target = get2(o, path3);
1622
+ function nestedRedact(store, o, path2, ns, censor, isCensorFct, censorFctTakesPath) {
1623
+ const target = get2(o, path2);
1635
1624
  if (target == null) return;
1636
1625
  const keys = Object.keys(target);
1637
1626
  const keysLength = keys.length;
1638
1627
  for (var i = 0; i < keysLength; i++) {
1639
1628
  const key = keys[i];
1640
- specialSet(store, target, key, path3, ns, censor, isCensorFct, censorFctTakesPath);
1629
+ specialSet(store, target, key, path2, ns, censor, isCensorFct, censorFctTakesPath);
1641
1630
  }
1642
1631
  return store;
1643
1632
  }
1644
1633
  function has(obj, prop) {
1645
1634
  return obj !== void 0 && obj !== null ? "hasOwn" in Object ? Object.hasOwn(obj, prop) : Object.prototype.hasOwnProperty.call(obj, prop) : false;
1646
1635
  }
1647
- function specialSet(store, o, k, path3, afterPath, censor, isCensorFct, censorFctTakesPath) {
1636
+ function specialSet(store, o, k, path2, afterPath, censor, isCensorFct, censorFctTakesPath) {
1648
1637
  const afterPathLen = afterPath.length;
1649
1638
  const lastPathIndex = afterPathLen - 1;
1650
1639
  const originalKey = k;
@@ -1685,7 +1674,7 @@ var require_modifiers = __commonJS({
1685
1674
  if (consecutive) {
1686
1675
  redactPathCurrent = node(redactPathCurrent, wck, depth);
1687
1676
  level = i;
1688
- ov = iterateNthLevel(wcov, level - 1, k, path3, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, o[originalKey], depth + 1);
1677
+ ov = iterateNthLevel(wcov, level - 1, k, path2, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, o[originalKey], depth + 1);
1689
1678
  } else {
1690
1679
  if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
1691
1680
  if (kIsWc) {
@@ -1693,7 +1682,7 @@ var require_modifiers = __commonJS({
1693
1682
  } else {
1694
1683
  ov = wcov[k];
1695
1684
  }
1696
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path3, originalKey, ...afterPath]) : censor(ov) : censor;
1685
+ nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path2, originalKey, ...afterPath]) : censor(ov) : censor;
1697
1686
  if (kIsWc) {
1698
1687
  const rv = restoreInstr(node(redactPathCurrent, wck, depth), ov, o[originalKey]);
1699
1688
  store.push(rv);
@@ -1715,7 +1704,7 @@ var require_modifiers = __commonJS({
1715
1704
  } else {
1716
1705
  ov = n[k];
1717
1706
  redactPathCurrent = node(redactPathCurrent, k, depth);
1718
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path3, originalKey, ...afterPath]) : censor(ov) : censor;
1707
+ nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path2, originalKey, ...afterPath]) : censor(ov) : censor;
1719
1708
  if (has(n, k) && nv === ov || nv === void 0 && censor !== void 0) ; else {
1720
1709
  const rv = restoreInstr(redactPathCurrent, ov, o[originalKey]);
1721
1710
  store.push(rv);
@@ -1735,7 +1724,7 @@ var require_modifiers = __commonJS({
1735
1724
  }
1736
1725
  return n;
1737
1726
  }
1738
- function iterateNthLevel(wcov, level, k, path3, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) {
1727
+ function iterateNthLevel(wcov, level, k, path2, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) {
1739
1728
  if (level === 0) {
1740
1729
  if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
1741
1730
  if (kIsWc) {
@@ -1743,7 +1732,7 @@ var require_modifiers = __commonJS({
1743
1732
  } else {
1744
1733
  ov = wcov[k];
1745
1734
  }
1746
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path3, originalKey, ...afterPath]) : censor(ov) : censor;
1735
+ nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path2, originalKey, ...afterPath]) : censor(ov) : censor;
1747
1736
  if (kIsWc) {
1748
1737
  const rv = restoreInstr(redactPathCurrent, ov, parent);
1749
1738
  store.push(rv);
@@ -1760,7 +1749,7 @@ var require_modifiers = __commonJS({
1760
1749
  for (const key in wcov) {
1761
1750
  if (typeof wcov[key] === "object") {
1762
1751
  redactPathCurrent = node(redactPathCurrent, key, depth);
1763
- iterateNthLevel(wcov[key], level - 1, k, path3, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1);
1752
+ iterateNthLevel(wcov[key], level - 1, k, path2, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1);
1764
1753
  }
1765
1754
  }
1766
1755
  }
@@ -1782,12 +1771,12 @@ var require_modifiers = __commonJS({
1782
1771
  }
1783
1772
  function restoreInstr(node2, value, target) {
1784
1773
  let current = node2;
1785
- const path3 = [];
1774
+ const path2 = [];
1786
1775
  do {
1787
- path3.push(current.key);
1776
+ path2.push(current.key);
1788
1777
  current = current.parent;
1789
1778
  } while (current.parent != null);
1790
- return { path: path3, value, target };
1779
+ return { path: path2, value, target };
1791
1780
  }
1792
1781
  }
1793
1782
  });
@@ -1816,10 +1805,10 @@ var require_restorer = __commonJS({
1816
1805
  };
1817
1806
  }
1818
1807
  function resetTmpl(secret, paths2) {
1819
- return paths2.map((path3) => {
1820
- const { circle, escPath, leadingBracket } = secret[path3];
1808
+ return paths2.map((path2) => {
1809
+ const { circle, escPath, leadingBracket } = secret[path2];
1821
1810
  const delim = leadingBracket ? "" : ".";
1822
- const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${path3} = secret[${escPath}].val`;
1811
+ const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${path2} = secret[${escPath}].val`;
1823
1812
  const clear = `secret[${escPath}].val = undefined`;
1824
1813
  return `
1825
1814
  if (secret[${escPath}].val !== undefined) {
@@ -2021,8 +2010,8 @@ var require_redaction = __commonJS({
2021
2010
  if (o[ns] === null) {
2022
2011
  return o;
2023
2012
  }
2024
- const { index: index2 } = next;
2025
- const nextPath = `${str.substr(index2, str.length - 1)}`;
2013
+ const { index } = next;
2014
+ const nextPath = `${str.substr(index, str.length - 1)}`;
2026
2015
  o[ns] = o[ns] || [];
2027
2016
  if (ns !== wildcardFirstSym && o[ns].length === 0) {
2028
2017
  o[ns].push(...o[wildcardFirstSym] || []);
@@ -2047,8 +2036,8 @@ var require_redaction = __commonJS({
2047
2036
  if (shape[k] === null) {
2048
2037
  o[k] = (value) => topCensor(value, [k]);
2049
2038
  } else {
2050
- const wrappedCensor = typeof censor === "function" ? (value, path3) => {
2051
- return censor(value, [k, ...path3]);
2039
+ const wrappedCensor = typeof censor === "function" ? (value, path2) => {
2040
+ return censor(value, [k, ...path2]);
2052
2041
  } : censor;
2053
2042
  o[k] = fastRedact({
2054
2043
  paths: shape[k],
@@ -2108,8 +2097,8 @@ var require_quick_format_unescaped = __commonJS({
2108
2097
  if (len === 1) return f;
2109
2098
  var objects = new Array(len);
2110
2099
  objects[0] = ss(f);
2111
- for (var index2 = 1; index2 < len; index2++) {
2112
- objects[index2] = ss(args[index2]);
2100
+ for (var index = 1; index < len; index++) {
2101
+ objects[index] = ss(args[index]);
2113
2102
  }
2114
2103
  return objects.join(" ");
2115
2104
  }
@@ -2244,7 +2233,7 @@ var require_sonic_boom = __commonJS({
2244
2233
  var fs2 = __require("fs");
2245
2234
  var EventEmitter2 = __require("events");
2246
2235
  var inherits = __require("util").inherits;
2247
- var path3 = __require("path");
2236
+ var path2 = __require("path");
2248
2237
  var sleep = require_atomic_sleep();
2249
2238
  var assert2 = __require("assert");
2250
2239
  var BUSY_WRITE_TIMEOUT = 100;
@@ -2298,7 +2287,7 @@ var require_sonic_boom = __commonJS({
2298
2287
  const mode2 = sonic.mode;
2299
2288
  if (sonic.sync) {
2300
2289
  try {
2301
- if (sonic.mkdir) fs2.mkdirSync(path3.dirname(file), { recursive: true });
2290
+ if (sonic.mkdir) fs2.mkdirSync(path2.dirname(file), { recursive: true });
2302
2291
  const fd = fs2.openSync(file, flags, mode2);
2303
2292
  fileOpened(null, fd);
2304
2293
  } catch (err) {
@@ -2306,7 +2295,7 @@ var require_sonic_boom = __commonJS({
2306
2295
  throw err;
2307
2296
  }
2308
2297
  } else if (sonic.mkdir) {
2309
- fs2.mkdir(path3.dirname(file), { recursive: true }, (err) => {
2298
+ fs2.mkdir(path2.dirname(file), { recursive: true }, (err) => {
2310
2299
  if (err) return fileOpened(err);
2311
2300
  fs2.open(file, flags, mode2, fileOpened);
2312
2301
  });
@@ -2862,8 +2851,8 @@ var require_on_exit_leak_free = __commonJS({
2862
2851
  }
2863
2852
  function clear(ref) {
2864
2853
  for (const event of ["exit", "beforeExit"]) {
2865
- const index2 = refs[event].indexOf(ref);
2866
- refs[event].splice(index2, index2 + 1);
2854
+ const index = refs[event].indexOf(ref);
2855
+ refs[event].splice(index, index + 1);
2867
2856
  uninstall(event);
2868
2857
  }
2869
2858
  }
@@ -2972,9 +2961,9 @@ var require_package = __commonJS({
2972
2961
  var require_wait = __commonJS({
2973
2962
  "../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/wait.js"(exports, module2) {
2974
2963
  var MAX_TIMEOUT = 1e3;
2975
- function wait2(state, index2, expected, timeout, done) {
2964
+ function wait2(state, index, expected, timeout, done) {
2976
2965
  const max = Date.now() + timeout;
2977
- let current = Atomics.load(state, index2);
2966
+ let current = Atomics.load(state, index);
2978
2967
  if (current === expected) {
2979
2968
  done(null, "ok");
2980
2969
  return;
@@ -2986,7 +2975,7 @@ var require_wait = __commonJS({
2986
2975
  } else {
2987
2976
  setTimeout(() => {
2988
2977
  prior = current;
2989
- current = Atomics.load(state, index2);
2978
+ current = Atomics.load(state, index);
2990
2979
  if (current === prior) {
2991
2980
  check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : backoff * 2);
2992
2981
  } else {
@@ -2998,9 +2987,9 @@ var require_wait = __commonJS({
2998
2987
  };
2999
2988
  check(1);
3000
2989
  }
3001
- function waitDiff(state, index2, expected, timeout, done) {
2990
+ function waitDiff(state, index, expected, timeout, done) {
3002
2991
  const max = Date.now() + timeout;
3003
- let current = Atomics.load(state, index2);
2992
+ let current = Atomics.load(state, index);
3004
2993
  if (current !== expected) {
3005
2994
  done(null, "ok");
3006
2995
  return;
@@ -3010,7 +2999,7 @@ var require_wait = __commonJS({
3010
2999
  done(null, "timed-out");
3011
3000
  } else {
3012
3001
  setTimeout(() => {
3013
- current = Atomics.load(state, index2);
3002
+ current = Atomics.load(state, index);
3014
3003
  if (current !== expected) {
3015
3004
  done(null, "ok");
3016
3005
  } else {
@@ -4491,7 +4480,7 @@ var require_safe_stable_stringify = __commonJS({
4491
4480
  }
4492
4481
  }
4493
4482
  const circularValue = getCircularValueOption(options);
4494
- const bigint2 = getBooleanOption(options, "bigint");
4483
+ const bigint = getBooleanOption(options, "bigint");
4495
4484
  const deterministic = getDeterministicOption(options);
4496
4485
  const comparator = typeof deterministic === "function" ? deterministic : void 0;
4497
4486
  const maximumDepth = getPositiveIntegerOption(options, "maximumDepth");
@@ -4599,7 +4588,7 @@ ${originalIndentation}`;
4599
4588
  case "undefined":
4600
4589
  return void 0;
4601
4590
  case "bigint":
4602
- if (bigint2) {
4591
+ if (bigint) {
4603
4592
  return String(value);
4604
4593
  }
4605
4594
  // fallthrough
@@ -4690,7 +4679,7 @@ ${originalIndentation}`;
4690
4679
  case "undefined":
4691
4680
  return void 0;
4692
4681
  case "bigint":
4693
- if (bigint2) {
4682
+ if (bigint) {
4694
4683
  return String(value);
4695
4684
  }
4696
4685
  // fallthrough
@@ -4802,7 +4791,7 @@ ${originalIndentation}`;
4802
4791
  case "undefined":
4803
4792
  return void 0;
4804
4793
  case "bigint":
4805
- if (bigint2) {
4794
+ if (bigint) {
4806
4795
  return String(value);
4807
4796
  }
4808
4797
  // fallthrough
@@ -4898,7 +4887,7 @@ ${originalIndentation}`;
4898
4887
  case "undefined":
4899
4888
  return void 0;
4900
4889
  case "bigint":
4901
- if (bigint2) {
4890
+ if (bigint) {
4902
4891
  return String(value);
4903
4892
  }
4904
4893
  // fallthrough
@@ -5182,7 +5171,7 @@ var require_pino = __commonJS({
5182
5171
  redact,
5183
5172
  crlf,
5184
5173
  serializers: serializers2,
5185
- timestamp: timestamp2,
5174
+ timestamp,
5186
5175
  messageKey,
5187
5176
  errorKey,
5188
5177
  nestedKey,
@@ -5232,7 +5221,7 @@ var require_pino = __commonJS({
5232
5221
  chindings = coreChindings(Object.assign({}, base2, { name }));
5233
5222
  }
5234
5223
  }
5235
- const time2 = timestamp2 instanceof Function ? timestamp2 : timestamp2 ? epochTime : nullTime;
5224
+ const time2 = timestamp instanceof Function ? timestamp : timestamp ? epochTime : nullTime;
5236
5225
  const timeSliceIndex = time2().indexOf(":") + 1;
5237
5226
  if (useOnlyCustomLevels && !customLevels) throw Error("customLevels is required if useOnlyCustomLevels is set true");
5238
5227
  if (mixin && typeof mixin !== "function") throw Error(`Unknown mixin type "${typeof mixin}" - expected "function"`);
@@ -7542,9 +7531,9 @@ var require_stream_readable = __commonJS({
7542
7531
  });
7543
7532
  return this;
7544
7533
  }
7545
- var index2 = indexOf(state.pipes, dest);
7546
- if (index2 === -1) return this;
7547
- state.pipes.splice(index2, 1);
7534
+ var index = indexOf(state.pipes, dest);
7535
+ if (index === -1) return this;
7536
+ state.pipes.splice(index, 1);
7548
7537
  state.pipesCount -= 1;
7549
7538
  if (state.pipesCount === 1) state.pipes = state.pipes[0];
7550
7539
  dest.emit("unpipe", this, unpipeInfo);
@@ -8127,32 +8116,6 @@ var require_qheap2 = __commonJS({
8127
8116
  }
8128
8117
  });
8129
8118
 
8130
- // src/index.node.ts
8131
- var index_node_exports = {};
8132
- __export(index_node_exports, {
8133
- ApiSchema: () => apiSchema_exports,
8134
- Chain: () => Chain_exports,
8135
- EVM: () => EVM_exports,
8136
- Logger: () => Logger_exports,
8137
- OfferDB: () => OfferDB_exports,
8138
- OfferRepository: () => OfferRepository_exports,
8139
- Router: () => core_exports,
8140
- RouterEvent: () => RouterEvent_exports,
8141
- RouterOffer: () => RouterOffer_exports,
8142
- Validation: () => Validation_exports,
8143
- ValidationRule: () => ValidationRule_exports,
8144
- batch: () => batch,
8145
- consumed: () => consumed,
8146
- decodeCursor: () => decodeCursor,
8147
- encodeCursor: () => encodeCursor,
8148
- offerCollaterals: () => offerCollaterals,
8149
- offerStatus: () => offerStatus,
8150
- offers: () => offers,
8151
- poll: () => poll,
8152
- validateCursor: () => validateCursor,
8153
- wait: () => wait
8154
- });
8155
-
8156
8119
  // src/Chain.ts
8157
8120
  var Chain_exports = {};
8158
8121
  __export(Chain_exports, {
@@ -8275,6 +8238,18 @@ var InvalidRouterOfferError = class extends mempool.Errors.BaseError {
8275
8238
  }
8276
8239
  };
8277
8240
 
8241
+ // src/utils/index.ts
8242
+ var utils_exports = {};
8243
+ __export(utils_exports, {
8244
+ batch: () => batch,
8245
+ decodeCursor: () => decodeCursor,
8246
+ encodeCursor: () => encodeCursor,
8247
+ poll: () => poll,
8248
+ retry: () => retry,
8249
+ validateCursor: () => validateCursor,
8250
+ wait: () => wait
8251
+ });
8252
+
8278
8253
  // src/utils/batch.ts
8279
8254
  function* batch(array, batchSize) {
8280
8255
  for (let i = 0; i < array.length; i += batchSize) {
@@ -8385,6 +8360,20 @@ function poll(fn, { interval }) {
8385
8360
  return unwatch;
8386
8361
  }
8387
8362
 
8363
+ // src/utils/retry.ts
8364
+ var retry = async (fn, attempts = 3, delayMs = 50) => {
8365
+ let lastErr;
8366
+ for (let i = 0; i < attempts; i++) {
8367
+ try {
8368
+ return await fn();
8369
+ } catch (err) {
8370
+ lastErr = err;
8371
+ if (i < attempts - 1) await new Promise((r) => setTimeout(r, delayMs));
8372
+ }
8373
+ }
8374
+ throw lastErr;
8375
+ };
8376
+
8388
8377
  // src/core/apiSchema/requests.ts
8389
8378
  var MAX_LIMIT = 100;
8390
8379
  var DEFAULT_LIMIT = 20;
@@ -8455,19 +8444,33 @@ var GetOffersQueryParams = v4.z.object({
8455
8444
  example: "1500000000000000000"
8456
8445
  }),
8457
8446
  // Time range
8458
- min_maturity: v4.z.bigint({ coerce: true }).min(0n).optional().transform((val) => val === void 0 ? void 0 : Number(val)).meta({
8459
- description: "Minimum maturity timestamp (Unix timestamp in seconds)",
8460
- example: "1700000000"
8461
- }),
8462
- max_maturity: v4.z.bigint({ coerce: true }).min(0n).optional().transform((val) => val === void 0 ? void 0 : Number(val)).meta({
8463
- description: "Maximum maturity timestamp (Unix timestamp in seconds)",
8464
- example: "1800000000"
8465
- }),
8466
- min_expiry: v4.z.bigint({ coerce: true }).min(0n).optional().transform((val) => val === void 0 ? void 0 : Number(val)).meta({
8447
+ min_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
8448
+ try {
8449
+ return mempool.Maturity.from(maturity);
8450
+ } catch (e) {
8451
+ ctx.addIssue({
8452
+ code: "custom",
8453
+ message: e.message
8454
+ });
8455
+ return v4.z.NEVER;
8456
+ }
8457
+ }).optional(),
8458
+ max_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
8459
+ try {
8460
+ return mempool.Maturity.from(maturity);
8461
+ } catch (e) {
8462
+ ctx.addIssue({
8463
+ code: "custom",
8464
+ message: e.message
8465
+ });
8466
+ return v4.z.NEVER;
8467
+ }
8468
+ }).optional(),
8469
+ min_expiry: v4.z.coerce.number().int().optional().meta({
8467
8470
  description: "Minimum expiry timestamp (Unix timestamp in seconds)",
8468
8471
  example: "1700000000"
8469
8472
  }),
8470
- max_expiry: v4.z.bigint({ coerce: true }).min(0n).optional().transform((val) => val === void 0 ? void 0 : Number(val)).meta({
8473
+ max_expiry: v4.z.coerce.number().int().optional().meta({
8471
8474
  description: "Maximum expiry timestamp (Unix timestamp in seconds)",
8472
8475
  example: "1800000000"
8473
8476
  }),
@@ -8489,51 +8492,81 @@ var GetOffersQueryParams = v4.z.object({
8489
8492
  {
8490
8493
  message: "Collateral tuple must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. Oracle and lltv are optional. Asset must be 0x + 40 hex chars, oracle must be 0x + 40 hex chars, lltv must be a number (e.g., 80.5)."
8491
8494
  }
8492
- ).transform((val) => {
8495
+ ).transform((val, ctx) => {
8493
8496
  return val.split("#").map((tuple) => {
8494
8497
  const parts = tuple.split(":");
8495
8498
  if (parts.length === 0 || !parts[0]) {
8496
- throw new v4.z.ZodError([
8497
- {
8498
- code: "custom",
8499
- message: "Asset address is required for each collateral tuple",
8500
- path: ["collateral_tuple"],
8501
- input: val
8502
- }
8503
- ]);
8499
+ ctx.addIssue({
8500
+ code: "custom",
8501
+ message: "Asset address is required for each collateral tuple",
8502
+ path: ["asset"],
8503
+ input: val
8504
+ });
8505
+ return v4.z.NEVER;
8504
8506
  }
8505
8507
  const asset = parts[0]?.toLowerCase();
8506
8508
  const oracle = parts[1]?.toLowerCase();
8507
8509
  const lltv = parts[2] ? parseFloat(parts[2]) : void 0;
8508
8510
  if (lltv !== void 0 && (lltv < MIN_LLTV || lltv > MAX_LLTV)) {
8509
- throw new v4.z.ZodError([
8510
- {
8511
+ ctx.addIssue({
8512
+ code: "custom",
8513
+ message: `LLTV must be between ${MIN_LLTV} and ${MAX_LLTV} (0-100%)`,
8514
+ path: ["lltv"],
8515
+ input: val
8516
+ });
8517
+ return v4.z.NEVER;
8518
+ }
8519
+ let lltvValue;
8520
+ if (lltv !== void 0) {
8521
+ try {
8522
+ lltvValue = mempool.LLTV.from(viem.parseUnits(lltv.toString(), 16));
8523
+ } catch (e) {
8524
+ ctx.issues.push({
8511
8525
  code: "custom",
8512
- message: `LLTV must be between ${MIN_LLTV} and ${MAX_LLTV} (0-100%)`,
8513
- path: ["collateral_tuple"],
8514
- input: val
8515
- }
8516
- ]);
8526
+ message: e instanceof mempool.LLTV.InvalidLLTVError || e instanceof mempool.LLTV.InvalidOptionError ? e.message : "Invalid LLTV.",
8527
+ input: lltv,
8528
+ path: ["lltv"]
8529
+ });
8530
+ return v4.z.NEVER;
8531
+ }
8517
8532
  }
8518
8533
  return {
8519
8534
  asset,
8520
8535
  oracle,
8521
- lltv
8536
+ lltv: lltvValue
8522
8537
  };
8523
8538
  });
8524
8539
  }).optional().meta({
8525
8540
  description: "Filter by collateral combinations in format: asset:oracle:lltv#asset2:oracle2:lltv2. Oracle and lltv are optional. Use # to separate multiple combinations.",
8526
- example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:8000#0x9876543210987654321098765432109876543210::8000"
8541
+ example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:86#0x9876543210987654321098765432109876543210:94.5"
8527
8542
  }),
8528
- min_lltv: v4.z.string().regex(/^\d+(\.\d+)?$/, {
8529
- message: "Min LLTV must be a valid number"
8530
- }).transform((val) => parseFloat(val)).pipe(v4.z.number().min(0).max(100)).optional().meta({
8543
+ min_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).transform((lltv, ctx) => {
8544
+ try {
8545
+ return mempool.LLTV.from(viem.parseUnits(lltv.toString(), 16));
8546
+ } catch (e) {
8547
+ ctx.addIssue({
8548
+ code: "custom",
8549
+ message: e.message,
8550
+ input: lltv
8551
+ });
8552
+ return v4.z.NEVER;
8553
+ }
8554
+ }).optional().meta({
8531
8555
  description: "Minimum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal, e.g., 80.5 = 80.5%)",
8532
8556
  example: "80.5"
8533
8557
  }),
8534
- max_lltv: v4.z.string().regex(/^\d+(\.\d+)?$/, {
8535
- message: "Max LLTV must be a valid number"
8536
- }).transform((val) => parseFloat(val)).pipe(v4.z.number().min(0).max(100)).optional().meta({
8558
+ max_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).transform((lltv, ctx) => {
8559
+ try {
8560
+ return mempool.LLTV.from(viem.parseUnits(lltv.toString(), 16));
8561
+ } catch (e) {
8562
+ ctx.addIssue({
8563
+ code: "custom",
8564
+ message: e.message,
8565
+ input: lltv
8566
+ });
8567
+ return v4.z.NEVER;
8568
+ }
8569
+ }).optional().meta({
8537
8570
  description: "Maximum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal, e.g., 95.5 = 95.5%)",
8538
8571
  example: "95.5"
8539
8572
  }),
@@ -8626,68 +8659,89 @@ var MatchOffersQueryParams = v4.z.object({
8626
8659
  }),
8627
8660
  // Collateral filtering
8628
8661
  collaterals: v4.z.string().regex(
8629
- /^(0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:\d+)(#0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:\d+)*$/,
8662
+ /^(0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)(#0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)*$/,
8630
8663
  {
8631
8664
  message: "Collaterals must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. All fields are required for each collateral."
8632
8665
  }
8633
- ).transform((val) => {
8666
+ ).transform((val, ctx) => {
8634
8667
  return val.split("#").map((collateral) => {
8635
8668
  const parts = collateral.split(":");
8636
8669
  if (parts.length !== 3) {
8637
- throw new v4.z.ZodError([
8638
- {
8639
- code: "custom",
8640
- message: "Each collateral must have exactly 3 parts: asset:oracle:lltv",
8641
- path: ["collaterals"],
8642
- input: val
8643
- }
8644
- ]);
8670
+ ctx.addIssue({
8671
+ code: "custom",
8672
+ message: "Each collateral must have exactly 3 parts: asset:oracle:lltv",
8673
+ path: ["collaterals"],
8674
+ input: val
8675
+ });
8676
+ return v4.z.NEVER;
8645
8677
  }
8646
8678
  const [asset, oracle, lltvStr] = parts;
8647
8679
  if (!asset || !oracle || !lltvStr) {
8648
- throw new v4.z.ZodError([
8649
- {
8650
- code: "custom",
8651
- message: "Asset, oracle, and lltv are all required for each collateral",
8652
- path: ["collaterals"],
8653
- input: val
8654
- }
8655
- ]);
8680
+ ctx.addIssue({
8681
+ code: "custom",
8682
+ message: "Asset, oracle, and lltv are all required for each collateral",
8683
+ path: ["collaterals"],
8684
+ input: val
8685
+ });
8656
8686
  }
8657
- const lltv = BigInt(lltvStr);
8658
- if (lltv <= 0n) {
8659
- throw new v4.z.ZodError([
8660
- {
8687
+ let lltvValue;
8688
+ if (lltvStr !== void 0) {
8689
+ try {
8690
+ lltvValue = mempool.LLTV.from(viem.parseUnits(lltvStr, 16));
8691
+ } catch (e) {
8692
+ ctx.issues.push({
8661
8693
  code: "custom",
8662
- message: "LLTV must be a positive number",
8663
- path: ["collaterals"],
8664
- input: val
8665
- }
8666
- ]);
8694
+ message: e instanceof mempool.LLTV.InvalidLLTVError || e instanceof mempool.LLTV.InvalidOptionError ? e.message : "Invalid LLTV.",
8695
+ input: lltvStr,
8696
+ path: ["lltv"]
8697
+ });
8698
+ return v4.z.NEVER;
8699
+ }
8667
8700
  }
8668
8701
  return {
8669
8702
  asset: asset.toLowerCase(),
8670
8703
  oracle: oracle.toLowerCase(),
8671
- lltv
8704
+ lltv: lltvValue
8672
8705
  };
8673
8706
  });
8674
8707
  }).optional().meta({
8675
8708
  description: "Collateral requirements in format: asset:oracle:lltv#asset2:oracle2:lltv2. Use # to separate multiple collaterals.",
8676
- example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:800000000000000000#0x9876543210987654321098765432109876543210:0xfedcbafedcbafedcbafedcbafedcbafedcbafedc:900000000000000000"
8709
+ example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:86#0x9876543210987654321098765432109876543210:0xfedcbafedcbafedcbafedcbafedcbafedcbafedc:94.5"
8677
8710
  }),
8678
8711
  // Maturity filtering
8679
- maturity: v4.z.bigint({ coerce: true }).min(0n).optional().transform((val) => val === void 0 ? void 0 : Number(val)).meta({
8680
- description: "Exact maturity timestamp (Unix timestamp in seconds)",
8681
- example: "1700000000"
8682
- }),
8683
- min_maturity: v4.z.bigint({ coerce: true }).min(0n).optional().transform((val) => val === void 0 ? void 0 : Number(val)).meta({
8684
- description: "Minimum maturity timestamp (Unix timestamp in seconds, inclusive)",
8685
- example: "1700000000"
8686
- }),
8687
- max_maturity: v4.z.bigint({ coerce: true }).min(0n).optional().transform((val) => val === void 0 ? void 0 : Number(val)).meta({
8688
- description: "Maximum maturity timestamp (Unix timestamp in seconds, inclusive)",
8689
- example: "1800000000"
8690
- }),
8712
+ maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
8713
+ try {
8714
+ return mempool.Maturity.from(maturity);
8715
+ } catch (e) {
8716
+ ctx.addIssue({
8717
+ code: "custom",
8718
+ message: e.message
8719
+ });
8720
+ return v4.z.NEVER;
8721
+ }
8722
+ }).optional(),
8723
+ min_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
8724
+ try {
8725
+ return mempool.Maturity.from(maturity);
8726
+ } catch (e) {
8727
+ ctx.addIssue({
8728
+ code: "custom",
8729
+ message: e.message
8730
+ });
8731
+ return v4.z.NEVER;
8732
+ }
8733
+ }).optional(),
8734
+ max_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
8735
+ try {
8736
+ return mempool.Maturity.from(maturity);
8737
+ } catch (e) {
8738
+ ctx.addIssue({
8739
+ code: "custom",
8740
+ message: e.message
8741
+ });
8742
+ return v4.z.NEVER;
8743
+ }
8744
+ }).optional(),
8691
8745
  // Asset and creator filtering
8692
8746
  loan_token: v4.z.string().regex(/^0x[a-fA-F0-9]{40}$/, {
8693
8747
  message: "Loan asset must be a valid Ethereum address"
@@ -8752,8 +8806,10 @@ var schemas = {
8752
8806
  function parse(action, query) {
8753
8807
  return schemas[action].parse(query);
8754
8808
  }
8755
- function safeParse(action, query) {
8756
- return schemas[action].safeParse(query);
8809
+ function safeParse(action, query, error) {
8810
+ return schemas[action].safeParse(query, {
8811
+ error
8812
+ });
8757
8813
  }
8758
8814
 
8759
8815
  // src/core/apiSchema/openapi.ts
@@ -8805,7 +8861,7 @@ var paths = {
8805
8861
  }
8806
8862
  }
8807
8863
  },
8808
- "/v1/match-offers": {
8864
+ "/v1/offers/match": {
8809
8865
  get: {
8810
8866
  summary: "Match offers",
8811
8867
  description: "Find offers that match specific criteria",
@@ -8861,27 +8917,27 @@ var OpenApi = zodOpenapi.createDocument({
8861
8917
 
8862
8918
  // src/core/apiSchema/utils.ts
8863
8919
  function toResponse(routerOffer) {
8864
- const { consumed: consumed2, status, metadata, ...offer } = routerOffer;
8920
+ const { consumed, status, metadata, ...offer } = routerOffer;
8865
8921
  return {
8866
8922
  offer,
8867
- consumed: consumed2,
8923
+ consumed,
8868
8924
  status,
8869
8925
  metadata
8870
8926
  };
8871
8927
  }
8872
8928
  function fromResponse(offerResponse) {
8873
- const { offer, consumed: consumed2, status, metadata } = offerResponse;
8929
+ const { offer, consumed, status, metadata } = offerResponse;
8874
8930
  return {
8875
8931
  ...offer,
8876
- consumed: consumed2,
8932
+ consumed,
8877
8933
  status,
8878
8934
  metadata
8879
8935
  };
8880
8936
  }
8881
8937
 
8882
- // src/core/index.ts
8883
- var core_exports = {};
8884
- __export(core_exports, {
8938
+ // src/core/router/index.ts
8939
+ var router_exports = {};
8940
+ __export(router_exports, {
8885
8941
  HttpForbiddenError: () => HttpForbiddenError,
8886
8942
  HttpGetOffersFailedError: () => HttpGetOffersFailedError,
8887
8943
  HttpRateLimitError: () => HttpRateLimitError,
@@ -8968,16 +9024,16 @@ async function get(config, parameters) {
8968
9024
  } else if (lltv !== void 0) {
8969
9025
  result += `:`;
8970
9026
  }
8971
- if (lltv !== void 0) result += `:${lltv}`;
9027
+ if (lltv !== void 0) result += `:${viem.formatUnits(lltv, 16)}`;
8972
9028
  return result;
8973
9029
  }).join("#");
8974
9030
  url.searchParams.set("collateral_tuple", tupleStr);
8975
9031
  }
8976
9032
  if (parameters.minLltv !== void 0) {
8977
- url.searchParams.set("min_lltv", parameters.minLltv.toString());
9033
+ url.searchParams.set("min_lltv", viem.formatUnits(parameters.minLltv, 16));
8978
9034
  }
8979
9035
  if (parameters.maxLltv !== void 0) {
8980
- url.searchParams.set("max_lltv", parameters.maxLltv.toString());
9036
+ url.searchParams.set("max_lltv", viem.formatUnits(parameters.maxLltv, 16));
8981
9037
  }
8982
9038
  if (parameters.sortBy) {
8983
9039
  url.searchParams.set("sort_by", parameters.sortBy);
@@ -8991,22 +9047,22 @@ async function get(config, parameters) {
8991
9047
  if (parameters.limit !== void 0) {
8992
9048
  url.searchParams.set("limit", parameters.limit.toString());
8993
9049
  }
8994
- const { cursor: returnedCursor, data: offers2 } = await getApi(config, url);
8995
- const routerOffers = offers2.map(mempool.Format.fromSnakeCase).map(fromResponse);
9050
+ const { cursor: returnedCursor, data: offers } = await getApi(config, url);
9051
+ const routerOffers = offers.map(mempool.Format.fromSnakeCase).map(fromResponse);
8996
9052
  return {
8997
9053
  cursor: returnedCursor,
8998
9054
  offers: routerOffers.map(from).map(toResponse)
8999
9055
  };
9000
9056
  }
9001
9057
  async function match(config, parameters) {
9002
- const url = new URL(`${config.url.toString()}v1/match-offers`);
9058
+ const url = new URL(`${config.url.toString()}v1/offers/match`);
9003
9059
  url.searchParams.set("side", parameters.side);
9004
9060
  url.searchParams.set("chain_id", parameters.chainId.toString());
9005
9061
  if (parameters.rate !== void 0) {
9006
9062
  url.searchParams.set("rate", parameters.rate.toString());
9007
9063
  }
9008
9064
  if (parameters.collaterals?.length) {
9009
- const collateralsStr = parameters.collaterals.map(({ asset, oracle, lltv }) => `${asset}:${oracle}:${lltv}`).join("#");
9065
+ const collateralsStr = parameters.collaterals.map(({ asset, oracle, lltv }) => `${asset}:${oracle}:${viem.formatUnits(lltv, 16)}`).join("#");
9010
9066
  url.searchParams.set("collaterals", collateralsStr);
9011
9067
  }
9012
9068
  if (parameters.maturity !== void 0) {
@@ -9033,8 +9089,8 @@ async function match(config, parameters) {
9033
9089
  if (parameters.limit !== void 0) {
9034
9090
  url.searchParams.set("limit", parameters.limit.toString());
9035
9091
  }
9036
- const { cursor: returnedCursor, data: offers2 } = await getApi(config, url);
9037
- const routerOffers = offers2.map(mempool.Format.fromSnakeCase).map(fromResponse);
9092
+ const { cursor: returnedCursor, data: offers } = await getApi(config, url);
9093
+ const routerOffers = offers.map(mempool.Format.fromSnakeCase).map(fromResponse);
9038
9094
  return {
9039
9095
  cursor: returnedCursor,
9040
9096
  offers: routerOffers.map(from).map(toResponse)
@@ -9047,7 +9103,7 @@ async function getApi(config, url) {
9047
9103
  case pathname.includes("/v1/offers"):
9048
9104
  action = "get_offers";
9049
9105
  break;
9050
- case pathname.includes("/v1/match-offers"):
9106
+ case pathname.includes("/v1/offers/match"):
9051
9107
  action = "match_offers";
9052
9108
  break;
9053
9109
  default:
@@ -9121,558 +9177,214 @@ var HttpGetOffersFailedError = class extends mempool.Errors.BaseError {
9121
9177
  }
9122
9178
  };
9123
9179
 
9124
- // src/OfferDB/index.ts
9125
- var OfferDB_exports2 = {};
9126
- __export(OfferDB_exports2, {
9127
- OfferDB: () => OfferDB_exports,
9128
- OfferRepository: () => OfferRepository_exports,
9129
- consumed: () => consumed,
9130
- offerCollaterals: () => offerCollaterals,
9131
- offerStatus: () => offerStatus,
9132
- offers: () => offers
9133
- });
9134
- __reExport(OfferDB_exports2, drizzle_orm_star__namespace);
9135
-
9136
- // src/OfferDB/OfferDB.ts
9137
- var OfferDB_exports = {};
9138
- __export(OfferDB_exports, {
9139
- applyMigrations: () => applyMigrations,
9140
- applyMigrationsPostgres: () => applyMigrationsPostgres,
9141
- clean: () => clean,
9142
- create: () => create
9143
- });
9144
-
9145
- // src/OfferDB/schema.ts
9146
- var schema_exports = {};
9147
- __export(schema_exports, {
9148
- consumed: () => consumed,
9149
- offerCollaterals: () => offerCollaterals,
9150
- offerStatus: () => offerStatus,
9151
- offers: () => offers
9180
+ // src/OfferStore/index.ts
9181
+ var OfferStore_exports = {};
9182
+ __export(OfferStore_exports, {
9183
+ memory: () => memory
9152
9184
  });
9153
- var offers = pgCore.pgTable(
9154
- "offers",
9155
- {
9156
- hash: pgCore.varchar("hash", { length: 66 }).primaryKey(),
9157
- offering: pgCore.varchar("offering", { length: 42 }).notNull(),
9158
- assets: pgCore.bigint("assets", { mode: "bigint" }).notNull(),
9159
- rate: pgCore.bigint("rate", { mode: "bigint" }).notNull(),
9160
- maturity: pgCore.integer("maturity").notNull(),
9161
- expiry: pgCore.integer("expiry").notNull(),
9162
- start: pgCore.integer("start").notNull(),
9163
- nonce: pgCore.bigint("nonce", { mode: "bigint" }).notNull(),
9164
- buy: pgCore.boolean("buy").notNull(),
9165
- chainId: pgCore.bigint("chain_id", { mode: "bigint" }).notNull(),
9166
- loanToken: pgCore.varchar("loan_token", { length: 42 }).notNull(),
9167
- callbackAddress: pgCore.varchar("callback_address", { length: 42 }).notNull(),
9168
- callbackData: pgCore.text("callback_data").notNull(),
9169
- callbackGasLimit: pgCore.bigint("callback_gas_limit", { mode: "bigint" }).notNull(),
9170
- signature: pgCore.varchar("signature", { length: 132 }),
9171
- createdAt: pgCore.timestamp("created_at").defaultNow().notNull()
9172
- },
9173
- (table) => [
9174
- pgCore.index("offers_offering_idx").on(table.offering),
9175
- pgCore.index("offers_buy_idx").on(table.buy),
9176
- pgCore.index("offers_chain_id_idx").on(table.chainId),
9177
- pgCore.index("offers_loan_token_idx").on(table.loanToken),
9178
- pgCore.index("offers_maturity_idx").on(table.maturity),
9179
- pgCore.index("offers_expiry_idx").on(table.expiry),
9180
- pgCore.index("offers_rate_idx").on(table.rate),
9181
- pgCore.index("offers_assets_idx").on(table.assets),
9182
- // Compound indices for cursor pagination with hash
9183
- pgCore.index("offers_rate_hash_idx").on(table.rate, table.hash),
9184
- pgCore.index("offers_maturity_hash_idx").on(table.maturity, table.hash),
9185
- pgCore.index("offers_expiry_hash_idx").on(table.expiry, table.hash),
9186
- pgCore.index("offers_assets_hash_idx").on(table.assets, table.hash)
9187
- ]
9188
- );
9189
- var offerCollaterals = pgCore.pgTable(
9190
- "offer_collaterals",
9191
- {
9192
- id: pgCore.serial("id").primaryKey(),
9193
- offerHash: pgCore.varchar("offer_hash", { length: 66 }).notNull().references(() => offers.hash, { onDelete: "cascade" }),
9194
- asset: pgCore.varchar("asset", { length: 42 }).notNull(),
9195
- oracle: pgCore.varchar("oracle", { length: 42 }).notNull(),
9196
- lltv: pgCore.bigint("lltv", { mode: "bigint" }).notNull()
9197
- },
9198
- (table) => [
9199
- pgCore.index("offer_collaterals_offer_hash_idx").on(table.offerHash),
9200
- pgCore.index("offer_collaterals_asset_idx").on(table.asset),
9201
- pgCore.index("offer_collaterals_oracle_idx").on(table.oracle),
9202
- // Composite index
9203
- pgCore.index("offer_collaterals_tuple_idx").on(table.asset, table.oracle, table.lltv)
9204
- ]
9205
- );
9206
- var offerStatus = pgCore.pgTable(
9207
- "offer_status",
9208
- {
9209
- id: pgCore.serial("id").primaryKey(),
9210
- offerHash: pgCore.varchar("offer_hash", { length: 66 }).notNull().references(() => offers.hash, { onDelete: "cascade" }),
9211
- status: pgCore.text("status").$type().notNull(),
9212
- metadata: pgCore.jsonb("metadata"),
9213
- createdAt: pgCore.timestamp("created_at").defaultNow().notNull()
9214
- },
9215
- (table) => [
9216
- pgCore.index("offer_status_offer_hash_created_at_idx").on(table.offerHash, drizzle_orm_star.desc(table.createdAt)),
9217
- pgCore.index("offer_status_status_idx").on(table.status)
9218
- ]
9219
- );
9220
- var consumed = pgCore.pgTable(
9221
- "consumed_per_user_and_nonce",
9222
- {
9223
- id: pgCore.serial("id").primaryKey(),
9224
- chainId: pgCore.bigint("chain_id", { mode: "bigint" }).notNull(),
9225
- offering: pgCore.varchar("offering", { length: 42 }).notNull(),
9226
- nonce: pgCore.bigint("nonce", { mode: "bigint" }).notNull(),
9227
- consumed: pgCore.bigint("consumed", { mode: "bigint" }).notNull(),
9228
- createdAt: pgCore.timestamp("created_at").defaultNow().notNull()
9229
- },
9230
- (table) => [
9231
- pgCore.index("consumed_per_user_and_nonce_chain_id_offering_nonce_created_at_idx").on(
9232
- table.chainId,
9233
- table.offering,
9234
- table.nonce,
9235
- drizzle_orm_star.desc(table.createdAt)
9236
- )
9237
- ]
9238
- );
9239
-
9240
- // src/OfferDB/OfferDB.ts
9241
- function create({
9242
- type = "pg",
9243
- endpoint
9244
- }) {
9245
- if (type === "pg") {
9246
- if (!endpoint) {
9247
- throw new Error("endpoint is required with pg database");
9185
+ function memory(parameters) {
9186
+ const map = parameters.offers;
9187
+ const filled = parameters.filled;
9188
+ const create = async (parameters2) => {
9189
+ if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
9190
+ map.set(parameters2.offer.hash.toLowerCase(), {
9191
+ ...parameters2.offer,
9192
+ status: parameters2.status,
9193
+ metadata: parameters2.metadata
9194
+ });
9195
+ const chainId = parameters2.offer.chainId;
9196
+ const address = parameters2.offer.offering.toLowerCase();
9197
+ const nonce = parameters2.offer.nonce;
9198
+ const filledForChain = filled.get(chainId) || /* @__PURE__ */ new Map();
9199
+ const filledForOffering = filledForChain.get(address) || /* @__PURE__ */ new Map();
9200
+ if (!filledForOffering.has(nonce)) filledForOffering.set(nonce, 0n);
9201
+ filledForChain.set(address, filledForOffering);
9202
+ filled.set(chainId, filledForChain);
9203
+ return Promise.resolve(parameters2.offer.hash);
9204
+ };
9205
+ const sort = (sortBy, sortOrder, a, b) => {
9206
+ sortBy = sortBy || "expiry";
9207
+ sortOrder = sortOrder || "desc";
9208
+ const sortKey = sortBy === "amount" ? "assets" : sortBy;
9209
+ if (a[sortKey] === b[sortKey]) {
9210
+ if (a.hash === b.hash) return 0;
9211
+ return sortOrder === "asc" ? a.hash > b.hash ? 1 : -1 : b.hash > a.hash ? 1 : -1;
9212
+ }
9213
+ switch (sortBy) {
9214
+ case "rate":
9215
+ if (a.rate === b.rate) {
9216
+ if (a.hash === b.hash) return 0;
9217
+ return sortOrder === "asc" ? a.hash > b.hash ? 1 : -1 : a.hash > b.hash ? -1 : 1;
9218
+ }
9219
+ return sortOrder === "asc" ? a.rate > b.rate ? 1 : -1 : b.rate > a.rate ? 1 : -1;
9220
+ case "maturity":
9221
+ if (a.maturity === b.maturity) {
9222
+ if (a.hash === b.hash) return 0;
9223
+ return sortOrder === "asc" ? a.hash > b.hash ? 1 : -1 : a.hash > b.hash ? -1 : 1;
9224
+ }
9225
+ return sortOrder === "asc" ? a.maturity > b.maturity ? 1 : -1 : b.maturity > a.maturity ? 1 : -1;
9226
+ case "expiry":
9227
+ if (a.expiry === b.expiry) {
9228
+ if (a.hash === b.hash) return 0;
9229
+ return sortOrder === "asc" ? a.hash > b.hash ? 1 : -1 : a.hash > b.hash ? -1 : 1;
9230
+ }
9231
+ return sortOrder === "asc" ? a.expiry > b.expiry ? 1 : -1 : b.expiry > a.expiry ? 1 : -1;
9232
+ case "amount":
9233
+ if (a.assets === b.assets) {
9234
+ if (a.hash === b.hash) return 0;
9235
+ return sortOrder === "asc" ? a.hash > b.hash ? 1 : -1 : a.hash > b.hash ? -1 : 1;
9236
+ }
9237
+ return sortOrder === "asc" ? a.assets > b.assets ? 1 : -1 : b.assets > a.assets ? 1 : -1;
9238
+ default:
9239
+ if (a.expiry === b.expiry) {
9240
+ if (a.hash === b.hash) return 0;
9241
+ return sortOrder === "asc" ? a.hash > b.hash ? 1 : -1 : a.hash > b.hash ? -1 : 1;
9242
+ }
9243
+ return sortOrder === "asc" ? a.expiry > b.expiry ? 1 : -1 : b.expiry > a.expiry ? 1 : -1;
9248
9244
  }
9249
- const pool2 = new pg.Pool({ connectionString: endpoint });
9250
- const client2 = nodePostgres.drizzle(pool2, { schema: schema_exports });
9251
- return Object.assign(client2, { name: "pg", pool: pool2 });
9252
- }
9253
- const pool = new pglite.PGlite();
9254
- const client = pglite$1.drizzle(pool, { schema: schema_exports });
9255
- return Object.assign(client, { name: "pglite", pool });
9256
- }
9257
- async function applyMigrations(db) {
9258
- if (db.name !== "pglite") {
9259
- throw new Error("Migrations can only be applied to PGLite database");
9260
- }
9261
- const filePath = path__default.default.join(__dirname, "drizzle");
9262
- await migrator.migrate(db, { migrationsFolder: filePath });
9263
- }
9264
- async function applyMigrationsPostgres(db) {
9265
- const filePath = process.env.AWS_LAMBDA_FUNCTION_NAME ? path__default.default.join(process.cwd(), "drizzle") : path__default.default.join(__dirname, "drizzle");
9266
- if (db.name !== "pg") {
9267
- throw new Error("Migrations can only be applied to PostgreSQL database");
9268
- }
9269
- await migrator$1.migrate(db, { migrationsFolder: filePath });
9270
- }
9271
- async function clean(db) {
9272
- await db.execute(drizzle_orm_star.sql`drop schema if exists public cascade`);
9273
- await db.execute(drizzle_orm_star.sql`create schema public`);
9274
- await db.execute(drizzle_orm_star.sql`drop schema if exists drizzle cascade`);
9275
- }
9276
-
9277
- // src/OfferDB/repositories/offers/OfferRepository.ts
9278
- var OfferRepository_exports = {};
9279
- __export(OfferRepository_exports, {
9280
- create: () => create2,
9281
- createTest: () => createTest
9282
- });
9283
- function create2(config) {
9284
- const db = config.db;
9245
+ };
9285
9246
  return {
9286
- create: async (parameters) => {
9287
- const { offer, status, metadata = {} } = parameters;
9288
- return await db.transaction(async (tx) => {
9289
- const result = await tx.insert(offers).values({
9290
- hash: offer.hash.toLowerCase(),
9291
- offering: offer.offering.toLowerCase(),
9292
- assets: offer.assets,
9293
- rate: offer.rate,
9294
- maturity: offer.maturity,
9295
- expiry: offer.expiry,
9296
- start: offer.start,
9297
- nonce: offer.nonce,
9298
- buy: offer.buy,
9299
- chainId: offer.chainId,
9300
- loanToken: offer.loanToken.toLowerCase(),
9301
- callbackAddress: offer.callback.address.toLowerCase(),
9302
- callbackData: offer.callback.data,
9303
- callbackGasLimit: offer.callback.gasLimit,
9304
- signature: offer.signature
9305
- }).onConflictDoNothing().returning();
9306
- if (result.length === 0) {
9307
- return offer.hash;
9308
- }
9309
- for (const collateral of offer.collaterals) {
9310
- await tx.insert(offerCollaterals).values({
9311
- offerHash: offer.hash.toLowerCase(),
9312
- asset: collateral.asset.toLowerCase(),
9313
- oracle: collateral.oracle.toLowerCase(),
9314
- lltv: collateral.lltv
9315
- });
9316
- }
9317
- await tx.insert(offerStatus).values({
9318
- offerHash: offer.hash.toLowerCase(),
9319
- status,
9320
- metadata
9321
- });
9322
- const consumedAmountExists = await tx.select().from(consumed).where(
9323
- drizzle_orm_star.and(
9324
- drizzle_orm_star.eq(consumed.offering, offer.offering.toLowerCase()),
9325
- drizzle_orm_star.eq(consumed.nonce, offer.nonce),
9326
- drizzle_orm_star.eq(consumed.chainId, offer.chainId)
9327
- )
9328
- );
9329
- if (consumedAmountExists.length > 0) {
9330
- return offer.hash;
9331
- }
9332
- await tx.insert(consumed).values({
9333
- chainId: offer.chainId,
9334
- offering: offer.offering.toLowerCase(),
9335
- nonce: offer.nonce,
9336
- consumed: 0n
9337
- });
9338
- return offer.hash;
9339
- });
9340
- },
9341
- createMany: async (parameters) => {
9342
- return await db.transaction(async (tx) => {
9343
- const hashes = [];
9344
- for (const { offer, status, metadata } of parameters) {
9345
- const result = await tx.insert(offers).values({
9346
- hash: offer.hash.toLowerCase(),
9347
- offering: offer.offering.toLowerCase(),
9348
- assets: offer.assets,
9349
- rate: offer.rate,
9350
- maturity: offer.maturity,
9351
- expiry: offer.expiry,
9352
- start: offer.start,
9353
- nonce: offer.nonce,
9354
- buy: offer.buy,
9355
- chainId: offer.chainId,
9356
- loanToken: offer.loanToken.toLowerCase(),
9357
- callbackAddress: offer.callback.address.toLowerCase(),
9358
- callbackData: offer.callback.data,
9359
- callbackGasLimit: offer.callback.gasLimit,
9360
- signature: offer.signature
9361
- }).onConflictDoNothing().returning();
9362
- if (result.length === 0) continue;
9363
- for (const collateral of offer.collaterals) {
9364
- await tx.insert(offerCollaterals).values({
9365
- offerHash: offer.hash.toLowerCase(),
9366
- asset: collateral.asset.toLowerCase(),
9367
- oracle: collateral.oracle.toLowerCase(),
9368
- lltv: collateral.lltv
9369
- });
9370
- }
9371
- await tx.insert(offerStatus).values({
9372
- offerHash: offer.hash.toLowerCase(),
9373
- status,
9374
- metadata
9375
- });
9376
- const consumedAmountExists = await tx.select().from(consumed).where(
9377
- drizzle_orm_star.and(
9378
- drizzle_orm_star.eq(consumed.offering, offer.offering.toLowerCase()),
9379
- drizzle_orm_star.eq(consumed.nonce, offer.nonce),
9380
- drizzle_orm_star.eq(consumed.chainId, offer.chainId)
9381
- )
9382
- );
9383
- if (consumedAmountExists.length > 0) {
9384
- hashes.push(offer.hash);
9385
- continue;
9386
- }
9387
- await tx.insert(consumed).values({
9388
- chainId: offer.chainId,
9389
- offering: offer.offering.toLowerCase(),
9390
- nonce: offer.nonce,
9391
- consumed: 0n
9392
- });
9393
- hashes.push(offer.hash);
9394
- }
9395
- return hashes;
9396
- });
9247
+ create,
9248
+ createMany: async (parameters2) => {
9249
+ return Promise.all(
9250
+ parameters2.map((p) => create({ offer: p.offer, status: p.status, metadata: p.metadata }))
9251
+ );
9397
9252
  },
9398
9253
  getAll: async (params) => {
9399
- const { query } = params ?? {};
9400
- const conditions = [];
9401
- if (query?.creators && query.creators.length > 0) {
9402
- conditions.push(drizzle_orm_star.inArray(offers.offering, query.creators));
9403
- }
9404
- if (query?.side) {
9405
- conditions.push(drizzle_orm_star.eq(offers.buy, query.side === "buy"));
9406
- }
9407
- if (query?.chains && query.chains.length > 0) {
9408
- conditions.push(
9409
- drizzle_orm_star.inArray(
9410
- offers.chainId,
9411
- query.chains.map((chain) => BigInt(chain))
9412
- )
9413
- );
9414
- }
9415
- if (query?.loanTokens && query.loanTokens.length > 0) {
9416
- conditions.push(drizzle_orm_star.inArray(offers.loanToken, query.loanTokens));
9417
- }
9418
- if (query?.callbackAddresses && query.callbackAddresses.length > 0) {
9419
- conditions.push(drizzle_orm_star.inArray(offers.callbackAddress, query.callbackAddresses));
9420
- }
9421
- if (query?.minAmount !== void 0) {
9422
- conditions.push(drizzle_orm_star.gte(offers.assets, query.minAmount));
9423
- }
9424
- if (query?.maxAmount !== void 0) {
9425
- conditions.push(drizzle_orm_star.lte(offers.assets, query.maxAmount));
9426
- }
9427
- if (query?.minRate !== void 0) {
9428
- conditions.push(drizzle_orm_star.gte(offers.rate, query.minRate));
9429
- }
9430
- if (query?.maxRate !== void 0) {
9431
- conditions.push(drizzle_orm_star.lte(offers.rate, query.maxRate));
9432
- }
9433
- if (query?.minMaturity !== void 0) {
9434
- conditions.push(drizzle_orm_star.gte(offers.maturity, query.minMaturity));
9435
- }
9436
- if (query?.maxMaturity !== void 0) {
9437
- conditions.push(drizzle_orm_star.lte(offers.maturity, query.maxMaturity));
9438
- }
9439
- if (query?.minExpiry !== void 0) {
9440
- conditions.push(drizzle_orm_star.gte(offers.expiry, query.minExpiry));
9441
- }
9442
- if (query?.maxExpiry !== void 0) {
9443
- conditions.push(drizzle_orm_star.lte(offers.expiry, query.maxExpiry));
9444
- }
9445
- if (query?.collateralAssets && query.collateralAssets.length > 0) {
9446
- conditions.push(drizzle_orm_star.inArray(offerCollaterals.asset, query.collateralAssets));
9447
- }
9448
- if (query?.collateralOracles && query.collateralOracles.length > 0) {
9449
- conditions.push(drizzle_orm_star.inArray(offerCollaterals.oracle, query.collateralOracles));
9450
- }
9451
- if (query?.collateralTuple && query.collateralTuple.length > 0) {
9452
- const tupleClauses = query.collateralTuple.map((tuple) => {
9453
- const parts = [
9454
- drizzle_orm_star.sql`${offerCollaterals.asset} = ${tuple.asset}`
9455
- ];
9456
- if (tuple.oracle) {
9457
- parts.push(drizzle_orm_star.sql`${offerCollaterals.oracle} = ${tuple.oracle}`);
9458
- }
9459
- if (tuple.lltv !== void 0) {
9460
- const lltvInBasisPoints = blueSdkViem.safeParseNumber(tuple.lltv / 100, 18);
9461
- parts.push(drizzle_orm_star.sql`${offerCollaterals.lltv} = ${lltvInBasisPoints}`);
9462
- }
9463
- let clause = parts[0];
9464
- for (let i = 1; i < parts.length; i++) {
9465
- clause = drizzle_orm_star.sql`${clause} AND ${parts[i]}`;
9466
- }
9467
- return drizzle_orm_star.sql`(${clause})`;
9468
- }).filter((c) => c !== void 0);
9469
- if (tupleClauses.length > 0) {
9470
- let combined = tupleClauses[0];
9471
- for (let i = 1; i < tupleClauses.length; i++) {
9472
- combined = drizzle_orm_star.sql`${combined} OR ${tupleClauses[i]}`;
9473
- }
9474
- conditions.push(drizzle_orm_star.sql`(${combined})`);
9254
+ const { query } = params || {};
9255
+ let {
9256
+ creators,
9257
+ side,
9258
+ chains: chains2,
9259
+ loanTokens,
9260
+ status = ["valid"],
9261
+ callbackAddresses,
9262
+ minAmount,
9263
+ maxAmount,
9264
+ minRate,
9265
+ maxRate,
9266
+ minMaturity,
9267
+ maxMaturity,
9268
+ minExpiry,
9269
+ maxExpiry,
9270
+ collateralAssets,
9271
+ collateralOracles,
9272
+ collateralTuple,
9273
+ minLltv,
9274
+ maxLltv,
9275
+ sortBy = "expiry",
9276
+ sortOrder = "desc",
9277
+ cursor: queryCursor,
9278
+ limit = 20
9279
+ } = query || {};
9280
+ const now = mempool.Time.now();
9281
+ const buy = side === "buy";
9282
+ let offers = Array.from(map.values()).map((o) => ({
9283
+ ...o,
9284
+ consumed: filled.get(o.chainId)?.get(o.offering.toLowerCase())?.get(o.nonce) || 0n
9285
+ })).filter((o) => o.consumed < o.assets);
9286
+ const cursor = decodeCursor(queryCursor);
9287
+ if (cursor) {
9288
+ if (cursor.sort !== sortBy || cursor.dir !== sortOrder) {
9289
+ throw new Error("Cursor does not match the current sort parameters");
9475
9290
  }
9476
- }
9477
- if (query?.minLltv !== void 0) {
9478
- const minLltvInBasisPoints = blueSdkViem.safeParseNumber(query.minLltv / 100, 18);
9479
- conditions.push(drizzle_orm_star.gte(offerCollaterals.lltv, minLltvInBasisPoints));
9480
- }
9481
- if (query?.maxLltv !== void 0) {
9482
- const maxLltvInBasisPoints = blueSdkViem.safeParseNumber(query.maxLltv / 100, 18);
9483
- conditions.push(drizzle_orm_star.lte(offerCollaterals.lltv, maxLltvInBasisPoints));
9484
- }
9485
- const sortBy = query?.sortBy ?? "expiry";
9486
- const sortOrder = query?.sortOrder ?? "desc";
9487
- const sortColumn = (() => {
9488
- switch (sortBy) {
9291
+ switch (cursor.sort) {
9489
9292
  case "rate":
9490
- return offers.rate;
9293
+ offers = offers.filter(
9294
+ (o) => (sortOrder === "asc" ? o.rate >= BigInt(cursor.rate) : o.rate <= BigInt(cursor.rate)) && (o.rate !== BigInt(cursor.rate) || (sortOrder === "asc" ? o.hash > cursor.hash : o.hash < cursor.hash))
9295
+ );
9296
+ break;
9491
9297
  case "maturity":
9492
- return offers.maturity;
9298
+ offers = offers.filter(
9299
+ (o) => (sortOrder === "asc" ? o.maturity >= BigInt(cursor.maturity) : o.maturity <= BigInt(cursor.maturity)) && (o.maturity !== mempool.Maturity.from(cursor.maturity) || (sortOrder === "asc" ? o.hash > cursor.hash : o.hash < cursor.hash))
9300
+ );
9301
+ break;
9493
9302
  case "expiry":
9494
- return offers.expiry;
9303
+ offers = offers.filter(
9304
+ (o) => (sortOrder === "asc" ? o.expiry >= cursor.expiry : o.expiry <= cursor.expiry) && (o.expiry !== cursor.expiry || (sortOrder === "asc" ? o.hash > cursor.hash : o.hash < cursor.hash))
9305
+ );
9306
+ break;
9495
9307
  case "amount":
9496
- return offers.assets;
9308
+ offers = offers.filter(
9309
+ (o) => (sortOrder === "asc" ? o.assets >= BigInt(cursor.assets) : o.assets <= BigInt(cursor.assets)) && (o.assets !== BigInt(cursor.assets) || (sortOrder === "asc" ? o.hash > cursor.hash : o.hash < cursor.hash))
9310
+ );
9311
+ break;
9497
9312
  default:
9498
- return offers.expiry;
9499
- }
9500
- })();
9501
- const cursor = decodeCursor(query?.cursor);
9502
- if (cursor) {
9503
- if (cursor.sort !== sortBy || cursor.dir !== sortOrder) {
9504
- throw new Error("Cursor does not match the current sort parameters");
9505
- }
9506
- const op = sortOrder === "asc" ? drizzle_orm_star.sql`>` : drizzle_orm_star.sql`<`;
9507
- const cursorVal = (() => {
9508
- switch (sortBy) {
9509
- case "rate":
9510
- return BigInt(cursor.rate);
9511
- case "amount":
9512
- return BigInt(cursor.assets);
9513
- case "maturity":
9514
- return cursor.maturity;
9515
- case "expiry":
9516
- return cursor.expiry;
9517
- default:
9518
- return cursor.expiry;
9519
- }
9520
- })();
9521
- conditions.push(drizzle_orm_star.sql`(${sortColumn}, ${offers.hash}) ${op} (${cursorVal}, ${cursor.hash})`);
9522
- }
9523
- const limit = query?.limit ?? 20;
9524
- const latestStatus = db.select({
9525
- status: offerStatus.status,
9526
- metadata: offerStatus.metadata
9527
- }).from(offerStatus).where(drizzle_orm_star.eq(offerStatus.offerHash, offers.hash)).orderBy(drizzle_orm_star.desc(offerStatus.createdAt)).limit(1).as("latest_status");
9528
- const latestConsumed = db.selectDistinctOn(
9529
- [
9530
- consumed.offering,
9531
- consumed.nonce,
9532
- consumed.chainId,
9533
- consumed.createdAt
9534
- ],
9535
- {
9536
- consumed: consumed.consumed
9537
- }
9538
- ).from(consumed).orderBy(drizzle_orm_star.desc(consumed.createdAt)).limit(1).as("latest_consumed");
9539
- const results = await db.select({
9540
- hash: offers.hash,
9541
- offering: offers.offering,
9542
- assets: offers.assets,
9543
- consumed: latestConsumed.consumed,
9544
- rate: offers.rate,
9545
- maturity: offers.maturity,
9546
- expiry: offers.expiry,
9547
- start: offers.start,
9548
- nonce: offers.nonce,
9549
- buy: offers.buy,
9550
- chainId: offers.chainId,
9551
- loanToken: offers.loanToken,
9552
- callbackAddress: offers.callbackAddress,
9553
- callbackData: offers.callbackData,
9554
- callbackGasLimit: offers.callbackGasLimit,
9555
- signature: offers.signature,
9556
- createdAt: offers.createdAt,
9557
- collateralAsset: offerCollaterals.asset,
9558
- collateralOracle: offerCollaterals.oracle,
9559
- collateralLltv: offerCollaterals.lltv,
9560
- status: latestStatus.status,
9561
- metadata: latestStatus.metadata
9562
- }).from(offers).leftJoin(offerCollaterals, drizzle_orm_star.eq(offers.hash, offerCollaterals.offerHash)).leftJoinLateral(latestStatus, drizzle_orm_star.sql`true`).leftJoinLateral(latestConsumed, drizzle_orm_star.sql`true`).where(
9563
- drizzle_orm_star.and(
9564
- conditions.length > 0 ? drizzle_orm_star.and(...conditions) : drizzle_orm_star.sql`true`,
9565
- query?.status && query.status.length > 0 ? drizzle_orm_star.inArray(latestStatus.status, query.status) : drizzle_orm_star.eq(latestStatus.status, "valid"),
9566
- drizzle_orm_star.sql`( ${offers.assets} - COALESCE(${latestConsumed.consumed}, 0) ) > 0`
9313
+ throw new Error("Invalid sort parameter");
9314
+ }
9315
+ offers = offers.filter((o) => o.hash !== cursor.hash);
9316
+ }
9317
+ creators && (creators = creators.map((c) => c.toLowerCase()));
9318
+ loanTokens && (loanTokens = loanTokens.map((lt) => lt.toLowerCase()));
9319
+ callbackAddresses && (callbackAddresses = callbackAddresses.map((ca) => ca.toLowerCase()));
9320
+ collateralAssets && (collateralAssets = collateralAssets.map((ca) => ca.toLowerCase()));
9321
+ collateralOracles && (collateralOracles = collateralOracles.map((co) => co.toLowerCase()));
9322
+ collateralTuple && (collateralTuple = collateralTuple.map((ct) => ({
9323
+ asset: ct.asset.toLowerCase(),
9324
+ oracle: ct.oracle?.toLowerCase()
9325
+ })));
9326
+ offers = offers.filter((o) => o.expiry >= now);
9327
+ creators && (offers = offers.filter((o) => creators.includes(o.offering.toLowerCase())));
9328
+ side && (offers = offers.filter((o) => o.buy === buy));
9329
+ chains2 && (offers = offers.filter((o) => chains2.includes(Number(o.chainId))));
9330
+ loanTokens && (offers = offers.filter((o) => loanTokens.includes(o.loanToken.toLowerCase())));
9331
+ status && (offers = offers.filter((o) => status.includes(o.status)));
9332
+ callbackAddresses && (offers = offers.filter(
9333
+ (o) => callbackAddresses.includes(o.callback.address.toLowerCase())
9334
+ ));
9335
+ minAmount && (offers = offers.filter((o) => o.assets >= minAmount));
9336
+ maxAmount && (offers = offers.filter((o) => o.assets <= maxAmount));
9337
+ minRate && (offers = offers.filter((o) => o.rate >= minRate));
9338
+ maxRate && (offers = offers.filter((o) => o.rate <= maxRate));
9339
+ minMaturity && (offers = offers.filter((o) => o.maturity >= minMaturity));
9340
+ maxMaturity && (offers = offers.filter((o) => o.maturity <= maxMaturity));
9341
+ minExpiry && (offers = offers.filter((o) => o.expiry >= minExpiry));
9342
+ maxExpiry && (offers = offers.filter((o) => o.expiry <= maxExpiry));
9343
+ collateralAssets && (offers = offers.filter(
9344
+ (o) => o.collaterals.some((c) => collateralAssets.includes(c.asset.toLowerCase()))
9345
+ ));
9346
+ collateralOracles && (offers = offers.filter(
9347
+ (o) => o.collaterals.some((c) => collateralOracles.includes(c.oracle.toLowerCase()))
9348
+ ));
9349
+ collateralTuple && (offers = offers.filter(
9350
+ (o) => o.collaterals.some(
9351
+ (c) => collateralTuple.some(
9352
+ (ct) => c.asset.toLowerCase() === ct.asset.toLowerCase() && (ct.oracle ? c.oracle.toLowerCase() === ct.oracle.toLowerCase() : true) && (ct.lltv ? c.lltv === mempool.LLTV.from(BigInt(ct.lltv)) : true)
9353
+ )
9567
9354
  )
9568
- ).orderBy(sortOrder === "asc" ? drizzle_orm_star.asc(sortColumn) : drizzle_orm_star.desc(sortColumn)).limit(limit);
9569
- const offerMap = /* @__PURE__ */ new Map();
9570
- for (const row of results) {
9571
- const offer = offerMap.get(row.hash) || {
9572
- hash: row.hash,
9573
- offering: row.offering,
9574
- assets: row.assets,
9575
- consumed: row.consumed || 0n,
9576
- rate: row.rate,
9577
- maturity: row.maturity,
9578
- expiry: row.expiry,
9579
- start: row.start,
9580
- nonce: row.nonce,
9581
- buy: row.buy,
9582
- chainId: row.chainId,
9583
- loanToken: row.loanToken,
9584
- callbackAddress: row.callbackAddress,
9585
- callbackData: row.callbackData,
9586
- callbackGasLimit: row.callbackGasLimit,
9587
- signature: row.signature,
9588
- createdAt: row.createdAt,
9589
- collaterals: [],
9590
- status: row.status,
9591
- metadata: row.metadata
9592
- };
9593
- if (row.collateralAsset && row.collateralOracle && row.collateralLltv) {
9594
- offer.collaterals.push({
9595
- asset: row.collateralAsset,
9596
- oracle: row.collateralOracle,
9597
- lltv: mempool.LLTV.from(row.collateralLltv)
9598
- });
9599
- }
9600
- offerMap.set(row.hash, offer);
9601
- }
9355
+ ));
9356
+ minLltv && (offers = offers.filter((o) => o.collaterals.every((c) => c.lltv >= minLltv)));
9357
+ maxLltv && (offers = offers.filter((o) => o.collaterals.every((c) => c.lltv <= maxLltv)));
9358
+ offers = offers.sort((a, b) => sort(sortBy, sortOrder, a, b));
9602
9359
  let nextCursor = null;
9603
- if (results.length === limit && results.length > 0) {
9604
- const lastRow = results[results.length - 1];
9360
+ if (offers.length > limit) {
9361
+ const last = offers[limit - 1];
9605
9362
  const base2 = {
9606
9363
  sort: sortBy,
9607
9364
  dir: sortOrder,
9608
- hash: lastRow.hash
9365
+ hash: last.hash
9609
9366
  };
9610
9367
  switch (sortBy) {
9611
9368
  case "rate":
9612
- base2.rate = lastRow.rate.toString();
9369
+ base2.rate = last.rate.toString();
9613
9370
  break;
9614
9371
  case "amount":
9615
- base2.assets = lastRow.assets.toString();
9372
+ base2.assets = last.assets.toString();
9616
9373
  break;
9617
9374
  case "maturity":
9618
- base2.maturity = lastRow.maturity;
9375
+ base2.maturity = last.maturity;
9619
9376
  break;
9620
9377
  default:
9621
- base2.expiry = lastRow.expiry;
9378
+ base2.expiry = last.expiry;
9622
9379
  }
9623
9380
  nextCursor = encodeCursor(base2);
9624
9381
  }
9625
- const transformedResults = [];
9626
- for (const offerData of offerMap.values()) {
9627
- const offer = mempool.Offer.from({
9628
- offering: offerData.offering,
9629
- assets: offerData.assets,
9630
- rate: offerData.rate,
9631
- maturity: mempool.Maturity.from(offerData.maturity),
9632
- expiry: offerData.expiry,
9633
- start: offerData.start,
9634
- nonce: offerData.nonce,
9635
- buy: offerData.buy,
9636
- chainId: offerData.chainId,
9637
- loanToken: offerData.loanToken,
9638
- collaterals: offerData.collaterals.map((c) => ({
9639
- asset: c.asset,
9640
- oracle: c.oracle,
9641
- lltv: mempool.LLTV.from(c.lltv)
9642
- })).sort((a, b) => a.asset.toLowerCase().localeCompare(b.asset.toLowerCase())),
9643
- callback: {
9644
- address: offerData.callbackAddress,
9645
- data: offerData.callbackData,
9646
- gasLimit: offerData.callbackGasLimit
9647
- },
9648
- signature: offerData.signature === null ? void 0 : offerData.signature
9649
- });
9650
- transformedResults.push({
9651
- ...offer,
9652
- consumed: offerData.consumed,
9653
- status: offerData.status,
9654
- ...offerData.metadata !== null ? { metadata: offerData.metadata } : {}
9655
- });
9656
- }
9657
- return { offers: transformedResults, nextCursor };
9382
+ offers = offers.slice(0, limit);
9383
+ return {
9384
+ offers,
9385
+ nextCursor
9386
+ };
9658
9387
  },
9659
- /**
9660
- * Returns offers that match specified offer based on the provided parameters.
9661
- *
9662
- * Rules for filtering:
9663
- * - If offer expiry is in the past compared to now, it should not be included
9664
- * - If offer maturity is in the past compared to now, it should not be included
9665
- * - It should return if buyOffer.rate >= sellOffer.rate
9666
- * - It should return if buyOffer.userAddress != sellOffer.userAddress
9667
- * - It should return if maturity matches
9668
- * - It should return if loanToken matches
9669
- * - If the incoming intent is a buy / lend offer, only consider existing sell / borrow offers.
9670
- * - If the incoming intent is a sell / borrow offer, only consider existing buy / lend offers.
9671
- * - When the intent is lend: require offer_collaterals ⊆ intent_collaterals
9672
- * - When the intent is borrow: require intent_collaterals ⊆ offer_collaterals
9673
- * - It should sort by increasing rate if the input offer is a buy/lend offer
9674
- * - It should sort by decreasing rate if the input offer is a sell/borrow offer
9675
- */
9676
9388
  findMatchingOffers: async (params) => {
9677
9389
  const {
9678
9390
  side,
@@ -9685,192 +9397,86 @@ function create2(config) {
9685
9397
  loanToken,
9686
9398
  creator,
9687
9399
  status,
9688
- cursor,
9400
+ cursor: queryCursor,
9689
9401
  limit = 20
9690
9402
  } = params;
9691
- const buy = side !== "buy";
9692
- const now = Math.floor(Date.now() / 1e3);
9693
- const sortOrder = buy ? "asc" : "desc";
9694
- const conditions = [];
9695
- conditions.push(drizzle_orm_star.eq(offers.buy, buy));
9696
- conditions.push(drizzle_orm_star.eq(offers.chainId, BigInt(chainId)));
9697
- conditions.push(drizzle_orm_star.gte(offers.expiry, now));
9698
- conditions.push(drizzle_orm_star.gte(offers.maturity, now));
9699
- if (maturity !== void 0) conditions.push(drizzle_orm_star.eq(offers.maturity, maturity));
9700
- if (minMaturity !== void 0) conditions.push(drizzle_orm_star.gte(offers.maturity, minMaturity));
9701
- if (maxMaturity !== void 0) conditions.push(drizzle_orm_star.lte(offers.maturity, maxMaturity));
9702
- if (loanToken) conditions.push(drizzle_orm_star.eq(offers.loanToken, loanToken.toLowerCase()));
9703
- if (creator) conditions.push(drizzle_orm_star.eq(offers.offering, creator.toLowerCase()));
9704
- if (rate !== void 0) {
9705
- conditions.push(buy ? drizzle_orm_star.gte(offers.rate, rate) : drizzle_orm_star.lte(offers.rate, rate));
9706
- }
9707
- const decoded = decodeCursor(cursor);
9708
- if (decoded) {
9709
- if (decoded.sort !== "rate" || decoded.dir !== sortOrder) {
9403
+ const now = mempool.Time.now();
9404
+ const isBuying = side === "buy";
9405
+ const sortOrder = isBuying ? "desc" : "asc";
9406
+ let offers = Array.from(map.values()).map((o) => ({
9407
+ ...o,
9408
+ consumed: filled.get(o.chainId)?.get(o.offering.toLowerCase())?.get(o.nonce) || 0n
9409
+ })).filter((o) => o.consumed < o.assets);
9410
+ const cursor = decodeCursor(queryCursor);
9411
+ if (cursor) {
9412
+ if (cursor.sort !== "rate" || cursor.dir !== sortOrder) {
9710
9413
  throw new Error("Cursor does not match the current sort parameters");
9711
9414
  }
9712
- const op = sortOrder === "asc" ? drizzle_orm_star.sql`>` : drizzle_orm_star.sql`<`;
9713
- conditions.push(
9714
- drizzle_orm_star.sql`(${offers.rate}, ${offers.hash}) ${op} (${BigInt(decoded.rate)}, ${decoded.hash})`
9415
+ offers = offers.filter(
9416
+ (o) => sortOrder === "asc" ? o.rate >= BigInt(cursor.rate) : o.rate <= BigInt(cursor.rate)
9715
9417
  );
9716
9418
  }
9717
- if (collaterals.length > 0) {
9718
- const collateralValues = collaterals.map(
9719
- (c) => `('${c.asset.toLowerCase()}', '${c.oracle.toLowerCase()}', ${c.lltv.toString()})`
9720
- ).join(", ");
9721
- const userCollaterals = drizzle_orm_star.sql`(VALUES ${drizzle_orm_star.sql.raw(collateralValues)}) AS uc(asset, oracle, lltv)`;
9722
- const lendPredicate = drizzle_orm_star.sql`
9723
- NOT EXISTS (
9724
- SELECT 1 FROM ${userCollaterals}
9725
- WHERE NOT EXISTS (
9726
- SELECT 1 FROM ${offerCollaterals} oc
9727
- WHERE oc.offer_hash = ${offers.hash}
9728
- AND oc.asset = uc.asset
9729
- AND oc.oracle = uc.oracle
9730
- AND oc.lltv = uc.lltv
9731
- )
9732
- )
9733
- `;
9734
- const borrowPredicate = drizzle_orm_star.sql`
9735
- NOT EXISTS (
9736
- SELECT 1 FROM ${offerCollaterals} oc
9737
- WHERE oc.offer_hash = ${offers.hash}
9738
- AND NOT EXISTS (
9739
- SELECT 1 FROM ${userCollaterals}
9740
- WHERE uc.asset = oc.asset
9741
- AND uc.oracle = oc.oracle
9742
- AND uc.lltv = oc.lltv
9743
- )
9744
- )
9745
- `;
9746
- conditions.push(buy ? lendPredicate : borrowPredicate);
9747
- }
9748
- const latestStatus = db.select({
9749
- status: offerStatus.status,
9750
- metadata: offerStatus.metadata
9751
- }).from(offerStatus).where(drizzle_orm_star.eq(offerStatus.offerHash, offers.hash)).orderBy(drizzle_orm_star.desc(offerStatus.createdAt)).limit(1).as("latest_status");
9752
- const latestConsumed = db.selectDistinctOn(
9753
- [
9754
- consumed.offering,
9755
- consumed.nonce,
9756
- consumed.chainId,
9757
- consumed.createdAt
9758
- ],
9759
- {
9760
- consumed: consumed.consumed
9761
- }
9762
- ).from(consumed).orderBy(drizzle_orm_star.desc(consumed.createdAt)).limit(1).as("latest_consumed");
9763
- const statusCondition = status && status.length > 0 ? drizzle_orm_star.inArray(latestStatus.status, status) : drizzle_orm_star.eq(latestStatus.status, "valid");
9764
- const bestOffers = db.selectDistinctOn(
9765
- // group key
9766
- [offers.offering, offers.nonce, offers.buy],
9767
- {
9768
- hash: offers.hash,
9769
- offering: offers.offering,
9770
- assets: offers.assets,
9771
- consumed: latestConsumed.consumed,
9772
- rate: offers.rate,
9773
- maturity: offers.maturity,
9774
- expiry: offers.expiry,
9775
- start: offers.start,
9776
- nonce: offers.nonce,
9777
- buy: offers.buy,
9778
- chainId: offers.chainId,
9779
- loanToken: offers.loanToken,
9780
- callbackAddress: offers.callbackAddress,
9781
- callbackData: offers.callbackData,
9782
- callbackGasLimit: offers.callbackGasLimit,
9783
- signature: offers.signature,
9784
- status: latestStatus.status,
9785
- metadata: latestStatus.metadata
9786
- }
9787
- ).from(offers).leftJoinLateral(latestStatus, drizzle_orm_star.sql`true`).leftJoinLateral(latestConsumed, drizzle_orm_star.sql`true`).where(
9788
- drizzle_orm_star.and(
9789
- drizzle_orm_star.and(...conditions),
9790
- statusCondition,
9791
- drizzle_orm_star.sql`( ${offers.assets} - COALESCE(${latestConsumed.consumed}, 0) ) > 0`
9419
+ offers = offers.filter((o) => o.buy === !isBuying);
9420
+ offers = offers.filter((o) => o.chainId === BigInt(chainId));
9421
+ offers = offers.filter((o) => o.expiry >= now);
9422
+ rate && (offers = offers.filter((o) => isBuying ? o.rate >= rate : o.rate <= rate));
9423
+ collaterals.length > 0 && (offers = offers.filter(
9424
+ (o) => isBuying ? (
9425
+ // when wanting to buy, sell offer collaterals ⊆ user buy collaterals
9426
+ o.collaterals.every((oc) => {
9427
+ return collaterals.some(
9428
+ (c) => oc.asset.toLowerCase() === c.asset.toLowerCase() && oc.oracle.toLowerCase() === c.oracle.toLowerCase() && oc.lltv === c.lltv
9429
+ );
9430
+ })
9431
+ ) : (
9432
+ // when wanting to sell, user sell collaterals ⊆ buy offer collaterals
9433
+ collaterals.every((c) => {
9434
+ return o.collaterals.some(
9435
+ (oc) => oc.asset.toLowerCase() === c.asset.toLowerCase() && oc.oracle.toLowerCase() === c.oracle.toLowerCase() && oc.lltv === c.lltv
9436
+ );
9437
+ })
9792
9438
  )
9793
- ).orderBy(
9794
- offers.offering,
9795
- offers.nonce,
9796
- offers.buy,
9797
- // 1 price (direction depends on side)
9798
- drizzle_orm_star.sql`CASE WHEN ${offers.buy} THEN ${offers.rate} ELSE -${offers.rate} END`,
9799
- // 2 size (remaining)
9800
- drizzle_orm_star.sql`( ${offers.assets} - COALESCE(${latestConsumed.consumed}, 0) ) DESC`,
9801
- // 3 term (longer maturity)
9802
- drizzle_orm_star.desc(offers.maturity)
9803
- ).as("best_offers");
9804
- const rows = await db.select({
9805
- hash: bestOffers.hash,
9806
- offering: bestOffers.offering,
9807
- assets: bestOffers.assets,
9808
- consumed: bestOffers.consumed,
9809
- rate: bestOffers.rate,
9810
- maturity: bestOffers.maturity,
9811
- expiry: bestOffers.expiry,
9812
- start: bestOffers.start,
9813
- nonce: bestOffers.nonce,
9814
- buy: bestOffers.buy,
9815
- chainId: bestOffers.chainId,
9816
- loanToken: bestOffers.loanToken,
9817
- callbackAddress: bestOffers.callbackAddress,
9818
- callbackData: bestOffers.callbackData,
9819
- callbackGasLimit: bestOffers.callbackGasLimit,
9820
- signature: bestOffers.signature,
9821
- status: bestOffers.status,
9822
- metadata: bestOffers.metadata,
9823
- collateralAsset: offerCollaterals.asset,
9824
- collateralOracle: offerCollaterals.oracle,
9825
- collateralLltv: offerCollaterals.lltv
9826
- }).from(bestOffers).leftJoin(offerCollaterals, drizzle_orm_star.eq(bestOffers.hash, offerCollaterals.offerHash)).orderBy(
9827
- sortOrder === "asc" ? drizzle_orm_star.sql`CASE WHEN ${bestOffers.buy} THEN ${bestOffers.rate} ELSE -${bestOffers.rate} END ASC` : drizzle_orm_star.sql`CASE WHEN ${bestOffers.buy} THEN -${bestOffers.rate} ELSE ${bestOffers.rate} END DESC`
9828
- ).limit(limit + 1);
9829
- const offerMap = /* @__PURE__ */ new Map();
9830
- for (const r of rows) {
9831
- const entry = offerMap.get(r.hash) ?? { base: r, collaterals: [] };
9832
- if (r.collateralAsset && r.collateralOracle && r.collateralLltv) {
9833
- entry.collaterals.push({
9834
- asset: r.collateralAsset,
9835
- oracle: r.collateralOracle,
9836
- lltv: mempool.LLTV.from(r.collateralLltv)
9837
- });
9439
+ ));
9440
+ maturity && (offers = offers.filter((o) => o.maturity === maturity));
9441
+ minMaturity && (offers = offers.filter((o) => o.maturity >= minMaturity));
9442
+ maxMaturity && (offers = offers.filter((o) => o.maturity <= maxMaturity));
9443
+ loanToken && (offers = offers.filter((o) => o.loanToken.toLowerCase() === loanToken.toLowerCase()));
9444
+ creator && (offers = offers.filter((o) => o.offering.toLowerCase() === creator.toLowerCase()));
9445
+ status && (offers = offers.filter((o) => status.includes(o.status)));
9446
+ const byGroup = /* @__PURE__ */ new Map();
9447
+ for (const offer of offers) {
9448
+ const groupKey = `${offer.chainId}-${offer.offering.toLowerCase()}-${offer.nonce}-${offer.buy}`;
9449
+ const current = byGroup.get(groupKey);
9450
+ if (!current) {
9451
+ byGroup.set(groupKey, offer);
9452
+ continue;
9838
9453
  }
9839
- offerMap.set(r.hash, entry);
9840
- }
9841
- const offersArray = Array.from(offerMap.values()).sort(
9842
- (a, b) => sortOrder === "asc" ? a.base.rate < b.base.rate ? -1 : 1 : a.base.rate > b.base.rate ? -1 : 1
9843
- );
9844
- const page = offersArray.slice(0, limit);
9845
- const data = page.map(({ base: base2, collaterals: cols }) => ({
9846
- ...mempool.Offer.from({
9847
- offering: base2.offering,
9848
- assets: base2.assets,
9849
- rate: base2.rate,
9850
- maturity: mempool.Maturity.from(base2.maturity),
9851
- expiry: base2.expiry,
9852
- start: base2.start,
9853
- nonce: base2.nonce,
9854
- buy: base2.buy,
9855
- chainId: base2.chainId,
9856
- loanToken: base2.loanToken,
9857
- collaterals: cols.sort(
9858
- (a, b) => a.asset.toLowerCase().localeCompare(b.asset.toLowerCase())
9859
- ),
9860
- callback: {
9861
- address: base2.callbackAddress,
9862
- data: base2.callbackData,
9863
- gasLimit: base2.callbackGasLimit
9864
- },
9865
- signature: base2.signature === null ? void 0 : base2.signature
9866
- }),
9867
- consumed: base2.consumed || 0n,
9868
- status: base2.status,
9869
- ...base2.metadata ? { metadata: base2.metadata } : {}
9870
- }));
9454
+ const remainingCandidate = offer.assets - offer.consumed;
9455
+ const remainingCurrent = current.assets - current.consumed;
9456
+ let candidateIsBetter = false;
9457
+ if (offer.buy) {
9458
+ if (offer.rate !== current.rate) candidateIsBetter = offer.rate < current.rate;
9459
+ else if (remainingCandidate !== remainingCurrent)
9460
+ candidateIsBetter = remainingCandidate > remainingCurrent;
9461
+ else if (offer.maturity !== current.maturity)
9462
+ candidateIsBetter = offer.maturity > current.maturity;
9463
+ else candidateIsBetter = offer.hash < current.hash;
9464
+ } else {
9465
+ if (offer.rate !== current.rate) candidateIsBetter = offer.rate > current.rate;
9466
+ else if (remainingCandidate !== remainingCurrent)
9467
+ candidateIsBetter = remainingCandidate > remainingCurrent;
9468
+ else if (offer.maturity !== current.maturity)
9469
+ candidateIsBetter = offer.maturity > current.maturity;
9470
+ else candidateIsBetter = offer.hash < current.hash;
9471
+ }
9472
+ if (candidateIsBetter) byGroup.set(groupKey, offer);
9473
+ }
9474
+ offers = Array.from(byGroup.values());
9475
+ offers = offers.sort((a, b) => sort("rate", sortOrder, a, b));
9476
+ cursor && (offers = offers.filter((o) => o.hash !== cursor.hash));
9871
9477
  let nextCursor = null;
9872
- if (offersArray.length > limit) {
9873
- const last = page[page.length - 1].base;
9478
+ if (offers.length > limit) {
9479
+ const last = offers[limit - 1];
9874
9480
  nextCursor = encodeCursor({
9875
9481
  sort: "rate",
9876
9482
  dir: sortOrder,
@@ -9878,62 +9484,62 @@ function create2(config) {
9878
9484
  rate: last.rate.toString()
9879
9485
  });
9880
9486
  }
9881
- return { offers: data, nextCursor };
9487
+ offers = offers.slice(0, limit);
9488
+ return {
9489
+ offers,
9490
+ nextCursor
9491
+ };
9882
9492
  },
9883
9493
  delete: async (hash3) => {
9884
- const result = await db.delete(offers).where(drizzle_orm_star.eq(offers.hash, hash3.toLowerCase()));
9885
- return result.affectedRows > 0;
9494
+ if (!map.has(hash3.toLowerCase())) return false;
9495
+ map.delete(hash3.toLowerCase());
9496
+ return true;
9886
9497
  },
9887
9498
  deleteMany: async (hashes) => {
9888
- if (hashes.length === 0) {
9889
- return 0;
9499
+ let deleted = 0;
9500
+ for (const hash3 of hashes) {
9501
+ if (map.has(hash3.toLowerCase())) {
9502
+ map.delete(hash3.toLowerCase());
9503
+ deleted++;
9504
+ }
9890
9505
  }
9891
- return await db.transaction(async (tx) => {
9892
- const normalizedHashes = hashes.map((hash3) => hash3.toLowerCase());
9893
- const result = await tx.delete(offers).where(
9894
- drizzle_orm_star.sql`${offers.hash} = ANY(${drizzle_orm_star.sql.raw(`ARRAY[${normalizedHashes.map((h) => `'${h}'`).join(", ")}]`)})`
9895
- );
9896
- return result.affectedRows;
9897
- });
9506
+ return deleted;
9898
9507
  },
9899
- updateStatus: async (parameters) => {
9900
- await db.insert(offerStatus).values(parameters);
9901
- },
9902
- updateConsumedAmount: async (parameters) => {
9903
- await db.insert(consumed).values(parameters);
9904
- }
9905
- };
9906
- }
9907
- function createTest() {
9908
- return {
9909
- create: async (_parameters) => "",
9910
- createMany: async (_parameters) => [],
9911
- getAll: async (_params) => ({ offers: [], nextCursor: null }),
9912
- findMatchingOffers: async (_params) => ({ offers: [], nextCursor: null }),
9913
- delete: async (_hash) => false,
9914
- deleteMany: async (_hashes) => 0,
9915
- updateStatus: async (_params) => {
9508
+ updateStatus: async (parameters2) => {
9509
+ const key = parameters2.offerHash.toLowerCase();
9510
+ const existing = map.get(key);
9511
+ if (!existing) return;
9512
+ if (existing.status === parameters2.status) return;
9513
+ map.set(key, {
9514
+ ...existing,
9515
+ status: parameters2.status,
9516
+ metadata: parameters2.metadata
9517
+ });
9916
9518
  },
9917
- updateConsumedAmount: async (_params) => {
9519
+ updateConsumedAmount: async (parameters2) => {
9520
+ const chainId = parameters2.chainId;
9521
+ const address = parameters2.offering.toLowerCase();
9522
+ const nonce = parameters2.nonce;
9523
+ const filledForChain = filled.get(chainId) || /* @__PURE__ */ new Map();
9524
+ const filledForOffering = filledForChain.get(address) || /* @__PURE__ */ new Map();
9525
+ filledForOffering.set(nonce, parameters2.consumed);
9526
+ filledForChain.set(address, filledForOffering);
9527
+ filled.set(chainId, filledForChain);
9918
9528
  }
9919
9529
  };
9920
9530
  }
9921
9531
 
9922
- // src/core/Server.ts
9532
+ // src/core/router/Server.ts
9923
9533
  async function serve(parameters) {
9924
9534
  const app = new hono.Hono();
9925
- let repository;
9926
- if (parameters.store) {
9927
- repository = parameters.store;
9928
- } else {
9929
- const db = OfferDB_exports.create({ type: "pglite" });
9930
- repository = OfferRepository_exports.create({ db });
9931
- await OfferDB_exports.applyMigrations(db);
9932
- }
9535
+ const store = parameters.store ? parameters.store : memory({
9536
+ offers: /* @__PURE__ */ new Map(),
9537
+ filled: /* @__PURE__ */ new Map()
9538
+ });
9933
9539
  app.get("/v1/offers", async (c) => {
9934
9540
  try {
9935
9541
  const params = parse("get_offers", c.req.query());
9936
- const offers2 = await repository.getAll({
9542
+ const offers = await store.getAll({
9937
9543
  query: {
9938
9544
  creators: params.creators,
9939
9545
  side: params.side,
@@ -9961,20 +9567,20 @@ async function serve(parameters) {
9961
9567
  }
9962
9568
  });
9963
9569
  return mempool.Mempool.success(c, {
9964
- data: offers2.offers.map(
9570
+ data: offers.offers.map(
9965
9571
  (offer) => mempool.Format.stringifyBigint(mempool.Format.toSnakeCase(toResponse(offer)))
9966
9572
  ),
9967
- cursor: offers2.nextCursor ?? null
9573
+ cursor: offers.nextCursor ?? null
9968
9574
  });
9969
9575
  } catch (err) {
9970
9576
  console.error(err);
9971
9577
  return mempool.Mempool.error(err, c);
9972
9578
  }
9973
9579
  });
9974
- app.get("/v1/match-offers", async (c) => {
9580
+ app.get("/v1/offers/match", async (c) => {
9975
9581
  try {
9976
9582
  const params = parse("match_offers", c.req.query());
9977
- const offers2 = await repository.findMatchingOffers({
9583
+ const offers = await store.findMatchingOffers({
9978
9584
  side: params.side,
9979
9585
  chainId: params.chain_id,
9980
9586
  rate: params.rate,
@@ -9989,10 +9595,10 @@ async function serve(parameters) {
9989
9595
  limit: params.limit
9990
9596
  });
9991
9597
  return mempool.Mempool.success(c, {
9992
- data: offers2.offers.map(
9598
+ data: offers.offers.map(
9993
9599
  (offer) => mempool.Format.stringifyBigint(mempool.Format.toSnakeCase(toResponse(offer)))
9994
9600
  ),
9995
- cursor: offers2.nextCursor ?? null
9601
+ cursor: offers.nextCursor ?? null
9996
9602
  });
9997
9603
  } catch (err) {
9998
9604
  console.error(err);
@@ -10221,7 +9827,7 @@ function aoutput(out, instance) {
10221
9827
  function u32(arr) {
10222
9828
  return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
10223
9829
  }
10224
- function clean2(...arrays) {
9830
+ function clean(...arrays) {
10225
9831
  for (let i = 0; i < arrays.length; i++) {
10226
9832
  arrays[i].fill(0);
10227
9833
  }
@@ -10404,7 +10010,7 @@ var HashMD = class extends Hash {
10404
10010
  const { buffer, view, blockLen, isLE: isLE3 } = this;
10405
10011
  let { pos } = this;
10406
10012
  buffer[pos++] = 128;
10407
- clean2(this.buffer.subarray(pos));
10013
+ clean(this.buffer.subarray(pos));
10408
10014
  if (this.padOffset > blockLen - pos) {
10409
10015
  this.process(view, 0);
10410
10016
  pos = 0;
@@ -10612,11 +10218,11 @@ var SHA256 = class extends HashMD {
10612
10218
  this.set(A, B, C, D, E, F2, G, H);
10613
10219
  }
10614
10220
  roundClean() {
10615
- clean2(SHA256_W);
10221
+ clean(SHA256_W);
10616
10222
  }
10617
10223
  destroy() {
10618
10224
  this.set(0, 0, 0, 0, 0, 0, 0, 0);
10619
- clean2(this.buffer);
10225
+ clean(this.buffer);
10620
10226
  }
10621
10227
  };
10622
10228
  var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
@@ -10644,7 +10250,7 @@ var HMAC = class extends Hash {
10644
10250
  for (let i = 0; i < pad2.length; i++)
10645
10251
  pad2[i] ^= 54 ^ 92;
10646
10252
  this.oHash.update(pad2);
10647
- clean2(pad2);
10253
+ clean(pad2);
10648
10254
  }
10649
10255
  update(buf) {
10650
10256
  aexists(this);
@@ -12293,8 +11899,8 @@ function getHash(hash3) {
12293
11899
  };
12294
11900
  }
12295
11901
  function createCurve(curveDef, defHash) {
12296
- const create3 = (hash3) => weierstrass({ ...curveDef, ...getHash(hash3) });
12297
- return { ...create3(defHash), create: create3 };
11902
+ const create = (hash3) => weierstrass({ ...curveDef, ...getHash(hash3) });
11903
+ return { ...create(defHash), create };
12298
11904
  }
12299
11905
 
12300
11906
  // ../../node_modules/.pnpm/@noble+curves@1.9.0/node_modules/@noble/curves/esm/secp256k1.js
@@ -12581,11 +12187,11 @@ function concatBytes3(...arrays) {
12581
12187
  function utf8ToBytes2(utf) {
12582
12188
  return new TextEncoder().encode(utf);
12583
12189
  }
12584
- function numberToHex(integer2) {
12585
- if (integer2 < 0) {
12190
+ function numberToHex(integer) {
12191
+ if (integer < 0) {
12586
12192
  throw EthereumJSErrorWithoutCode("Invalid integer as argument, must be unsigned!");
12587
12193
  }
12588
- const hex = integer2.toString(16);
12194
+ const hex = integer.toString(16);
12589
12195
  return hex.length % 2 ? `0${hex}` : hex;
12590
12196
  }
12591
12197
  function padToEven(a) {
@@ -12965,7 +12571,7 @@ function keccakP(s, rounds = 24) {
12965
12571
  s[0] ^= SHA3_IOTA_H[round];
12966
12572
  s[1] ^= SHA3_IOTA_L[round];
12967
12573
  }
12968
- clean2(B);
12574
+ clean(B);
12969
12575
  }
12970
12576
  var Keccak = class _Keccak extends Hash {
12971
12577
  // NOTE: we accept arguments in bytes instead of bits here.
@@ -13061,7 +12667,7 @@ var Keccak = class _Keccak extends Hash {
13061
12667
  }
13062
12668
  destroy() {
13063
12669
  this.destroyed = true;
13064
- clean2(this.state);
12670
+ clean(this.state);
13065
12671
  }
13066
12672
  _cloneInto(to) {
13067
12673
  const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
@@ -13426,8 +13032,8 @@ function isEOACode7702AuthorizationList(input) {
13426
13032
 
13427
13033
  // ../../node_modules/.pnpm/@ethereumjs+util@10.0.0/node_modules/@ethereumjs/util/dist/esm/withdrawal.js
13428
13034
  function withdrawalToBytesArray(withdrawal) {
13429
- const { index: index2, validatorIndex, address, amount } = withdrawal;
13430
- const indexBytes = toType(index2, TypeOutput.BigInt) === BIGINT_02 ? new Uint8Array() : toType(index2, TypeOutput.Uint8Array);
13035
+ const { index, validatorIndex, address, amount } = withdrawal;
13036
+ const indexBytes = toType(index, TypeOutput.BigInt) === BIGINT_02 ? new Uint8Array() : toType(index, TypeOutput.Uint8Array);
13431
13037
  const validatorIndexBytes = toType(validatorIndex, TypeOutput.BigInt) === BIGINT_02 ? new Uint8Array() : toType(validatorIndex, TypeOutput.Uint8Array);
13432
13038
  const addressBytes = address instanceof Address ? address.bytes : toType(address, TypeOutput.Uint8Array);
13433
13039
  const amountBytes = toType(amount, TypeOutput.BigInt) === BIGINT_02 ? new Uint8Array() : toType(amount, TypeOutput.Uint8Array);
@@ -13439,8 +13045,8 @@ var Withdrawal = class {
13439
13045
  * Use the static factory methods to assist in creating a Withdrawal object from varying data types.
13440
13046
  * Its amount is in Gwei to match CL representation and for eventual ssz withdrawalsRoot
13441
13047
  */
13442
- constructor(index2, validatorIndex, address, amount) {
13443
- this.index = index2;
13048
+ constructor(index, validatorIndex, address, amount) {
13049
+ this.index = index;
13444
13050
  this.validatorIndex = validatorIndex;
13445
13051
  this.address = address;
13446
13052
  this.amount = amount;
@@ -13467,11 +13073,11 @@ var Withdrawal = class {
13467
13073
  };
13468
13074
  function createWithdrawal(withdrawalData) {
13469
13075
  const { index: indexData, validatorIndex: validatorIndexData, address: addressData, amount: amountData } = withdrawalData;
13470
- const index2 = toType(indexData, TypeOutput.BigInt);
13076
+ const index = toType(indexData, TypeOutput.BigInt);
13471
13077
  const validatorIndex = toType(validatorIndexData, TypeOutput.BigInt);
13472
13078
  const address = addressData instanceof Address ? addressData : new Address(toBytes3(addressData));
13473
13079
  const amount = toType(amountData, TypeOutput.BigInt);
13474
- return new Withdrawal(index2, validatorIndex, address, amount);
13080
+ return new Withdrawal(index, validatorIndex, address, amount);
13475
13081
  }
13476
13082
 
13477
13083
  // ../../node_modules/.pnpm/@ethereumjs+util@10.0.0/node_modules/@ethereumjs/util/dist/esm/signature.js
@@ -13880,8 +13486,8 @@ if (typeof Int32Array !== "undefined") {
13880
13486
  }
13881
13487
  var crc = (current, previous) => {
13882
13488
  let crc2 = 0 ^ -1;
13883
- for (let index2 = 0; index2 < current.length; index2++) {
13884
- crc2 = TABLE[(crc2 ^ current[index2]) & 255] ^ crc2 >>> 8;
13489
+ for (let index = 0; index < current.length; index++) {
13490
+ crc2 = TABLE[(crc2 ^ current[index]) & 255] ^ crc2 >>> 8;
13885
13491
  }
13886
13492
  return crc2 ^ -1;
13887
13493
  };
@@ -14714,15 +14320,15 @@ var Common = class {
14714
14320
  */
14715
14321
  getHardforkBy(opts) {
14716
14322
  const blockNumber = toType(opts.blockNumber, TypeOutput.BigInt);
14717
- const timestamp2 = toType(opts.timestamp, TypeOutput.BigInt);
14323
+ const timestamp = toType(opts.timestamp, TypeOutput.BigInt);
14718
14324
  const hfs = this.hardforks().filter((hf) => hf.block !== null || hf.timestamp !== void 0);
14719
- let hfIndex = hfs.findIndex((hf) => blockNumber !== void 0 && hf.block !== null && BigInt(hf.block) > blockNumber || timestamp2 !== void 0 && hf.timestamp !== void 0 && BigInt(hf.timestamp) > timestamp2);
14325
+ let hfIndex = hfs.findIndex((hf) => blockNumber !== void 0 && hf.block !== null && BigInt(hf.block) > blockNumber || timestamp !== void 0 && hf.timestamp !== void 0 && BigInt(hf.timestamp) > timestamp);
14720
14326
  if (hfIndex === -1) {
14721
14327
  hfIndex = hfs.length;
14722
14328
  } else if (hfIndex === 0) {
14723
14329
  throw Error("Must have at least one hardfork at block 0");
14724
14330
  }
14725
- if (timestamp2 === void 0) {
14331
+ if (timestamp === void 0) {
14726
14332
  const stepBack = hfs.slice(0, hfIndex).reverse().findIndex((hf) => hf.block !== null);
14727
14333
  hfIndex = hfIndex - stepBack;
14728
14334
  }
@@ -14733,13 +14339,13 @@ var Common = class {
14733
14339
  break;
14734
14340
  }
14735
14341
  }
14736
- if (timestamp2 !== void 0) {
14342
+ if (timestamp !== void 0) {
14737
14343
  const minTimeStamp = hfs.slice(0, hfStartIndex).reduce((acc, hf) => Math.max(Number(hf.timestamp ?? "0"), acc), 0);
14738
- if (minTimeStamp > timestamp2) {
14344
+ if (minTimeStamp > timestamp) {
14739
14345
  throw Error(`Maximum HF determined by timestamp is lower than the block number HF`);
14740
14346
  }
14741
- const maxTimeStamp = hfs.slice(hfIndex + 1).reduce((acc, hf) => Math.min(Number(hf.timestamp ?? timestamp2), acc), Number(timestamp2));
14742
- if (maxTimeStamp < timestamp2) {
14347
+ const maxTimeStamp = hfs.slice(hfIndex + 1).reduce((acc, hf) => Math.min(Number(hf.timestamp ?? timestamp), acc), Number(timestamp));
14348
+ if (maxTimeStamp < timestamp) {
14743
14349
  throw Error(`Maximum HF determined by block number is lower than timestamp HF`);
14744
14350
  }
14745
14351
  }
@@ -14910,8 +14516,8 @@ var Common = class {
14910
14516
  * @param blockNumber Block number
14911
14517
  * * @returns The value requested or `BigInt(0)` if not found
14912
14518
  */
14913
- paramByBlock(name, blockNumber, timestamp2) {
14914
- const hardfork = this.getHardforkBy({ blockNumber, timestamp: timestamp2 });
14519
+ paramByBlock(name, blockNumber, timestamp) {
14520
+ const hardfork = this.getHardforkBy({ blockNumber, timestamp });
14915
14521
  return this.paramByHardfork(name, hardfork);
14916
14522
  }
14917
14523
  /**
@@ -14963,13 +14569,13 @@ var Common = class {
14963
14569
  hardfork1 = hardfork1 ?? this._hardfork;
14964
14570
  const hardforks = this.hardforks();
14965
14571
  let posHf1 = -1, posHf2 = -1;
14966
- let index2 = 0;
14572
+ let index = 0;
14967
14573
  for (const hf of hardforks) {
14968
14574
  if (hf["name"] === hardfork1)
14969
- posHf1 = index2;
14575
+ posHf1 = index;
14970
14576
  if (hf["name"] === hardfork2)
14971
- posHf2 = index2;
14972
- index2 += 1;
14577
+ posHf2 = index;
14578
+ index += 1;
14973
14579
  }
14974
14580
  return posHf1 >= posHf2 && posHf2 !== -1;
14975
14581
  }
@@ -14996,11 +14602,11 @@ var Common = class {
14996
14602
  }
14997
14603
  hardforkTimestamp(hardfork) {
14998
14604
  hardfork = hardfork ?? this._hardfork;
14999
- const timestamp2 = this._getHardfork(hardfork)?.["timestamp"];
15000
- if (timestamp2 === void 0 || timestamp2 === null) {
14605
+ const timestamp = this._getHardfork(hardfork)?.["timestamp"];
14606
+ if (timestamp === void 0 || timestamp === null) {
15001
14607
  return null;
15002
14608
  }
15003
- return BigInt(timestamp2);
14609
+ return BigInt(timestamp);
15004
14610
  }
15005
14611
  /**
15006
14612
  * Returns the hardfork change block for eip
@@ -15075,8 +14681,8 @@ var Common = class {
15075
14681
  let hfBytes = new Uint8Array(0);
15076
14682
  let prevBlockOrTime = 0;
15077
14683
  for (const hf of this.hardforks()) {
15078
- const { block, timestamp: timestamp2, name } = hf;
15079
- let blockOrTime = timestamp2 ?? block;
14684
+ const { block, timestamp, name } = hf;
14685
+ let blockOrTime = timestamp ?? block;
15080
14686
  blockOrTime = blockOrTime !== null ? Number(blockOrTime) : null;
15081
14687
  if (typeof blockOrTime === "number" && blockOrTime !== 0 && blockOrTime !== prevBlockOrTime && name !== Hardfork.Paris) {
15082
14688
  const hfBlockBytes = hexToBytes5(`0x${blockOrTime.toString(16).padStart(16, "0")}`);
@@ -17291,9 +16897,9 @@ var handlers = /* @__PURE__ */ new Map([
17291
16897
  [
17292
16898
  73,
17293
16899
  function(runState) {
17294
- const index2 = runState.stack.pop();
17295
- if (runState.env.blobVersionedHashes.length > Number(index2)) {
17296
- runState.stack.push(BigInt(runState.env.blobVersionedHashes[Number(index2)]));
16900
+ const index = runState.stack.pop();
16901
+ if (runState.env.blobVersionedHashes.length > Number(index)) {
16902
+ runState.stack.push(BigInt(runState.env.blobVersionedHashes[Number(index)]));
17297
16903
  } else {
17298
16904
  runState.stack.push(BIGINT_02);
17299
16905
  }
@@ -19357,11 +18963,11 @@ var Stack = class {
19357
18963
  const peekArray = Array(num);
19358
18964
  let start = this._len;
19359
18965
  for (let peek = 0; peek < num; peek++) {
19360
- const index2 = --start;
19361
- if (index2 < 0) {
18966
+ const index = --start;
18967
+ if (index < 0) {
19362
18968
  throw new EVMError(EVMError.errorMessages.STACK_UNDERFLOW);
19363
18969
  }
19364
- peekArray[peek] = this._store[index2];
18970
+ peekArray[peek] = this._store[index];
19365
18971
  }
19366
18972
  return peekArray;
19367
18973
  }
@@ -24971,8 +24577,8 @@ var msmGasUsed = (numPairs, gasUsedPerPair, discountTable) => {
24971
24577
  return BigInt(numPairs) * gasUsedPerPair * BigInt(gasDiscountMultiplier) / BigInt(1e3);
24972
24578
  };
24973
24579
  var leading16ZeroBytesCheck = (opts, zeroByteRanges, pName, pairStart = 0) => {
24974
- for (const index2 in zeroByteRanges) {
24975
- const slicedBuffer = opts.data.subarray(zeroByteRanges[index2][0] + pairStart, zeroByteRanges[index2][1] + pairStart);
24580
+ for (const index in zeroByteRanges) {
24581
+ const slicedBuffer = opts.data.subarray(zeroByteRanges[index][0] + pairStart, zeroByteRanges[index][1] + pairStart);
24976
24582
  if (!(equalsBytes(slicedBuffer, ZERO_BYTES_16) === true)) {
24977
24583
  if (opts._debug !== void 0) {
24978
24584
  opts._debug(`${pName} failed: Point not on curve`);
@@ -25390,11 +24996,11 @@ var RIPEMD160 = class extends HashMD {
25390
24996
  this.set(this.h1 + cl + dr | 0, this.h2 + dl + er | 0, this.h3 + el + ar | 0, this.h4 + al + br | 0, this.h0 + bl + cr | 0);
25391
24997
  }
25392
24998
  roundClean() {
25393
- clean2(BUF_160);
24999
+ clean(BUF_160);
25394
25000
  }
25395
25001
  destroy() {
25396
25002
  this.destroyed = true;
25397
- clean2(this.buffer);
25003
+ clean(this.buffer);
25398
25004
  this.set(0, 0, 0, 0, 0);
25399
25005
  }
25400
25006
  };
@@ -28757,11 +28363,11 @@ var LRUCache = class _LRUCache {
28757
28363
  free: c.#free,
28758
28364
  // methods
28759
28365
  isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
28760
- backgroundFetch: (k, index2, options, context) => c.#backgroundFetch(k, index2, options, context),
28761
- moveToTail: (index2) => c.#moveToTail(index2),
28366
+ backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
28367
+ moveToTail: (index) => c.#moveToTail(index),
28762
28368
  indexes: (options) => c.#indexes(options),
28763
28369
  rindexes: (options) => c.#rindexes(options),
28764
- isStale: (index2) => c.#isStale(index2)
28370
+ isStale: (index) => c.#isStale(index)
28765
28371
  };
28766
28372
  }
28767
28373
  // Protected read-only members
@@ -28916,13 +28522,13 @@ var LRUCache = class _LRUCache {
28916
28522
  const starts = new ZeroArray(this.#max);
28917
28523
  this.#ttls = ttls;
28918
28524
  this.#starts = starts;
28919
- this.#setItemTTL = (index2, ttl, start = perf.now()) => {
28920
- starts[index2] = ttl !== 0 ? start : 0;
28921
- ttls[index2] = ttl;
28525
+ this.#setItemTTL = (index, ttl, start = perf.now()) => {
28526
+ starts[index] = ttl !== 0 ? start : 0;
28527
+ ttls[index] = ttl;
28922
28528
  if (ttl !== 0 && this.ttlAutopurge) {
28923
28529
  const t = setTimeout(() => {
28924
- if (this.#isStale(index2)) {
28925
- this.#delete(this.#keyList[index2], "expire");
28530
+ if (this.#isStale(index)) {
28531
+ this.#delete(this.#keyList[index], "expire");
28926
28532
  }
28927
28533
  }, ttl + 1);
28928
28534
  if (t.unref) {
@@ -28930,13 +28536,13 @@ var LRUCache = class _LRUCache {
28930
28536
  }
28931
28537
  }
28932
28538
  };
28933
- this.#updateItemAge = (index2) => {
28934
- starts[index2] = ttls[index2] !== 0 ? perf.now() : 0;
28539
+ this.#updateItemAge = (index) => {
28540
+ starts[index] = ttls[index] !== 0 ? perf.now() : 0;
28935
28541
  };
28936
- this.#statusTTL = (status, index2) => {
28937
- if (ttls[index2]) {
28938
- const ttl = ttls[index2];
28939
- const start = starts[index2];
28542
+ this.#statusTTL = (status, index) => {
28543
+ if (ttls[index]) {
28544
+ const ttl = ttls[index];
28545
+ const start = starts[index];
28940
28546
  if (!ttl || !start)
28941
28547
  return;
28942
28548
  status.ttl = ttl;
@@ -28959,21 +28565,21 @@ var LRUCache = class _LRUCache {
28959
28565
  return n;
28960
28566
  };
28961
28567
  this.getRemainingTTL = (key) => {
28962
- const index2 = this.#keyMap.get(key);
28963
- if (index2 === void 0) {
28568
+ const index = this.#keyMap.get(key);
28569
+ if (index === void 0) {
28964
28570
  return 0;
28965
28571
  }
28966
- const ttl = ttls[index2];
28967
- const start = starts[index2];
28572
+ const ttl = ttls[index];
28573
+ const start = starts[index];
28968
28574
  if (!ttl || !start) {
28969
28575
  return Infinity;
28970
28576
  }
28971
28577
  const age = (cachedNow || getNow()) - start;
28972
28578
  return ttl - age;
28973
28579
  };
28974
- this.#isStale = (index2) => {
28975
- const s = starts[index2];
28976
- const t = ttls[index2];
28580
+ this.#isStale = (index) => {
28581
+ const s = starts[index];
28582
+ const t = ttls[index];
28977
28583
  return !!t && !!s && (cachedNow || getNow()) - s > t;
28978
28584
  };
28979
28585
  }
@@ -28990,9 +28596,9 @@ var LRUCache = class _LRUCache {
28990
28596
  const sizes = new ZeroArray(this.#max);
28991
28597
  this.#calculatedSize = 0;
28992
28598
  this.#sizes = sizes;
28993
- this.#removeItemSize = (index2) => {
28994
- this.#calculatedSize -= sizes[index2];
28995
- sizes[index2] = 0;
28599
+ this.#removeItemSize = (index) => {
28600
+ this.#calculatedSize -= sizes[index];
28601
+ sizes[index] = 0;
28996
28602
  };
28997
28603
  this.#requireSize = (k, v, size, sizeCalculation) => {
28998
28604
  if (this.#isBackgroundFetch(v)) {
@@ -29013,15 +28619,15 @@ var LRUCache = class _LRUCache {
29013
28619
  }
29014
28620
  return size;
29015
28621
  };
29016
- this.#addItemSize = (index2, size, status) => {
29017
- sizes[index2] = size;
28622
+ this.#addItemSize = (index, size, status) => {
28623
+ sizes[index] = size;
29018
28624
  if (this.#maxSize) {
29019
- const maxSize2 = this.#maxSize - sizes[index2];
28625
+ const maxSize2 = this.#maxSize - sizes[index];
29020
28626
  while (this.#calculatedSize > maxSize2) {
29021
28627
  this.#evict(true);
29022
28628
  }
29023
28629
  }
29024
- this.#calculatedSize += sizes[index2];
28630
+ this.#calculatedSize += sizes[index];
29025
28631
  if (status) {
29026
28632
  status.entrySize = size;
29027
28633
  status.totalCalculatedSize = this.#calculatedSize;
@@ -29072,8 +28678,8 @@ var LRUCache = class _LRUCache {
29072
28678
  }
29073
28679
  }
29074
28680
  }
29075
- #isValidIndex(index2) {
29076
- return index2 !== void 0 && this.#keyMap.get(this.#keyList[index2]) === index2;
28681
+ #isValidIndex(index) {
28682
+ return index !== void 0 && this.#keyMap.get(this.#keyList[index]) === index;
29077
28683
  }
29078
28684
  /**
29079
28685
  * Return a generator yielding `[key, value]` pairs,
@@ -29360,23 +28966,23 @@ var LRUCache = class _LRUCache {
29360
28966
  this.#delete(k, "set");
29361
28967
  return this;
29362
28968
  }
29363
- let index2 = this.#size === 0 ? void 0 : this.#keyMap.get(k);
29364
- if (index2 === void 0) {
29365
- index2 = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
29366
- this.#keyList[index2] = k;
29367
- this.#valList[index2] = v;
29368
- this.#keyMap.set(k, index2);
29369
- this.#next[this.#tail] = index2;
29370
- this.#prev[index2] = this.#tail;
29371
- this.#tail = index2;
28969
+ let index = this.#size === 0 ? void 0 : this.#keyMap.get(k);
28970
+ if (index === void 0) {
28971
+ index = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
28972
+ this.#keyList[index] = k;
28973
+ this.#valList[index] = v;
28974
+ this.#keyMap.set(k, index);
28975
+ this.#next[this.#tail] = index;
28976
+ this.#prev[index] = this.#tail;
28977
+ this.#tail = index;
29372
28978
  this.#size++;
29373
- this.#addItemSize(index2, size, status);
28979
+ this.#addItemSize(index, size, status);
29374
28980
  if (status)
29375
28981
  status.set = "add";
29376
28982
  noUpdateTTL = false;
29377
28983
  } else {
29378
- this.#moveToTail(index2);
29379
- const oldVal = this.#valList[index2];
28984
+ this.#moveToTail(index);
28985
+ const oldVal = this.#valList[index];
29380
28986
  if (v !== oldVal) {
29381
28987
  if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
29382
28988
  oldVal.__abortController.abort(new Error("replaced"));
@@ -29397,9 +29003,9 @@ var LRUCache = class _LRUCache {
29397
29003
  this.#disposed?.push([oldVal, k, "set"]);
29398
29004
  }
29399
29005
  }
29400
- this.#removeItemSize(index2);
29401
- this.#addItemSize(index2, size, status);
29402
- this.#valList[index2] = v;
29006
+ this.#removeItemSize(index);
29007
+ this.#addItemSize(index, size, status);
29008
+ this.#valList[index] = v;
29403
29009
  if (status) {
29404
29010
  status.set = "replace";
29405
29011
  const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
@@ -29415,10 +29021,10 @@ var LRUCache = class _LRUCache {
29415
29021
  }
29416
29022
  if (this.#ttls) {
29417
29023
  if (!noUpdateTTL) {
29418
- this.#setItemTTL(index2, ttl, start);
29024
+ this.#setItemTTL(index, ttl, start);
29419
29025
  }
29420
29026
  if (status)
29421
- this.#statusTTL(status, index2);
29027
+ this.#statusTTL(status, index);
29422
29028
  }
29423
29029
  if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
29424
29030
  const dt = this.#disposed;
@@ -29504,24 +29110,24 @@ var LRUCache = class _LRUCache {
29504
29110
  */
29505
29111
  has(k, hasOptions = {}) {
29506
29112
  const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
29507
- const index2 = this.#keyMap.get(k);
29508
- if (index2 !== void 0) {
29509
- const v = this.#valList[index2];
29113
+ const index = this.#keyMap.get(k);
29114
+ if (index !== void 0) {
29115
+ const v = this.#valList[index];
29510
29116
  if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === void 0) {
29511
29117
  return false;
29512
29118
  }
29513
- if (!this.#isStale(index2)) {
29119
+ if (!this.#isStale(index)) {
29514
29120
  if (updateAgeOnHas) {
29515
- this.#updateItemAge(index2);
29121
+ this.#updateItemAge(index);
29516
29122
  }
29517
29123
  if (status) {
29518
29124
  status.has = "hit";
29519
- this.#statusTTL(status, index2);
29125
+ this.#statusTTL(status, index);
29520
29126
  }
29521
29127
  return true;
29522
29128
  } else if (status) {
29523
29129
  status.has = "stale";
29524
- this.#statusTTL(status, index2);
29130
+ this.#statusTTL(status, index);
29525
29131
  }
29526
29132
  } else if (status) {
29527
29133
  status.has = "miss";
@@ -29537,15 +29143,15 @@ var LRUCache = class _LRUCache {
29537
29143
  */
29538
29144
  peek(k, peekOptions = {}) {
29539
29145
  const { allowStale = this.allowStale } = peekOptions;
29540
- const index2 = this.#keyMap.get(k);
29541
- if (index2 === void 0 || !allowStale && this.#isStale(index2)) {
29146
+ const index = this.#keyMap.get(k);
29147
+ if (index === void 0 || !allowStale && this.#isStale(index)) {
29542
29148
  return;
29543
29149
  }
29544
- const v = this.#valList[index2];
29150
+ const v = this.#valList[index];
29545
29151
  return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
29546
29152
  }
29547
- #backgroundFetch(k, index2, options, context) {
29548
- const v = index2 === void 0 ? void 0 : this.#valList[index2];
29153
+ #backgroundFetch(k, index, options, context) {
29154
+ const v = index === void 0 ? void 0 : this.#valList[index];
29549
29155
  if (this.#isBackgroundFetch(v)) {
29550
29156
  return v;
29551
29157
  }
@@ -29576,10 +29182,10 @@ var LRUCache = class _LRUCache {
29576
29182
  return fetchFail(ac.signal.reason);
29577
29183
  }
29578
29184
  const bf2 = p;
29579
- if (this.#valList[index2] === p) {
29185
+ if (this.#valList[index] === p) {
29580
29186
  if (v2 === void 0) {
29581
29187
  if (bf2.__staleWhileFetching) {
29582
- this.#valList[index2] = bf2.__staleWhileFetching;
29188
+ this.#valList[index] = bf2.__staleWhileFetching;
29583
29189
  } else {
29584
29190
  this.#delete(k, "fetch");
29585
29191
  }
@@ -29604,12 +29210,12 @@ var LRUCache = class _LRUCache {
29604
29210
  const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
29605
29211
  const noDelete = allowStale || options.noDeleteOnFetchRejection;
29606
29212
  const bf2 = p;
29607
- if (this.#valList[index2] === p) {
29213
+ if (this.#valList[index] === p) {
29608
29214
  const del = !noDelete || bf2.__staleWhileFetching === void 0;
29609
29215
  if (del) {
29610
29216
  this.#delete(k, "fetch");
29611
29217
  } else if (!allowStaleAborted) {
29612
- this.#valList[index2] = bf2.__staleWhileFetching;
29218
+ this.#valList[index] = bf2.__staleWhileFetching;
29613
29219
  }
29614
29220
  }
29615
29221
  if (allowStale) {
@@ -29643,11 +29249,11 @@ var LRUCache = class _LRUCache {
29643
29249
  __staleWhileFetching: v,
29644
29250
  __returned: void 0
29645
29251
  });
29646
- if (index2 === void 0) {
29252
+ if (index === void 0) {
29647
29253
  this.set(k, bf, { ...fetchOpts.options, status: void 0 });
29648
- index2 = this.#keyMap.get(k);
29254
+ index = this.#keyMap.get(k);
29649
29255
  } else {
29650
- this.#valList[index2] = bf;
29256
+ this.#valList[index] = bf;
29651
29257
  }
29652
29258
  return bf;
29653
29259
  }
@@ -29705,14 +29311,14 @@ var LRUCache = class _LRUCache {
29705
29311
  status,
29706
29312
  signal
29707
29313
  };
29708
- let index2 = this.#keyMap.get(k);
29709
- if (index2 === void 0) {
29314
+ let index = this.#keyMap.get(k);
29315
+ if (index === void 0) {
29710
29316
  if (status)
29711
29317
  status.fetch = "miss";
29712
- const p = this.#backgroundFetch(k, index2, options, context);
29318
+ const p = this.#backgroundFetch(k, index, options, context);
29713
29319
  return p.__returned = p;
29714
29320
  } else {
29715
- const v = this.#valList[index2];
29321
+ const v = this.#valList[index];
29716
29322
  if (this.#isBackgroundFetch(v)) {
29717
29323
  const stale = allowStale && v.__staleWhileFetching !== void 0;
29718
29324
  if (status) {
@@ -29722,19 +29328,19 @@ var LRUCache = class _LRUCache {
29722
29328
  }
29723
29329
  return stale ? v.__staleWhileFetching : v.__returned = v;
29724
29330
  }
29725
- const isStale = this.#isStale(index2);
29331
+ const isStale = this.#isStale(index);
29726
29332
  if (!forceRefresh && !isStale) {
29727
29333
  if (status)
29728
29334
  status.fetch = "hit";
29729
- this.#moveToTail(index2);
29335
+ this.#moveToTail(index);
29730
29336
  if (updateAgeOnGet) {
29731
- this.#updateItemAge(index2);
29337
+ this.#updateItemAge(index);
29732
29338
  }
29733
29339
  if (status)
29734
- this.#statusTTL(status, index2);
29340
+ this.#statusTTL(status, index);
29735
29341
  return v;
29736
29342
  }
29737
- const p = this.#backgroundFetch(k, index2, options, context);
29343
+ const p = this.#backgroundFetch(k, index, options, context);
29738
29344
  const hasStale = p.__staleWhileFetching !== void 0;
29739
29345
  const staleVal = hasStale && allowStale;
29740
29346
  if (status) {
@@ -29775,13 +29381,13 @@ var LRUCache = class _LRUCache {
29775
29381
  */
29776
29382
  get(k, getOptions = {}) {
29777
29383
  const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
29778
- const index2 = this.#keyMap.get(k);
29779
- if (index2 !== void 0) {
29780
- const value = this.#valList[index2];
29384
+ const index = this.#keyMap.get(k);
29385
+ if (index !== void 0) {
29386
+ const value = this.#valList[index];
29781
29387
  const fetching = this.#isBackgroundFetch(value);
29782
29388
  if (status)
29783
- this.#statusTTL(status, index2);
29784
- if (this.#isStale(index2)) {
29389
+ this.#statusTTL(status, index);
29390
+ if (this.#isStale(index)) {
29785
29391
  if (status)
29786
29392
  status.get = "stale";
29787
29393
  if (!fetching) {
@@ -29803,9 +29409,9 @@ var LRUCache = class _LRUCache {
29803
29409
  if (fetching) {
29804
29410
  return value.__staleWhileFetching;
29805
29411
  }
29806
- this.#moveToTail(index2);
29412
+ this.#moveToTail(index);
29807
29413
  if (updateAgeOnGet) {
29808
- this.#updateItemAge(index2);
29414
+ this.#updateItemAge(index);
29809
29415
  }
29810
29416
  return value;
29811
29417
  }
@@ -29817,15 +29423,15 @@ var LRUCache = class _LRUCache {
29817
29423
  this.#prev[n] = p;
29818
29424
  this.#next[p] = n;
29819
29425
  }
29820
- #moveToTail(index2) {
29821
- if (index2 !== this.#tail) {
29822
- if (index2 === this.#head) {
29823
- this.#head = this.#next[index2];
29426
+ #moveToTail(index) {
29427
+ if (index !== this.#tail) {
29428
+ if (index === this.#head) {
29429
+ this.#head = this.#next[index];
29824
29430
  } else {
29825
- this.#connect(this.#prev[index2], this.#next[index2]);
29431
+ this.#connect(this.#prev[index], this.#next[index]);
29826
29432
  }
29827
- this.#connect(this.#tail, index2);
29828
- this.#tail = index2;
29433
+ this.#connect(this.#tail, index);
29434
+ this.#tail = index;
29829
29435
  }
29830
29436
  }
29831
29437
  /**
@@ -29839,14 +29445,14 @@ var LRUCache = class _LRUCache {
29839
29445
  #delete(k, reason) {
29840
29446
  let deleted = false;
29841
29447
  if (this.#size !== 0) {
29842
- const index2 = this.#keyMap.get(k);
29843
- if (index2 !== void 0) {
29448
+ const index = this.#keyMap.get(k);
29449
+ if (index !== void 0) {
29844
29450
  deleted = true;
29845
29451
  if (this.#size === 1) {
29846
29452
  this.#clear(reason);
29847
29453
  } else {
29848
- this.#removeItemSize(index2);
29849
- const v = this.#valList[index2];
29454
+ this.#removeItemSize(index);
29455
+ const v = this.#valList[index];
29850
29456
  if (this.#isBackgroundFetch(v)) {
29851
29457
  v.__abortController.abort(new Error("deleted"));
29852
29458
  } else if (this.#hasDispose || this.#hasDisposeAfter) {
@@ -29858,20 +29464,20 @@ var LRUCache = class _LRUCache {
29858
29464
  }
29859
29465
  }
29860
29466
  this.#keyMap.delete(k);
29861
- this.#keyList[index2] = void 0;
29862
- this.#valList[index2] = void 0;
29863
- if (index2 === this.#tail) {
29864
- this.#tail = this.#prev[index2];
29865
- } else if (index2 === this.#head) {
29866
- this.#head = this.#next[index2];
29467
+ this.#keyList[index] = void 0;
29468
+ this.#valList[index] = void 0;
29469
+ if (index === this.#tail) {
29470
+ this.#tail = this.#prev[index];
29471
+ } else if (index === this.#head) {
29472
+ this.#head = this.#next[index];
29867
29473
  } else {
29868
- const pi = this.#prev[index2];
29869
- this.#next[pi] = this.#next[index2];
29870
- const ni = this.#next[index2];
29871
- this.#prev[ni] = this.#prev[index2];
29474
+ const pi = this.#prev[index];
29475
+ this.#next[pi] = this.#next[index];
29476
+ const ni = this.#next[index];
29477
+ this.#prev[ni] = this.#prev[index];
29872
29478
  }
29873
29479
  this.#size--;
29874
- this.#free.push(index2);
29480
+ this.#free.push(index);
29875
29481
  }
29876
29482
  }
29877
29483
  }
@@ -29891,12 +29497,12 @@ var LRUCache = class _LRUCache {
29891
29497
  return this.#clear("delete");
29892
29498
  }
29893
29499
  #clear(reason) {
29894
- for (const index2 of this.#rindexes({ allowStale: true })) {
29895
- const v = this.#valList[index2];
29500
+ for (const index of this.#rindexes({ allowStale: true })) {
29501
+ const v = this.#valList[index];
29896
29502
  if (this.#isBackgroundFetch(v)) {
29897
29503
  v.__abortController.abort(new Error("deleted"));
29898
29504
  } else {
29899
- const k = this.#keyList[index2];
29505
+ const k = this.#keyList[index];
29900
29506
  if (this.#hasDispose) {
29901
29507
  this.#dispose?.(v, k, reason);
29902
29508
  }
@@ -36661,9 +36267,9 @@ function sign(tx, privateKey, extraEntropy = true) {
36661
36267
  const { recovery, r, s } = ecSignFunction(msgHash, privateKey, { extraEntropy });
36662
36268
  const signedTx = tx.addSignature(BigInt(recovery), r, s, true);
36663
36269
  if (hackApplied) {
36664
- const index2 = tx["activeCapabilities"].indexOf(Capability.EIP155ReplayProtection);
36665
- if (index2 > -1) {
36666
- tx["activeCapabilities"].splice(index2, 1);
36270
+ const index = tx["activeCapabilities"].indexOf(Capability.EIP155ReplayProtection);
36271
+ if (index > -1) {
36272
+ tx["activeCapabilities"].splice(index, 1);
36667
36273
  }
36668
36274
  }
36669
36275
  return signedTx;
@@ -38620,7 +38226,7 @@ var BlockHeader = class {
38620
38226
  const number2 = toType(headerData.number, TypeOutput.BigInt) ?? defaults2.number;
38621
38227
  const gasLimit = toType(headerData.gasLimit, TypeOutput.BigInt) ?? defaults2.gasLimit;
38622
38228
  const gasUsed = toType(headerData.gasUsed, TypeOutput.BigInt) ?? defaults2.gasUsed;
38623
- const timestamp2 = toType(headerData.timestamp, TypeOutput.BigInt) ?? defaults2.timestamp;
38229
+ const timestamp = toType(headerData.timestamp, TypeOutput.BigInt) ?? defaults2.timestamp;
38624
38230
  const extraData = toType(headerData.extraData, TypeOutput.Uint8Array) ?? defaults2.extraData;
38625
38231
  const mixHash = toType(headerData.mixHash, TypeOutput.Uint8Array) ?? defaults2.mixHash;
38626
38232
  const nonce = toType(headerData.nonce, TypeOutput.Uint8Array) ?? defaults2.nonce;
@@ -38628,7 +38234,7 @@ var BlockHeader = class {
38628
38234
  if (setHardfork === true) {
38629
38235
  this.common.setHardforkBy({
38630
38236
  blockNumber: number2,
38631
- timestamp: timestamp2
38237
+ timestamp
38632
38238
  });
38633
38239
  }
38634
38240
  const hardforkDefaults = {
@@ -38678,7 +38284,7 @@ var BlockHeader = class {
38678
38284
  this.number = number2;
38679
38285
  this.gasLimit = gasLimit;
38680
38286
  this.gasUsed = gasUsed;
38681
- this.timestamp = timestamp2;
38287
+ this.timestamp = timestamp;
38682
38288
  this.extraData = extraData;
38683
38289
  this.mixHash = mixHash;
38684
38290
  this.nonce = nonce;
@@ -39613,8 +39219,8 @@ var hmac2 = (hash3, key, message) => new HMAC2(hash3, key).update(message).diges
39613
39219
  hmac2.create = (hash3, key) => new HMAC2(hash3, key);
39614
39220
 
39615
39221
  // ../../node_modules/.pnpm/@noble+curves@1.4.2/node_modules/@noble/curves/esm/abstract/utils.js
39616
- var utils_exports = {};
39617
- __export(utils_exports, {
39222
+ var utils_exports2 = {};
39223
+ __export(utils_exports2, {
39618
39224
  abytes: () => abytes4,
39619
39225
  bitGet: () => bitGet2,
39620
39226
  bitLen: () => bitLen3,
@@ -40256,7 +39862,7 @@ function validatePointOpts2(curve) {
40256
39862
  }
40257
39863
  return Object.freeze({ ...opts });
40258
39864
  }
40259
- var { bytesToNumberBE: b2n, hexToBytes: h2b } = utils_exports;
39865
+ var { bytesToNumberBE: b2n, hexToBytes: h2b } = utils_exports2;
40260
39866
  var DER3 = {
40261
39867
  // asn.1 DER encoding utils
40262
39868
  Err: class DERErr3 extends Error {
@@ -41036,8 +40642,8 @@ function getHash2(hash3) {
41036
40642
  };
41037
40643
  }
41038
40644
  function createCurve2(curveDef, defHash) {
41039
- const create3 = (hash3) => weierstrass3({ ...curveDef, ...getHash2(hash3) });
41040
- return Object.freeze({ ...create3(defHash), create: create3 });
40645
+ const create = (hash3) => weierstrass3({ ...curveDef, ...getHash2(hash3) });
40646
+ return Object.freeze({ ...create(defHash), create });
41041
40647
  }
41042
40648
 
41043
40649
  // ../../node_modules/.pnpm/@noble+curves@1.4.2/node_modules/@noble/curves/esm/secp256k1.js
@@ -41481,11 +41087,11 @@ function concatBytes8(...arrays) {
41481
41087
  function utf8ToBytes5(utf) {
41482
41088
  return new TextEncoder().encode(utf);
41483
41089
  }
41484
- function numberToHex4(integer2) {
41485
- if (integer2 < 0) {
41090
+ function numberToHex4(integer) {
41091
+ if (integer < 0) {
41486
41092
  throw new Error("Invalid integer as argument, must be unsigned!");
41487
41093
  }
41488
- const hex = integer2.toString(16);
41094
+ const hex = integer.toString(16);
41489
41095
  return hex.length % 2 ? `0${hex}` : hex;
41490
41096
  }
41491
41097
  function padToEven4(a) {
@@ -42044,11 +41650,11 @@ var LRUCache2 = class _LRUCache {
42044
41650
  free: c.#free,
42045
41651
  // methods
42046
41652
  isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
42047
- backgroundFetch: (k, index2, options, context) => c.#backgroundFetch(k, index2, options, context),
42048
- moveToTail: (index2) => c.#moveToTail(index2),
41653
+ backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
41654
+ moveToTail: (index) => c.#moveToTail(index),
42049
41655
  indexes: (options) => c.#indexes(options),
42050
41656
  rindexes: (options) => c.#rindexes(options),
42051
- isStale: (index2) => c.#isStale(index2)
41657
+ isStale: (index) => c.#isStale(index)
42052
41658
  };
42053
41659
  }
42054
41660
  // Protected read-only members
@@ -42195,13 +41801,13 @@ var LRUCache2 = class _LRUCache {
42195
41801
  const starts = new ZeroArray2(this.#max);
42196
41802
  this.#ttls = ttls;
42197
41803
  this.#starts = starts;
42198
- this.#setItemTTL = (index2, ttl, start = perf2.now()) => {
42199
- starts[index2] = ttl !== 0 ? start : 0;
42200
- ttls[index2] = ttl;
41804
+ this.#setItemTTL = (index, ttl, start = perf2.now()) => {
41805
+ starts[index] = ttl !== 0 ? start : 0;
41806
+ ttls[index] = ttl;
42201
41807
  if (ttl !== 0 && this.ttlAutopurge) {
42202
41808
  const t = setTimeout(() => {
42203
- if (this.#isStale(index2)) {
42204
- this.delete(this.#keyList[index2]);
41809
+ if (this.#isStale(index)) {
41810
+ this.delete(this.#keyList[index]);
42205
41811
  }
42206
41812
  }, ttl + 1);
42207
41813
  if (t.unref) {
@@ -42209,13 +41815,13 @@ var LRUCache2 = class _LRUCache {
42209
41815
  }
42210
41816
  }
42211
41817
  };
42212
- this.#updateItemAge = (index2) => {
42213
- starts[index2] = ttls[index2] !== 0 ? perf2.now() : 0;
41818
+ this.#updateItemAge = (index) => {
41819
+ starts[index] = ttls[index] !== 0 ? perf2.now() : 0;
42214
41820
  };
42215
- this.#statusTTL = (status, index2) => {
42216
- if (ttls[index2]) {
42217
- const ttl = ttls[index2];
42218
- const start = starts[index2];
41821
+ this.#statusTTL = (status, index) => {
41822
+ if (ttls[index]) {
41823
+ const ttl = ttls[index];
41824
+ const start = starts[index];
42219
41825
  if (!ttl || !start)
42220
41826
  return;
42221
41827
  status.ttl = ttl;
@@ -42238,21 +41844,21 @@ var LRUCache2 = class _LRUCache {
42238
41844
  return n;
42239
41845
  };
42240
41846
  this.getRemainingTTL = (key) => {
42241
- const index2 = this.#keyMap.get(key);
42242
- if (index2 === void 0) {
41847
+ const index = this.#keyMap.get(key);
41848
+ if (index === void 0) {
42243
41849
  return 0;
42244
41850
  }
42245
- const ttl = ttls[index2];
42246
- const start = starts[index2];
41851
+ const ttl = ttls[index];
41852
+ const start = starts[index];
42247
41853
  if (!ttl || !start) {
42248
41854
  return Infinity;
42249
41855
  }
42250
41856
  const age = (cachedNow || getNow()) - start;
42251
41857
  return ttl - age;
42252
41858
  };
42253
- this.#isStale = (index2) => {
42254
- const s = starts[index2];
42255
- const t = ttls[index2];
41859
+ this.#isStale = (index) => {
41860
+ const s = starts[index];
41861
+ const t = ttls[index];
42256
41862
  return !!t && !!s && (cachedNow || getNow()) - s > t;
42257
41863
  };
42258
41864
  }
@@ -42269,9 +41875,9 @@ var LRUCache2 = class _LRUCache {
42269
41875
  const sizes = new ZeroArray2(this.#max);
42270
41876
  this.#calculatedSize = 0;
42271
41877
  this.#sizes = sizes;
42272
- this.#removeItemSize = (index2) => {
42273
- this.#calculatedSize -= sizes[index2];
42274
- sizes[index2] = 0;
41878
+ this.#removeItemSize = (index) => {
41879
+ this.#calculatedSize -= sizes[index];
41880
+ sizes[index] = 0;
42275
41881
  };
42276
41882
  this.#requireSize = (k, v, size, sizeCalculation) => {
42277
41883
  if (this.#isBackgroundFetch(v)) {
@@ -42292,15 +41898,15 @@ var LRUCache2 = class _LRUCache {
42292
41898
  }
42293
41899
  return size;
42294
41900
  };
42295
- this.#addItemSize = (index2, size, status) => {
42296
- sizes[index2] = size;
41901
+ this.#addItemSize = (index, size, status) => {
41902
+ sizes[index] = size;
42297
41903
  if (this.#maxSize) {
42298
- const maxSize2 = this.#maxSize - sizes[index2];
41904
+ const maxSize2 = this.#maxSize - sizes[index];
42299
41905
  while (this.#calculatedSize > maxSize2) {
42300
41906
  this.#evict(true);
42301
41907
  }
42302
41908
  }
42303
- this.#calculatedSize += sizes[index2];
41909
+ this.#calculatedSize += sizes[index];
42304
41910
  if (status) {
42305
41911
  status.entrySize = size;
42306
41912
  status.totalCalculatedSize = this.#calculatedSize;
@@ -42351,8 +41957,8 @@ var LRUCache2 = class _LRUCache {
42351
41957
  }
42352
41958
  }
42353
41959
  }
42354
- #isValidIndex(index2) {
42355
- return index2 !== void 0 && this.#keyMap.get(this.#keyList[index2]) === index2;
41960
+ #isValidIndex(index) {
41961
+ return index !== void 0 && this.#keyMap.get(this.#keyList[index]) === index;
42356
41962
  }
42357
41963
  /**
42358
41964
  * Return a generator yielding `[key, value]` pairs,
@@ -42585,23 +42191,23 @@ var LRUCache2 = class _LRUCache {
42585
42191
  this.delete(k);
42586
42192
  return this;
42587
42193
  }
42588
- let index2 = this.#size === 0 ? void 0 : this.#keyMap.get(k);
42589
- if (index2 === void 0) {
42590
- index2 = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
42591
- this.#keyList[index2] = k;
42592
- this.#valList[index2] = v;
42593
- this.#keyMap.set(k, index2);
42594
- this.#next[this.#tail] = index2;
42595
- this.#prev[index2] = this.#tail;
42596
- this.#tail = index2;
42194
+ let index = this.#size === 0 ? void 0 : this.#keyMap.get(k);
42195
+ if (index === void 0) {
42196
+ index = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
42197
+ this.#keyList[index] = k;
42198
+ this.#valList[index] = v;
42199
+ this.#keyMap.set(k, index);
42200
+ this.#next[this.#tail] = index;
42201
+ this.#prev[index] = this.#tail;
42202
+ this.#tail = index;
42597
42203
  this.#size++;
42598
- this.#addItemSize(index2, size, status);
42204
+ this.#addItemSize(index, size, status);
42599
42205
  if (status)
42600
42206
  status.set = "add";
42601
42207
  noUpdateTTL = false;
42602
42208
  } else {
42603
- this.#moveToTail(index2);
42604
- const oldVal = this.#valList[index2];
42209
+ this.#moveToTail(index);
42210
+ const oldVal = this.#valList[index];
42605
42211
  if (v !== oldVal) {
42606
42212
  if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
42607
42213
  oldVal.__abortController.abort(new Error("replaced"));
@@ -42622,9 +42228,9 @@ var LRUCache2 = class _LRUCache {
42622
42228
  this.#disposed?.push([oldVal, k, "set"]);
42623
42229
  }
42624
42230
  }
42625
- this.#removeItemSize(index2);
42626
- this.#addItemSize(index2, size, status);
42627
- this.#valList[index2] = v;
42231
+ this.#removeItemSize(index);
42232
+ this.#addItemSize(index, size, status);
42233
+ this.#valList[index] = v;
42628
42234
  if (status) {
42629
42235
  status.set = "replace";
42630
42236
  const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
@@ -42640,10 +42246,10 @@ var LRUCache2 = class _LRUCache {
42640
42246
  }
42641
42247
  if (this.#ttls) {
42642
42248
  if (!noUpdateTTL) {
42643
- this.#setItemTTL(index2, ttl, start);
42249
+ this.#setItemTTL(index, ttl, start);
42644
42250
  }
42645
42251
  if (status)
42646
- this.#statusTTL(status, index2);
42252
+ this.#statusTTL(status, index);
42647
42253
  }
42648
42254
  if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
42649
42255
  const dt = this.#disposed;
@@ -42721,24 +42327,24 @@ var LRUCache2 = class _LRUCache {
42721
42327
  */
42722
42328
  has(k, hasOptions = {}) {
42723
42329
  const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
42724
- const index2 = this.#keyMap.get(k);
42725
- if (index2 !== void 0) {
42726
- const v = this.#valList[index2];
42330
+ const index = this.#keyMap.get(k);
42331
+ if (index !== void 0) {
42332
+ const v = this.#valList[index];
42727
42333
  if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === void 0) {
42728
42334
  return false;
42729
42335
  }
42730
- if (!this.#isStale(index2)) {
42336
+ if (!this.#isStale(index)) {
42731
42337
  if (updateAgeOnHas) {
42732
- this.#updateItemAge(index2);
42338
+ this.#updateItemAge(index);
42733
42339
  }
42734
42340
  if (status) {
42735
42341
  status.has = "hit";
42736
- this.#statusTTL(status, index2);
42342
+ this.#statusTTL(status, index);
42737
42343
  }
42738
42344
  return true;
42739
42345
  } else if (status) {
42740
42346
  status.has = "stale";
42741
- this.#statusTTL(status, index2);
42347
+ this.#statusTTL(status, index);
42742
42348
  }
42743
42349
  } else if (status) {
42744
42350
  status.has = "miss";
@@ -42754,15 +42360,15 @@ var LRUCache2 = class _LRUCache {
42754
42360
  */
42755
42361
  peek(k, peekOptions = {}) {
42756
42362
  const { allowStale = this.allowStale } = peekOptions;
42757
- const index2 = this.#keyMap.get(k);
42758
- if (index2 === void 0 || !allowStale && this.#isStale(index2)) {
42363
+ const index = this.#keyMap.get(k);
42364
+ if (index === void 0 || !allowStale && this.#isStale(index)) {
42759
42365
  return;
42760
42366
  }
42761
- const v = this.#valList[index2];
42367
+ const v = this.#valList[index];
42762
42368
  return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
42763
42369
  }
42764
- #backgroundFetch(k, index2, options, context) {
42765
- const v = index2 === void 0 ? void 0 : this.#valList[index2];
42370
+ #backgroundFetch(k, index, options, context) {
42371
+ const v = index === void 0 ? void 0 : this.#valList[index];
42766
42372
  if (this.#isBackgroundFetch(v)) {
42767
42373
  return v;
42768
42374
  }
@@ -42793,10 +42399,10 @@ var LRUCache2 = class _LRUCache {
42793
42399
  return fetchFail(ac.signal.reason);
42794
42400
  }
42795
42401
  const bf2 = p;
42796
- if (this.#valList[index2] === p) {
42402
+ if (this.#valList[index] === p) {
42797
42403
  if (v2 === void 0) {
42798
42404
  if (bf2.__staleWhileFetching) {
42799
- this.#valList[index2] = bf2.__staleWhileFetching;
42405
+ this.#valList[index] = bf2.__staleWhileFetching;
42800
42406
  } else {
42801
42407
  this.delete(k);
42802
42408
  }
@@ -42821,12 +42427,12 @@ var LRUCache2 = class _LRUCache {
42821
42427
  const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
42822
42428
  const noDelete = allowStale || options.noDeleteOnFetchRejection;
42823
42429
  const bf2 = p;
42824
- if (this.#valList[index2] === p) {
42430
+ if (this.#valList[index] === p) {
42825
42431
  const del = !noDelete || bf2.__staleWhileFetching === void 0;
42826
42432
  if (del) {
42827
42433
  this.delete(k);
42828
42434
  } else if (!allowStaleAborted) {
42829
- this.#valList[index2] = bf2.__staleWhileFetching;
42435
+ this.#valList[index] = bf2.__staleWhileFetching;
42830
42436
  }
42831
42437
  }
42832
42438
  if (allowStale) {
@@ -42860,11 +42466,11 @@ var LRUCache2 = class _LRUCache {
42860
42466
  __staleWhileFetching: v,
42861
42467
  __returned: void 0
42862
42468
  });
42863
- if (index2 === void 0) {
42469
+ if (index === void 0) {
42864
42470
  this.set(k, bf, { ...fetchOpts.options, status: void 0 });
42865
- index2 = this.#keyMap.get(k);
42471
+ index = this.#keyMap.get(k);
42866
42472
  } else {
42867
- this.#valList[index2] = bf;
42473
+ this.#valList[index] = bf;
42868
42474
  }
42869
42475
  return bf;
42870
42476
  }
@@ -42922,14 +42528,14 @@ var LRUCache2 = class _LRUCache {
42922
42528
  status,
42923
42529
  signal
42924
42530
  };
42925
- let index2 = this.#keyMap.get(k);
42926
- if (index2 === void 0) {
42531
+ let index = this.#keyMap.get(k);
42532
+ if (index === void 0) {
42927
42533
  if (status)
42928
42534
  status.fetch = "miss";
42929
- const p = this.#backgroundFetch(k, index2, options, context);
42535
+ const p = this.#backgroundFetch(k, index, options, context);
42930
42536
  return p.__returned = p;
42931
42537
  } else {
42932
- const v = this.#valList[index2];
42538
+ const v = this.#valList[index];
42933
42539
  if (this.#isBackgroundFetch(v)) {
42934
42540
  const stale = allowStale && v.__staleWhileFetching !== void 0;
42935
42541
  if (status) {
@@ -42939,19 +42545,19 @@ var LRUCache2 = class _LRUCache {
42939
42545
  }
42940
42546
  return stale ? v.__staleWhileFetching : v.__returned = v;
42941
42547
  }
42942
- const isStale = this.#isStale(index2);
42548
+ const isStale = this.#isStale(index);
42943
42549
  if (!forceRefresh && !isStale) {
42944
42550
  if (status)
42945
42551
  status.fetch = "hit";
42946
- this.#moveToTail(index2);
42552
+ this.#moveToTail(index);
42947
42553
  if (updateAgeOnGet) {
42948
- this.#updateItemAge(index2);
42554
+ this.#updateItemAge(index);
42949
42555
  }
42950
42556
  if (status)
42951
- this.#statusTTL(status, index2);
42557
+ this.#statusTTL(status, index);
42952
42558
  return v;
42953
42559
  }
42954
- const p = this.#backgroundFetch(k, index2, options, context);
42560
+ const p = this.#backgroundFetch(k, index, options, context);
42955
42561
  const hasStale = p.__staleWhileFetching !== void 0;
42956
42562
  const staleVal = hasStale && allowStale;
42957
42563
  if (status) {
@@ -42970,13 +42576,13 @@ var LRUCache2 = class _LRUCache {
42970
42576
  */
42971
42577
  get(k, getOptions = {}) {
42972
42578
  const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
42973
- const index2 = this.#keyMap.get(k);
42974
- if (index2 !== void 0) {
42975
- const value = this.#valList[index2];
42579
+ const index = this.#keyMap.get(k);
42580
+ if (index !== void 0) {
42581
+ const value = this.#valList[index];
42976
42582
  const fetching = this.#isBackgroundFetch(value);
42977
42583
  if (status)
42978
- this.#statusTTL(status, index2);
42979
- if (this.#isStale(index2)) {
42584
+ this.#statusTTL(status, index);
42585
+ if (this.#isStale(index)) {
42980
42586
  if (status)
42981
42587
  status.get = "stale";
42982
42588
  if (!fetching) {
@@ -42998,9 +42604,9 @@ var LRUCache2 = class _LRUCache {
42998
42604
  if (fetching) {
42999
42605
  return value.__staleWhileFetching;
43000
42606
  }
43001
- this.#moveToTail(index2);
42607
+ this.#moveToTail(index);
43002
42608
  if (updateAgeOnGet) {
43003
- this.#updateItemAge(index2);
42609
+ this.#updateItemAge(index);
43004
42610
  }
43005
42611
  return value;
43006
42612
  }
@@ -43012,15 +42618,15 @@ var LRUCache2 = class _LRUCache {
43012
42618
  this.#prev[n] = p;
43013
42619
  this.#next[p] = n;
43014
42620
  }
43015
- #moveToTail(index2) {
43016
- if (index2 !== this.#tail) {
43017
- if (index2 === this.#head) {
43018
- this.#head = this.#next[index2];
42621
+ #moveToTail(index) {
42622
+ if (index !== this.#tail) {
42623
+ if (index === this.#head) {
42624
+ this.#head = this.#next[index];
43019
42625
  } else {
43020
- this.#connect(this.#prev[index2], this.#next[index2]);
42626
+ this.#connect(this.#prev[index], this.#next[index]);
43021
42627
  }
43022
- this.#connect(this.#tail, index2);
43023
- this.#tail = index2;
42628
+ this.#connect(this.#tail, index);
42629
+ this.#tail = index;
43024
42630
  }
43025
42631
  }
43026
42632
  /**
@@ -43030,14 +42636,14 @@ var LRUCache2 = class _LRUCache {
43030
42636
  delete(k) {
43031
42637
  let deleted = false;
43032
42638
  if (this.#size !== 0) {
43033
- const index2 = this.#keyMap.get(k);
43034
- if (index2 !== void 0) {
42639
+ const index = this.#keyMap.get(k);
42640
+ if (index !== void 0) {
43035
42641
  deleted = true;
43036
42642
  if (this.#size === 1) {
43037
42643
  this.clear();
43038
42644
  } else {
43039
- this.#removeItemSize(index2);
43040
- const v = this.#valList[index2];
42645
+ this.#removeItemSize(index);
42646
+ const v = this.#valList[index];
43041
42647
  if (this.#isBackgroundFetch(v)) {
43042
42648
  v.__abortController.abort(new Error("deleted"));
43043
42649
  } else if (this.#hasDispose || this.#hasDisposeAfter) {
@@ -43049,20 +42655,20 @@ var LRUCache2 = class _LRUCache {
43049
42655
  }
43050
42656
  }
43051
42657
  this.#keyMap.delete(k);
43052
- this.#keyList[index2] = void 0;
43053
- this.#valList[index2] = void 0;
43054
- if (index2 === this.#tail) {
43055
- this.#tail = this.#prev[index2];
43056
- } else if (index2 === this.#head) {
43057
- this.#head = this.#next[index2];
42658
+ this.#keyList[index] = void 0;
42659
+ this.#valList[index] = void 0;
42660
+ if (index === this.#tail) {
42661
+ this.#tail = this.#prev[index];
42662
+ } else if (index === this.#head) {
42663
+ this.#head = this.#next[index];
43058
42664
  } else {
43059
- const pi = this.#prev[index2];
43060
- this.#next[pi] = this.#next[index2];
43061
- const ni = this.#next[index2];
43062
- this.#prev[ni] = this.#prev[index2];
42665
+ const pi = this.#prev[index];
42666
+ this.#next[pi] = this.#next[index];
42667
+ const ni = this.#next[index];
42668
+ this.#prev[ni] = this.#prev[index];
43063
42669
  }
43064
42670
  this.#size--;
43065
- this.#free.push(index2);
42671
+ this.#free.push(index);
43066
42672
  }
43067
42673
  }
43068
42674
  }
@@ -43079,12 +42685,12 @@ var LRUCache2 = class _LRUCache {
43079
42685
  * Clear the cache entirely, throwing away all values.
43080
42686
  */
43081
42687
  clear() {
43082
- for (const index2 of this.#rindexes({ allowStale: true })) {
43083
- const v = this.#valList[index2];
42688
+ for (const index of this.#rindexes({ allowStale: true })) {
42689
+ const v = this.#valList[index];
43084
42690
  if (this.#isBackgroundFetch(v)) {
43085
42691
  v.__abortController.abort(new Error("deleted"));
43086
42692
  } else {
43087
- const k = this.#keyList[index2];
42693
+ const k = this.#keyList[index];
43088
42694
  if (this.#hasDispose) {
43089
42695
  this.#dispose?.(v, k, "delete");
43090
42696
  }
@@ -43222,9 +42828,9 @@ var CheckpointDB4 = class _CheckpointDB {
43222
42828
  return value2;
43223
42829
  }
43224
42830
  }
43225
- for (let index2 = this.checkpoints.length - 1; index2 >= 0; index2--) {
43226
- if (this.checkpoints[index2].keyValueMap.has(keyHex)) {
43227
- return this.checkpoints[index2].keyValueMap.get(keyHex);
42831
+ for (let index = this.checkpoints.length - 1; index >= 0; index--) {
42832
+ if (this.checkpoints[index].keyValueMap.has(keyHex)) {
42833
+ return this.checkpoints[index].keyValueMap.get(keyHex);
43228
42834
  }
43229
42835
  }
43230
42836
  const value = await this.db.get(keyHex, {
@@ -45296,7 +44902,7 @@ function valuesArrayToHeaderData2(values) {
45296
44902
  number2,
45297
44903
  gasLimit,
45298
44904
  gasUsed,
45299
- timestamp2,
44905
+ timestamp,
45300
44906
  extraData,
45301
44907
  mixHash,
45302
44908
  nonce,
@@ -45325,7 +44931,7 @@ function valuesArrayToHeaderData2(values) {
45325
44931
  ...number2 !== void 0 ? { number: number2 } : {},
45326
44932
  ...gasLimit !== void 0 ? { gasLimit } : {},
45327
44933
  ...gasUsed !== void 0 ? { gasUsed } : {},
45328
- ...timestamp2 !== void 0 ? { timestamp: timestamp2 } : {},
44934
+ ...timestamp !== void 0 ? { timestamp } : {},
45329
44935
  ...extraData !== void 0 ? { extraData } : {},
45330
44936
  ...mixHash !== void 0 ? { mixHash } : {},
45331
44937
  ...nonce !== void 0 ? { nonce } : {},
@@ -45486,7 +45092,7 @@ var BlockHeader2 = class _BlockHeader {
45486
45092
  const number2 = safeToType(headerData.number, 1) ?? defaults2.number;
45487
45093
  const gasLimit = safeToType(headerData.gasLimit, 1) ?? defaults2.gasLimit;
45488
45094
  const gasUsed = safeToType(headerData.gasUsed, 1) ?? defaults2.gasUsed;
45489
- const timestamp2 = safeToType(headerData.timestamp, 1) ?? defaults2.timestamp;
45095
+ const timestamp = safeToType(headerData.timestamp, 1) ?? defaults2.timestamp;
45490
45096
  const extraData = safeToType(headerData.extraData, 2) ?? defaults2.extraData;
45491
45097
  const mixHash = safeToType(headerData.mixHash, 2) ?? defaults2.mixHash;
45492
45098
  const nonce = safeToType(headerData.nonce, 2) ?? defaults2.nonce;
@@ -45494,12 +45100,12 @@ var BlockHeader2 = class _BlockHeader {
45494
45100
  if (setHardfork === true) {
45495
45101
  this.common.ethjsCommon.setHardforkBy({
45496
45102
  blockNumber: number2,
45497
- timestamp: timestamp2
45103
+ timestamp
45498
45104
  });
45499
45105
  } else if (typeof setHardfork !== "boolean") {
45500
45106
  this.common.ethjsCommon.setHardforkBy({
45501
45107
  blockNumber: number2,
45502
- timestamp: timestamp2
45108
+ timestamp
45503
45109
  });
45504
45110
  }
45505
45111
  const hardforkDefaults = {
@@ -45547,7 +45153,7 @@ var BlockHeader2 = class _BlockHeader {
45547
45153
  this.number = number2;
45548
45154
  this.gasLimit = gasLimit;
45549
45155
  this.gasUsed = gasUsed;
45550
- this.timestamp = timestamp2;
45156
+ this.timestamp = timestamp;
45551
45157
  this.extraData = extraData;
45552
45158
  this.mixHash = mixHash;
45553
45159
  this.nonce = nonce;
@@ -46310,8 +45916,8 @@ var Block2 = class _Block {
46310
45916
  for (const uncleHeaderData of uhsData ?? []) {
46311
45917
  uncleHeaders.push(BlockHeader2.fromValuesArray(uncleHeaderData, uncleOpts));
46312
45918
  }
46313
- const withdrawals = withdrawalBytes?.map(([index2, validatorIndex, address, amount]) => ({
46314
- index: index2,
45919
+ const withdrawals = withdrawalBytes?.map(([index, validatorIndex, address, amount]) => ({
45920
+ index,
46315
45921
  validatorIndex,
46316
45922
  address,
46317
45923
  amount
@@ -46350,14 +45956,14 @@ var Block2 = class _Block {
46350
45956
  executionWitness
46351
45957
  } = payload;
46352
45958
  const txs = [];
46353
- for (const [index2, serializedTx] of transactions.entries()) {
45959
+ for (const [index, serializedTx] of transactions.entries()) {
46354
45960
  try {
46355
45961
  const tx = createTxFromRLP(utils.hexToBytes(serializedTx), {
46356
45962
  common: opts?.common.ethjsCommon
46357
45963
  });
46358
45964
  txs.push(tx);
46359
45965
  } catch (error) {
46360
- const validationError2 = `Invalid tx at index ${index2}: ${error}`;
45966
+ const validationError2 = `Invalid tx at index ${index}: ${error}`;
46361
45967
  throw validationError2;
46362
45968
  }
46363
45969
  }
@@ -46607,9 +46213,9 @@ var Block2 = class _Block {
46607
46213
  return;
46608
46214
  }
46609
46215
  if (verifyTxs) {
46610
- for (const [index2, tx] of this.transactions.entries()) {
46216
+ for (const [index, tx] of this.transactions.entries()) {
46611
46217
  if (!tx.isSigned()) {
46612
- const msg = this._errorMsg(`invalid transactions: transaction at index ${index2} is unsigned`);
46218
+ const msg = this._errorMsg(`invalid transactions: transaction at index ${index} is unsigned`);
46613
46219
  throw new Error(msg);
46614
46220
  }
46615
46221
  }
@@ -46835,7 +46441,7 @@ function blockHeaderFromRpc(blockParams, options) {
46835
46441
  number: number2,
46836
46442
  gasLimit,
46837
46443
  gasUsed,
46838
- timestamp: timestamp2,
46444
+ timestamp,
46839
46445
  extraData,
46840
46446
  mixHash,
46841
46447
  nonce,
@@ -46859,7 +46465,7 @@ function blockHeaderFromRpc(blockParams, options) {
46859
46465
  number: number2,
46860
46466
  gasLimit,
46861
46467
  gasUsed,
46862
- timestamp: timestamp2,
46468
+ timestamp,
46863
46469
  extraData,
46864
46470
  mixHash,
46865
46471
  nonce,
@@ -47422,11 +47028,11 @@ var Evm = class _Evm extends EVM {
47422
47028
  "Custom precompiles is empty. This is an internal bug as it should always be defined"
47423
47029
  );
47424
47030
  }
47425
- const index2 = this._customPrecompiles.indexOf(precompile);
47426
- if (index2 === -1) {
47031
+ const index = this._customPrecompiles.indexOf(precompile);
47032
+ if (index === -1) {
47427
47033
  throw new InvalidParamsError("Precompile not found");
47428
47034
  }
47429
- this._customPrecompiles.splice(index2, 1);
47035
+ this._customPrecompiles.splice(index, 1);
47430
47036
  this._precompiles = getActivePrecompiles(this.common, this._customPrecompiles);
47431
47037
  }
47432
47038
  /**
@@ -47681,8 +47287,8 @@ var ReceiptsManager = class _ReceiptsManager {
47681
47287
  const block = value;
47682
47288
  if (operation === 0) {
47683
47289
  for (const [i, tx] of block.transactions.entries()) {
47684
- const index2 = [block.hash(), i];
47685
- const encoded = this.rlp(0, 2, index2);
47290
+ const index = [block.hash(), i];
47291
+ const encoded = this.rlp(0, 2, index);
47686
47292
  await this.mapDb.put("TxHash", tx.hash(), encoded);
47687
47293
  }
47688
47294
  } else if (operation === 1) {
@@ -49369,12 +48975,12 @@ createBlockHeader();
49369
48975
 
49370
48976
  // ../../node_modules/.pnpm/@tevm+vm@1.0.0-next.147_typescript@5.8.3_viem@2.33.1_typescript@5.8.3_zod@3.25.67__zod@3.25.67/node_modules/@tevm/vm/dist/index.js
49371
48977
  var parentBeaconBlockRootAddress2 = createAddressFromString("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02");
49372
- var accumulateParentBeaconBlockRoot2 = (vm) => async (root2, timestamp2) => {
48978
+ var accumulateParentBeaconBlockRoot2 = (vm) => async (root2, timestamp) => {
49373
48979
  if (!vm.common.ethjsCommon.isActivatedEIP(4788)) {
49374
48980
  throw new EipNotEnabledError("Cannot call `accumulateParentBeaconBlockRoot`: EIP 4788 is not active");
49375
48981
  }
49376
48982
  const historicalRootsLength = 8191n;
49377
- const timestampIndex = timestamp2 % historicalRootsLength;
48983
+ const timestampIndex = timestamp % historicalRootsLength;
49378
48984
  const timestampExtended = timestampIndex + historicalRootsLength;
49379
48985
  if (await vm.stateManager.getAccount(parentBeaconBlockRootAddress2) === void 0) {
49380
48986
  await vm.evm.journal.putAccount(parentBeaconBlockRootAddress2, new Account());
@@ -49382,7 +48988,7 @@ var accumulateParentBeaconBlockRoot2 = (vm) => async (root2, timestamp2) => {
49382
48988
  await vm.stateManager.putStorage(
49383
48989
  parentBeaconBlockRootAddress2,
49384
48990
  setLengthLeft(utils.toBytes(timestampIndex), 32),
49385
- utils.toBytes(timestamp2)
48991
+ utils.toBytes(timestamp)
49386
48992
  );
49387
48993
  await vm.stateManager.putStorage(parentBeaconBlockRootAddress2, setLengthLeft(utils.toBytes(timestampExtended), 32), root2);
49388
48994
  };
@@ -50431,7 +50037,7 @@ var BlockBuilder2 = class {
50431
50037
  const receiptTrie = await this.receiptTrie();
50432
50038
  const logsBloom = this.logsBloom();
50433
50039
  const gasUsed = this.gasUsed;
50434
- const timestamp2 = this.headerData.timestamp ?? 0n;
50040
+ const timestamp = this.headerData.timestamp ?? 0n;
50435
50041
  let blobGasUsed = void 0;
50436
50042
  if (this.vm.common.ethjsCommon.isActivatedEIP(4844) === true) {
50437
50043
  blobGasUsed = this.blobGasUsed;
@@ -50445,7 +50051,7 @@ var BlockBuilder2 = class {
50445
50051
  receiptTrie,
50446
50052
  logsBloom,
50447
50053
  gasUsed,
50448
- timestamp: timestamp2
50054
+ timestamp
50449
50055
  // correct excessBlobGas should already be part of headerData used above
50450
50056
  };
50451
50057
  if (consensusType === ConsensusType.ProofOfWork) {
@@ -50474,8 +50080,8 @@ var BlockBuilder2 = class {
50474
50080
  await this.vm.evm.journal.checkpoint();
50475
50081
  this.checkpointed = true;
50476
50082
  }
50477
- const { parentBeaconBlockRoot, timestamp: timestamp2 } = this.headerData;
50478
- const timestampValue = timestamp2 ?? 0n;
50083
+ const { parentBeaconBlockRoot, timestamp } = this.headerData;
50084
+ const timestampValue = timestamp ?? 0n;
50479
50085
  const timestampBigInt = toType(timestampValue, TypeOutput.BigInt) ?? 0n;
50480
50086
  const parentBeaconBlockRootBuf = parentBeaconBlockRoot ? toType(parentBeaconBlockRoot, TypeOutput.Uint8Array) : new Uint8Array(32);
50481
50087
  await accumulateParentBeaconBlockRoot2(this.vm)(
@@ -50883,9 +50489,9 @@ var createTevmNode = (options = {}) => {
50883
50489
  removeListener(eventName, listener) {
50884
50490
  const listeners = events.get(eventName);
50885
50491
  if (listeners) {
50886
- const index2 = listeners.findIndex((l) => l === listener);
50887
- if (index2 !== -1) {
50888
- listeners.splice(index2, 1);
50492
+ const index = listeners.findIndex((l) => l === listener);
50493
+ if (index !== -1) {
50494
+ listeners.splice(index, 1);
50889
50495
  if (listeners.length === 0) {
50890
50496
  events.delete(eventName);
50891
50497
  }
@@ -51717,12 +51323,12 @@ var mineHandler = (client, options = {}) => async ({ throwOnFail = options.throw
51717
51323
  const receiptsManager = await client.getReceiptsManager();
51718
51324
  for (let count = 0; count < blockCount; count++) {
51719
51325
  const parentBlock = await vm.blockchain.getCanonicalHeadBlock();
51720
- let timestamp2 = Math.max(Math.floor(Date.now() / 1e3), Number(parentBlock.header.timestamp));
51721
- timestamp2 = count === 0 ? timestamp2 : timestamp2 + interval;
51326
+ let timestamp = Math.max(Math.floor(Date.now() / 1e3), Number(parentBlock.header.timestamp));
51327
+ timestamp = count === 0 ? timestamp : timestamp + interval;
51722
51328
  const blockBuilder = await vm.buildBlock({
51723
51329
  parentBlock,
51724
51330
  headerData: {
51725
- timestamp: timestamp2,
51331
+ timestamp,
51726
51332
  number: parentBlock.header.number + 1n,
51727
51333
  // The following 2 are currently not supported
51728
51334
  // difficulty: undefined,
@@ -51751,13 +51357,13 @@ var mineHandler = (client, options = {}) => async ({ throwOnFail = options.throw
51751
51357
  ] : await pool.txsByPriceAndNonce({
51752
51358
  baseFee: parentBlock.header.calcNextBaseFee()
51753
51359
  });
51754
- let index2 = 0;
51360
+ let index = 0;
51755
51361
  const blockFull = false;
51756
51362
  const receipts = [];
51757
- while (index2 < orderedTx.length && !blockFull) {
51363
+ while (index < orderedTx.length && !blockFull) {
51758
51364
  const nextTx = (
51759
51365
  /** @type {import('@tevm/tx').TypedTransaction}*/
51760
- orderedTx[index2]
51366
+ orderedTx[index]
51761
51367
  );
51762
51368
  client.logger.debug(utils.bytesToHex(nextTx.hash()), "new tx added");
51763
51369
  const txResult = await blockBuilder.addTransaction(nextTx, {
@@ -51766,7 +51372,7 @@ var mineHandler = (client, options = {}) => async ({ throwOnFail = options.throw
51766
51372
  skipHardForkValidation: true
51767
51373
  });
51768
51374
  receipts.push(txResult.receipt);
51769
- index2++;
51375
+ index++;
51770
51376
  }
51771
51377
  await vm.stateManager.checkpoint();
51772
51378
  const createNewStateRoot = true;
@@ -57547,9 +57153,6 @@ function getLogger() {
57547
57153
  return loggerContext.getStore() ?? defaultLogger();
57548
57154
  }
57549
57155
 
57550
- // src/index.node.ts
57551
- __reExport(index_node_exports, OfferDB_exports2);
57552
-
57553
57156
  // src/RouterEvent.ts
57554
57157
  var RouterEvent_exports = {};
57555
57158
  __export(RouterEvent_exports, {
@@ -57675,14 +57278,14 @@ function morpho(parameters) {
57675
57278
  );
57676
57279
  const buyOffersEmptyCallback = batch2(
57677
57280
  "buy_offers_empty_callback",
57678
- async (offers2, { publicClients }) => {
57281
+ async (offers, { publicClients }) => {
57679
57282
  const issues = /* @__PURE__ */ new Map();
57680
57283
  const hashToIndex = /* @__PURE__ */ new Map();
57681
- for (let i = 0; i < offers2.length; i++) {
57682
- const offer = offers2[i];
57284
+ for (let i = 0; i < offers.length; i++) {
57285
+ const offer = offers[i];
57683
57286
  hashToIndex.set(offer.hash, i);
57684
57287
  }
57685
- const { buyOffers, sellOffers: _sellOffers } = offers2.reduce(
57288
+ const { buyOffers, sellOffers: _sellOffers } = offers.reduce(
57686
57289
  (acc, offer) => {
57687
57290
  offer.buy ? acc.buyOffers.push(offer) : issues.set(hashToIndex.get(offer.hash), {
57688
57291
  message: "Onchain callback for sell offers is not supported yet."
@@ -57695,9 +57298,9 @@ function morpho(parameters) {
57695
57298
  for (const offer of buyOffers) {
57696
57299
  const chainName = getChain(offer.chainId)?.name;
57697
57300
  const loanTokens = buyOffersPerLoanAsset.get(chainName) ?? /* @__PURE__ */ new Map();
57698
- const offers3 = loanTokens.get(offer.loanToken.toLowerCase()) ?? [];
57699
- offers3.push(offer);
57700
- loanTokens.set(offer.loanToken.toLowerCase(), offers3);
57301
+ const offers2 = loanTokens.get(offer.loanToken.toLowerCase()) ?? [];
57302
+ offers2.push(offer);
57303
+ loanTokens.set(offer.loanToken.toLowerCase(), offers2);
57701
57304
  buyOffersPerLoanAsset.set(chainName, loanTokens);
57702
57305
  }
57703
57306
  await Promise.all(
@@ -57706,8 +57309,8 @@ function morpho(parameters) {
57706
57309
  const publicClient = publicClients[chainName];
57707
57310
  const morpho2 = morphoPerChain.get(chains[chainName].id);
57708
57311
  if (!publicClient) {
57709
- const offers3 = Array.from(loanTokens.values()).flat();
57710
- for (const offer of offers3) {
57312
+ const offers2 = Array.from(loanTokens.values()).flat();
57313
+ for (const offer of offers2) {
57711
57314
  issues.set(hashToIndex.get(offer.hash), {
57712
57315
  message: `Public client for chain "${chainName}" is not available`
57713
57316
  });
@@ -57716,9 +57319,9 @@ function morpho(parameters) {
57716
57319
  }
57717
57320
  const balances = /* @__PURE__ */ new Map();
57718
57321
  const allowances = /* @__PURE__ */ new Map();
57719
- for (const [loanToken2, offers3] of loanTokens) {
57322
+ for (const [loanToken2, offers2] of loanTokens) {
57720
57323
  const data = await Promise.all(
57721
- offers3.flatMap((offer) => [
57324
+ offers2.flatMap((offer) => [
57722
57325
  publicClient.readContract({
57723
57326
  address: loanToken2,
57724
57327
  abi: viem.parseAbi([
@@ -57737,8 +57340,8 @@ function morpho(parameters) {
57737
57340
  })
57738
57341
  ])
57739
57342
  );
57740
- for (let i = 0; i < offers3.length; i++) {
57741
- const user = offers3[i].offering.toLowerCase();
57343
+ for (let i = 0; i < offers2.length; i++) {
57344
+ const user = offers2[i].offering.toLowerCase();
57742
57345
  const balance = data[i * 2] || 0n;
57743
57346
  const allowance = data[i * 2 + 1] || 0n;
57744
57347
  const userBalances = balances.get(user) ?? /* @__PURE__ */ new Map();
@@ -57819,23 +57422,13 @@ exports.ApiSchema = apiSchema_exports;
57819
57422
  exports.Chain = Chain_exports;
57820
57423
  exports.EVM = EVM_exports;
57821
57424
  exports.Logger = Logger_exports;
57822
- exports.OfferDB = OfferDB_exports;
57823
- exports.OfferRepository = OfferRepository_exports;
57824
- exports.Router = core_exports;
57425
+ exports.OfferStore = OfferStore_exports;
57426
+ exports.Router = router_exports;
57825
57427
  exports.RouterEvent = RouterEvent_exports;
57826
57428
  exports.RouterOffer = RouterOffer_exports;
57429
+ exports.Utils = utils_exports;
57827
57430
  exports.Validation = Validation_exports;
57828
57431
  exports.ValidationRule = ValidationRule_exports;
57829
- exports.batch = batch;
57830
- exports.consumed = consumed;
57831
- exports.decodeCursor = decodeCursor;
57832
- exports.encodeCursor = encodeCursor;
57833
- exports.offerCollaterals = offerCollaterals;
57834
- exports.offerStatus = offerStatus;
57835
- exports.offers = offers;
57836
- exports.poll = poll;
57837
- exports.validateCursor = validateCursor;
57838
- exports.wait = wait;
57839
57432
  Object.keys(mempool).forEach(function (k) {
57840
57433
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
57841
57434
  enumerable: true,