@morpho-dev/router 0.0.13 → 0.0.15

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.
@@ -4,6 +4,7 @@ var mempool = require('@morpho-dev/mempool');
4
4
  var chains$1 = require('viem/chains');
5
5
  var v4 = require('zod/v4');
6
6
  var zodOpenapi = require('zod-openapi');
7
+ var viem = require('viem');
7
8
  var nodeServer = require('@hono/node-server');
8
9
  var hono = require('hono');
9
10
  var drizzle_orm_star = require('drizzle-orm');
@@ -17,7 +18,6 @@ var pg = require('pg');
17
18
  var pgCore = require('drizzle-orm/pg-core');
18
19
  var blueSdkViem = require('@morpho-org/blue-sdk-viem');
19
20
  var fs = require('fs');
20
- var viem = require('viem');
21
21
  var nc = require('crypto');
22
22
  var accounts = require('viem/accounts');
23
23
  var utils = require('viem/utils');
@@ -68,11 +68,11 @@ var __export = (target, all) => {
68
68
  for (var name in all)
69
69
  __defProp(target, name, { get: all[name], enumerable: true });
70
70
  };
71
- var __copyProps = (to, from, except, desc3) => {
72
- if (from && typeof from === "object" || typeof from === "function") {
73
- for (let key of __getOwnPropNames(from))
71
+ var __copyProps = (to, from2, except, desc3) => {
72
+ if (from2 && typeof from2 === "object" || typeof from2 === "function") {
73
+ for (let key of __getOwnPropNames(from2))
74
74
  if (!__hasOwnProp.call(to, key) && key !== except)
75
- __defProp(to, key, { get: () => from[key], enumerable: !(desc3 = __getOwnPropDesc(from, key)) || desc3.enumerable });
75
+ __defProp(to, key, { get: () => from2[key], enumerable: !(desc3 = __getOwnPropDesc(from2, key)) || desc3.enumerable });
76
76
  }
77
77
  return to;
78
78
  };
@@ -7012,7 +7012,7 @@ var require_from = __commonJS({
7012
7012
  return (hint === "string" ? String : Number)(input);
7013
7013
  }
7014
7014
  var ERR_INVALID_ARG_TYPE = require_errors().codes.ERR_INVALID_ARG_TYPE;
7015
- function from(Readable2, iterable, opts) {
7015
+ function from2(Readable2, iterable, opts) {
7016
7016
  var iterator;
7017
7017
  if (iterable && typeof iterable.next === "function") {
7018
7018
  iterator = iterable;
@@ -7051,7 +7051,7 @@ var require_from = __commonJS({
7051
7051
  }
7052
7052
  return readable;
7053
7053
  }
7054
- module2.exports = from;
7054
+ module2.exports = from2;
7055
7055
  }
7056
7056
  });
7057
7057
 
@@ -7094,7 +7094,7 @@ var require_stream_readable = __commonJS({
7094
7094
  var ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
7095
7095
  var StringDecoder;
7096
7096
  var createReadableStreamAsyncIterator;
7097
- var from;
7097
+ var from2;
7098
7098
  require_inherits()(Readable2, Stream);
7099
7099
  var errorOrDestroy = destroyImpl.errorOrDestroy;
7100
7100
  var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
@@ -7772,10 +7772,10 @@ var require_stream_readable = __commonJS({
7772
7772
  }
7773
7773
  if (typeof Symbol === "function") {
7774
7774
  Readable2.from = function(iterable, opts) {
7775
- if (from === void 0) {
7776
- from = require_from();
7775
+ if (from2 === void 0) {
7776
+ from2 = require_from();
7777
7777
  }
7778
- return from(Readable2, iterable, opts);
7778
+ return from2(Readable2, iterable, opts);
7779
7779
  };
7780
7780
  }
7781
7781
  function indexOf(xs, x) {
@@ -7952,8 +7952,8 @@ var require_pipeline = __commonJS({
7952
7952
  function call(fn) {
7953
7953
  fn();
7954
7954
  }
7955
- function pipe(from, to) {
7956
- return from.pipe(to);
7955
+ function pipe(from2, to) {
7956
+ return from2.pipe(to);
7957
7957
  }
7958
7958
  function popCallback(streams) {
7959
7959
  if (!streams.length) return noop;
@@ -8142,6 +8142,7 @@ __export(index_node_exports, {
8142
8142
  Validation: () => Validation_exports,
8143
8143
  ValidationRule: () => ValidationRule_exports,
8144
8144
  batch: () => batch,
8145
+ consumed: () => consumed,
8145
8146
  decodeCursor: () => decodeCursor,
8146
8147
  encodeCursor: () => encodeCursor,
8147
8148
  offerCollaterals: () => offerCollaterals,
@@ -8217,7 +8218,13 @@ __export(apiSchema_exports, {
8217
8218
  // src/RouterOffer.ts
8218
8219
  var RouterOffer_exports = {};
8219
8220
  __export(RouterOffer_exports, {
8220
- OfferStatusValues: () => OfferStatusValues
8221
+ InvalidRouterOfferError: () => InvalidRouterOfferError,
8222
+ OfferStatusValues: () => OfferStatusValues,
8223
+ RouterOfferSchema: () => RouterOfferSchema,
8224
+ from: () => from,
8225
+ fromSnakeCase: () => fromSnakeCase,
8226
+ random: () => random,
8227
+ toSnakeCase: () => toSnakeCase
8221
8228
  });
8222
8229
  var OfferStatusValues = [
8223
8230
  "valid",
@@ -8225,6 +8232,46 @@ var OfferStatusValues = [
8225
8232
  "callback_error",
8226
8233
  "unverified"
8227
8234
  ];
8235
+ var RouterOfferSchema = (parameters) => mempool.Offer.OfferSchema(parameters).extend({
8236
+ consumed: v4.z.bigint({ coerce: true }).min(0n).max(viem.maxUint256),
8237
+ status: v4.z.enum(OfferStatusValues),
8238
+ metadata: v4.z.object({
8239
+ issue: v4.z.string()
8240
+ }).optional()
8241
+ });
8242
+ function from(input) {
8243
+ try {
8244
+ const parsedOffer = RouterOfferSchema({ omitHash: true }).parse(input);
8245
+ const parsedHash = mempool.Offer.OfferHashSchema.parse(mempool.Offer.hash(parsedOffer));
8246
+ return {
8247
+ ...parsedOffer,
8248
+ hash: parsedHash
8249
+ };
8250
+ } catch (error) {
8251
+ throw new InvalidRouterOfferError(error);
8252
+ }
8253
+ }
8254
+ function fromSnakeCase(input) {
8255
+ return from(mempool.Format.fromSnakeCase(input));
8256
+ }
8257
+ function toSnakeCase(offer) {
8258
+ return mempool.Format.toSnakeCase(offer);
8259
+ }
8260
+ function random() {
8261
+ const baseOffer = mempool.Offer.random();
8262
+ return from({
8263
+ ...baseOffer,
8264
+ status: "valid",
8265
+ metadata: void 0,
8266
+ consumed: 0n
8267
+ });
8268
+ }
8269
+ var InvalidRouterOfferError = class extends mempool.Errors.BaseError {
8270
+ name = "RouterOffer.InvalidRouterOfferError";
8271
+ constructor(error) {
8272
+ super("Invalid router offer.", { cause: error });
8273
+ }
8274
+ };
8228
8275
 
8229
8276
  // src/utils/batch.ts
8230
8277
  function* batch(array, batchSize) {
@@ -8925,14 +8972,7 @@ async function get(config, parameters) {
8925
8972
  const { cursor: returnedCursor, data: offers2 } = await getApi(config, url);
8926
8973
  return {
8927
8974
  cursor: returnedCursor,
8928
- offers: offers2.map((offer) => {
8929
- const baseOffer = mempool.Offer.fromSnakeCase(offer);
8930
- return {
8931
- ...baseOffer,
8932
- status: offer.status,
8933
- metadata: offer.metadata
8934
- };
8935
- })
8975
+ offers: offers2.map(fromSnakeCase)
8936
8976
  };
8937
8977
  }
8938
8978
  async function match(config, parameters) {
@@ -8973,14 +9013,7 @@ async function match(config, parameters) {
8973
9013
  const { cursor: returnedCursor, data: offers2 } = await getApi(config, url);
8974
9014
  return {
8975
9015
  cursor: returnedCursor,
8976
- offers: offers2.map((offer) => {
8977
- const baseOffer = mempool.Offer.fromSnakeCase(offer);
8978
- return {
8979
- ...baseOffer,
8980
- status: offer.status,
8981
- metadata: offer.metadata
8982
- };
8983
- })
9016
+ offers: offers2.map(fromSnakeCase)
8984
9017
  };
8985
9018
  }
8986
9019
  async function getApi(config, url) {
@@ -9069,6 +9102,7 @@ var OfferDB_exports2 = {};
9069
9102
  __export(OfferDB_exports2, {
9070
9103
  OfferDB: () => OfferDB_exports,
9071
9104
  OfferRepository: () => OfferRepository_exports,
9105
+ consumed: () => consumed,
9072
9106
  offerCollaterals: () => offerCollaterals,
9073
9107
  offerStatus: () => offerStatus,
9074
9108
  offers: () => offers
@@ -9087,6 +9121,7 @@ __export(OfferDB_exports, {
9087
9121
  // src/OfferDB/schema.ts
9088
9122
  var schema_exports = {};
9089
9123
  __export(schema_exports, {
9124
+ consumed: () => consumed,
9090
9125
  offerCollaterals: () => offerCollaterals,
9091
9126
  offerStatus: () => offerStatus,
9092
9127
  offers: () => offers
@@ -9158,6 +9193,25 @@ var offerStatus = pgCore.pgTable(
9158
9193
  pgCore.index("offer_status_status_idx").on(table.status)
9159
9194
  ]
9160
9195
  );
9196
+ var consumed = pgCore.pgTable(
9197
+ "consumed_per_user_and_nonce",
9198
+ {
9199
+ id: pgCore.serial("id").primaryKey(),
9200
+ chainId: pgCore.bigint("chain_id", { mode: "bigint" }).notNull(),
9201
+ offering: pgCore.varchar("offering", { length: 42 }).notNull(),
9202
+ nonce: pgCore.bigint("nonce", { mode: "bigint" }).notNull(),
9203
+ consumed: pgCore.bigint("consumed", { mode: "bigint" }).notNull(),
9204
+ createdAt: pgCore.timestamp("created_at").defaultNow().notNull()
9205
+ },
9206
+ (table) => [
9207
+ pgCore.index("consumed_per_user_and_nonce_chain_id_offering_nonce_created_at_idx").on(
9208
+ table.chainId,
9209
+ table.offering,
9210
+ table.nonce,
9211
+ drizzle_orm_star.desc(table.createdAt)
9212
+ )
9213
+ ]
9214
+ );
9161
9215
 
9162
9216
  // src/OfferDB/OfferDB.ts
9163
9217
  function create({
@@ -9241,6 +9295,22 @@ function create2(config) {
9241
9295
  status,
9242
9296
  metadata
9243
9297
  });
9298
+ const consumedAmountExists = await tx.select().from(consumed).where(
9299
+ drizzle_orm_star.and(
9300
+ drizzle_orm_star.eq(consumed.offering, offer.offering.toLowerCase()),
9301
+ drizzle_orm_star.eq(consumed.nonce, offer.nonce),
9302
+ drizzle_orm_star.eq(consumed.chainId, offer.chainId)
9303
+ )
9304
+ );
9305
+ if (consumedAmountExists.length > 0) {
9306
+ return offer.hash;
9307
+ }
9308
+ await tx.insert(consumed).values({
9309
+ chainId: offer.chainId,
9310
+ offering: offer.offering.toLowerCase(),
9311
+ nonce: offer.nonce,
9312
+ consumed: 0n
9313
+ });
9244
9314
  return offer.hash;
9245
9315
  });
9246
9316
  },
@@ -9279,6 +9349,23 @@ function create2(config) {
9279
9349
  status,
9280
9350
  metadata
9281
9351
  });
9352
+ const consumedAmountExists = await tx.select().from(consumed).where(
9353
+ drizzle_orm_star.and(
9354
+ drizzle_orm_star.eq(consumed.offering, offer.offering.toLowerCase()),
9355
+ drizzle_orm_star.eq(consumed.nonce, offer.nonce),
9356
+ drizzle_orm_star.eq(consumed.chainId, offer.chainId)
9357
+ )
9358
+ );
9359
+ if (consumedAmountExists.length > 0) {
9360
+ hashes.push(offer.hash);
9361
+ continue;
9362
+ }
9363
+ await tx.insert(consumed).values({
9364
+ chainId: offer.chainId,
9365
+ offering: offer.offering.toLowerCase(),
9366
+ nonce: offer.nonce,
9367
+ consumed: 0n
9368
+ });
9282
9369
  hashes.push(offer.hash);
9283
9370
  }
9284
9371
  return hashes;
@@ -9414,10 +9501,22 @@ function create2(config) {
9414
9501
  status: offerStatus.status,
9415
9502
  metadata: offerStatus.metadata
9416
9503
  }).from(offerStatus).where(drizzle_orm_star.eq(offerStatus.offerHash, offers.hash)).orderBy(drizzle_orm_star.desc(offerStatus.createdAt)).limit(1).as("latest_status");
9504
+ const latestConsumed = db.selectDistinctOn(
9505
+ [
9506
+ consumed.offering,
9507
+ consumed.nonce,
9508
+ consumed.chainId,
9509
+ consumed.createdAt
9510
+ ],
9511
+ {
9512
+ consumed: consumed.consumed
9513
+ }
9514
+ ).from(consumed).orderBy(drizzle_orm_star.desc(consumed.createdAt)).limit(1).as("latest_consumed");
9417
9515
  const results = await db.select({
9418
9516
  hash: offers.hash,
9419
9517
  offering: offers.offering,
9420
9518
  assets: offers.assets,
9519
+ consumed: latestConsumed.consumed,
9421
9520
  rate: offers.rate,
9422
9521
  maturity: offers.maturity,
9423
9522
  expiry: offers.expiry,
@@ -9436,10 +9535,11 @@ function create2(config) {
9436
9535
  collateralLltv: offerCollaterals.lltv,
9437
9536
  status: latestStatus.status,
9438
9537
  metadata: latestStatus.metadata
9439
- }).from(offers).leftJoin(offerCollaterals, drizzle_orm_star.eq(offers.hash, offerCollaterals.offerHash)).leftJoinLateral(latestStatus, drizzle_orm_star.sql`true`).where(
9538
+ }).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(
9440
9539
  drizzle_orm_star.and(
9441
9540
  conditions.length > 0 ? drizzle_orm_star.and(...conditions) : drizzle_orm_star.sql`true`,
9442
- query?.status && query.status.length > 0 ? drizzle_orm_star.inArray(latestStatus.status, query.status) : drizzle_orm_star.eq(latestStatus.status, "valid")
9541
+ query?.status && query.status.length > 0 ? drizzle_orm_star.inArray(latestStatus.status, query.status) : drizzle_orm_star.eq(latestStatus.status, "valid"),
9542
+ drizzle_orm_star.sql`( ${offers.assets} - COALESCE(${latestConsumed.consumed}, 0) ) > 0`
9443
9543
  )
9444
9544
  ).orderBy(sortOrder === "asc" ? drizzle_orm_star.asc(sortColumn) : drizzle_orm_star.desc(sortColumn)).limit(limit);
9445
9545
  const offerMap = /* @__PURE__ */ new Map();
@@ -9448,6 +9548,7 @@ function create2(config) {
9448
9548
  hash: row.hash,
9449
9549
  offering: row.offering,
9450
9550
  assets: row.assets,
9551
+ consumed: row.consumed || 0n,
9451
9552
  rate: row.rate,
9452
9553
  maturity: row.maturity,
9453
9554
  expiry: row.expiry,
@@ -9524,6 +9625,7 @@ function create2(config) {
9524
9625
  });
9525
9626
  transformedResults.push({
9526
9627
  ...offer,
9628
+ consumed: offerData.consumed,
9527
9629
  status: offerData.status,
9528
9630
  ...offerData.metadata !== null ? { metadata: offerData.metadata } : {}
9529
9631
  });
@@ -9623,29 +9725,83 @@ function create2(config) {
9623
9725
  status: offerStatus.status,
9624
9726
  metadata: offerStatus.metadata
9625
9727
  }).from(offerStatus).where(drizzle_orm_star.eq(offerStatus.offerHash, offers.hash)).orderBy(drizzle_orm_star.desc(offerStatus.createdAt)).limit(1).as("latest_status");
9728
+ const latestConsumed = db.selectDistinctOn(
9729
+ [
9730
+ consumed.offering,
9731
+ consumed.nonce,
9732
+ consumed.chainId,
9733
+ consumed.createdAt
9734
+ ],
9735
+ {
9736
+ consumed: consumed.consumed
9737
+ }
9738
+ ).from(consumed).orderBy(drizzle_orm_star.desc(consumed.createdAt)).limit(1).as("latest_consumed");
9626
9739
  const statusCondition = status && status.length > 0 ? drizzle_orm_star.inArray(latestStatus.status, status) : drizzle_orm_star.eq(latestStatus.status, "valid");
9740
+ const bestOffers = db.selectDistinctOn(
9741
+ // group key
9742
+ [offers.offering, offers.nonce, offers.buy],
9743
+ {
9744
+ hash: offers.hash,
9745
+ offering: offers.offering,
9746
+ assets: offers.assets,
9747
+ consumed: latestConsumed.consumed,
9748
+ rate: offers.rate,
9749
+ maturity: offers.maturity,
9750
+ expiry: offers.expiry,
9751
+ start: offers.start,
9752
+ nonce: offers.nonce,
9753
+ buy: offers.buy,
9754
+ chainId: offers.chainId,
9755
+ loanToken: offers.loanToken,
9756
+ callbackAddress: offers.callbackAddress,
9757
+ callbackData: offers.callbackData,
9758
+ callbackGasLimit: offers.callbackGasLimit,
9759
+ signature: offers.signature,
9760
+ status: latestStatus.status,
9761
+ metadata: latestStatus.metadata
9762
+ }
9763
+ ).from(offers).leftJoinLateral(latestStatus, drizzle_orm_star.sql`true`).leftJoinLateral(latestConsumed, drizzle_orm_star.sql`true`).where(
9764
+ drizzle_orm_star.and(
9765
+ drizzle_orm_star.and(...conditions),
9766
+ statusCondition,
9767
+ drizzle_orm_star.sql`( ${offers.assets} - COALESCE(${latestConsumed.consumed}, 0) ) > 0`
9768
+ )
9769
+ ).orderBy(
9770
+ offers.offering,
9771
+ offers.nonce,
9772
+ offers.buy,
9773
+ // 1 price (direction depends on side)
9774
+ drizzle_orm_star.sql`CASE WHEN ${offers.buy} THEN ${offers.rate} ELSE -${offers.rate} END`,
9775
+ // 2 size (remaining)
9776
+ drizzle_orm_star.sql`( ${offers.assets} - COALESCE(${latestConsumed.consumed}, 0) ) DESC`,
9777
+ // 3 term (longer maturity)
9778
+ drizzle_orm_star.desc(offers.maturity)
9779
+ ).as("best_offers");
9627
9780
  const rows = await db.select({
9628
- hash: offers.hash,
9629
- offering: offers.offering,
9630
- assets: offers.assets,
9631
- rate: offers.rate,
9632
- maturity: offers.maturity,
9633
- expiry: offers.expiry,
9634
- start: offers.start,
9635
- nonce: offers.nonce,
9636
- buy: offers.buy,
9637
- chainId: offers.chainId,
9638
- loanToken: offers.loanToken,
9639
- callbackAddress: offers.callbackAddress,
9640
- callbackData: offers.callbackData,
9641
- callbackGasLimit: offers.callbackGasLimit,
9642
- signature: offers.signature,
9643
- status: latestStatus.status,
9644
- metadata: latestStatus.metadata,
9781
+ hash: bestOffers.hash,
9782
+ offering: bestOffers.offering,
9783
+ assets: bestOffers.assets,
9784
+ consumed: bestOffers.consumed,
9785
+ rate: bestOffers.rate,
9786
+ maturity: bestOffers.maturity,
9787
+ expiry: bestOffers.expiry,
9788
+ start: bestOffers.start,
9789
+ nonce: bestOffers.nonce,
9790
+ buy: bestOffers.buy,
9791
+ chainId: bestOffers.chainId,
9792
+ loanToken: bestOffers.loanToken,
9793
+ callbackAddress: bestOffers.callbackAddress,
9794
+ callbackData: bestOffers.callbackData,
9795
+ callbackGasLimit: bestOffers.callbackGasLimit,
9796
+ signature: bestOffers.signature,
9797
+ status: bestOffers.status,
9798
+ metadata: bestOffers.metadata,
9645
9799
  collateralAsset: offerCollaterals.asset,
9646
9800
  collateralOracle: offerCollaterals.oracle,
9647
9801
  collateralLltv: offerCollaterals.lltv
9648
- }).from(offers).leftJoin(offerCollaterals, drizzle_orm_star.eq(offers.hash, offerCollaterals.offerHash)).leftJoinLateral(latestStatus, drizzle_orm_star.sql`true`).where(drizzle_orm_star.and(drizzle_orm_star.and(...conditions), statusCondition)).orderBy(sortOrder === "asc" ? drizzle_orm_star.asc(offers.rate) : drizzle_orm_star.desc(offers.rate)).limit(limit + 1);
9802
+ }).from(bestOffers).leftJoin(offerCollaterals, drizzle_orm_star.eq(bestOffers.hash, offerCollaterals.offerHash)).orderBy(
9803
+ 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`
9804
+ ).limit(limit + 1);
9649
9805
  const offerMap = /* @__PURE__ */ new Map();
9650
9806
  for (const r of rows) {
9651
9807
  const entry = offerMap.get(r.hash) ?? { base: r, collaterals: [] };
@@ -9684,6 +9840,7 @@ function create2(config) {
9684
9840
  },
9685
9841
  signature: base2.signature === null ? void 0 : base2.signature
9686
9842
  }),
9843
+ consumed: base2.consumed || 0n,
9687
9844
  status: base2.status,
9688
9845
  ...base2.metadata ? { metadata: base2.metadata } : {}
9689
9846
  }));
@@ -9717,6 +9874,9 @@ function create2(config) {
9717
9874
  },
9718
9875
  updateStatus: async (parameters) => {
9719
9876
  await db.insert(offerStatus).values(parameters);
9877
+ },
9878
+ updateConsumedAmount: async (parameters) => {
9879
+ await db.insert(consumed).values(parameters);
9720
9880
  }
9721
9881
  };
9722
9882
  }
@@ -9729,6 +9889,8 @@ function createTest() {
9729
9889
  delete: async (_hash) => false,
9730
9890
  deleteMany: async (_hashes) => 0,
9731
9891
  updateStatus: async (_params) => {
9892
+ },
9893
+ updateConsumedAmount: async (_params) => {
9732
9894
  }
9733
9895
  };
9734
9896
  }
@@ -11414,15 +11576,15 @@ function weierstrassPoints(opts) {
11414
11576
  throw new Error("ProjectivePoint expected");
11415
11577
  }
11416
11578
  const toAffineMemo = memoized((p, iz) => {
11417
- const { px: x, py: y, pz: z5 } = p;
11418
- if (Fp5.eql(z5, Fp5.ONE))
11579
+ const { px: x, py: y, pz: z6 } = p;
11580
+ if (Fp5.eql(z6, Fp5.ONE))
11419
11581
  return { x, y };
11420
11582
  const is0 = p.is0();
11421
11583
  if (iz == null)
11422
- iz = is0 ? Fp5.ONE : Fp5.inv(z5);
11584
+ iz = is0 ? Fp5.ONE : Fp5.inv(z6);
11423
11585
  const ax = Fp5.mul(x, iz);
11424
11586
  const ay = Fp5.mul(y, iz);
11425
- const zz = Fp5.mul(z5, iz);
11587
+ const zz = Fp5.mul(z6, iz);
11426
11588
  if (is0)
11427
11589
  return { x: Fp5.ZERO, y: Fp5.ZERO };
11428
11590
  if (!Fp5.eql(zz, Fp5.ONE))
@@ -11837,7 +11999,7 @@ function weierstrass(curveDef) {
11837
11999
  function normalizeS(s) {
11838
12000
  return isBiggerThanHalfOrder(s) ? modN(-s) : s;
11839
12001
  }
11840
- const slcNum = (b, from, to) => bytesToNumberBE(b.slice(from, to));
12002
+ const slcNum = (b, from2, to) => bytesToNumberBE(b.slice(from2, to));
11841
12003
  class Signature {
11842
12004
  constructor(r, s, recovery) {
11843
12005
  aInRange("r", r, _1n4, CURVE_ORDER);
@@ -13089,25 +13251,25 @@ var isValidAddress = function(hexAddress) {
13089
13251
  }
13090
13252
  return /^0x[0-9a-fA-F]{40}$/.test(hexAddress);
13091
13253
  };
13092
- var generateAddress = function(from, nonce) {
13093
- assertIsBytes(from);
13254
+ var generateAddress = function(from2, nonce) {
13255
+ assertIsBytes(from2);
13094
13256
  assertIsBytes(nonce);
13095
13257
  if (bytesToBigInt(nonce) === BIGINT_02) {
13096
- return keccak256(RLP.encode([from, Uint8Array.from([])])).subarray(-20);
13258
+ return keccak256(RLP.encode([from2, Uint8Array.from([])])).subarray(-20);
13097
13259
  }
13098
- return keccak256(RLP.encode([from, nonce])).subarray(-20);
13260
+ return keccak256(RLP.encode([from2, nonce])).subarray(-20);
13099
13261
  };
13100
- var generateAddress2 = function(from, salt, initCode) {
13101
- assertIsBytes(from);
13262
+ var generateAddress2 = function(from2, salt, initCode) {
13263
+ assertIsBytes(from2);
13102
13264
  assertIsBytes(salt);
13103
13265
  assertIsBytes(initCode);
13104
- if (from.length !== 20) {
13266
+ if (from2.length !== 20) {
13105
13267
  throw EthereumJSErrorWithoutCode("Expected from to be of length 20");
13106
13268
  }
13107
13269
  if (salt.length !== 32) {
13108
13270
  throw EthereumJSErrorWithoutCode("Expected salt to be of length 32");
13109
13271
  }
13110
- const address = keccak256(concatBytes4(hexToBytes5("0xff"), from, salt, keccak256(initCode)));
13272
+ const address = keccak256(concatBytes4(hexToBytes5("0xff"), from2, salt, keccak256(initCode)));
13111
13273
  return address.subarray(-20);
13112
13274
  };
13113
13275
  var pubToAddress = function(pubKey, sanitize = false) {
@@ -20978,7 +21140,7 @@ async function precompile0a(opts) {
20978
21140
  const version2 = Number(opts.common.param("blobCommitmentVersionKzg"));
20979
21141
  const fieldElementsPerBlob = opts.common.param("fieldElementsPerBlob");
20980
21142
  const versionedHash = bytesToHex4(opts.data.subarray(0, 32));
20981
- const z5 = bytesToHex4(opts.data.subarray(32, 64));
21143
+ const z6 = bytesToHex4(opts.data.subarray(32, 64));
20982
21144
  const y = bytesToHex4(opts.data.subarray(64, 96));
20983
21145
  const commitment = bytesToHex4(opts.data.subarray(96, 144));
20984
21146
  const kzgProof = bytesToHex4(opts.data.subarray(144, 192));
@@ -20989,10 +21151,10 @@ async function precompile0a(opts) {
20989
21151
  return EVMErrorResult(new EVMError(EVMError.errorMessages.INVALID_COMMITMENT), opts.gasLimit);
20990
21152
  }
20991
21153
  if (opts._debug !== void 0) {
20992
- opts._debug(`${pName}: proof verification with commitment=${commitment} z=${z5} y=${y} kzgProof=${kzgProof}`);
21154
+ opts._debug(`${pName}: proof verification with commitment=${commitment} z=${z6} y=${y} kzgProof=${kzgProof}`);
20993
21155
  }
20994
21156
  try {
20995
- const res = opts.common.customCrypto?.kzg?.verifyProof(commitment, z5, y, kzgProof);
21157
+ const res = opts.common.customCrypto?.kzg?.verifyProof(commitment, z6, y, kzgProof);
20996
21158
  if (res === false) {
20997
21159
  return EVMErrorResult(new EVMError(EVMError.errorMessages.INVALID_PROOF), opts.gasLimit);
20998
21160
  }
@@ -22394,15 +22556,15 @@ function weierstrassN(CURVE, curveOpts = {}) {
22394
22556
  throw new Error("ProjectivePoint expected");
22395
22557
  }
22396
22558
  const toAffineMemo = memoized2((p, iz) => {
22397
- const { px: x, py: y, pz: z5 } = p;
22398
- if (Fp5.eql(z5, Fp5.ONE))
22559
+ const { px: x, py: y, pz: z6 } = p;
22560
+ if (Fp5.eql(z6, Fp5.ONE))
22399
22561
  return { x, y };
22400
22562
  const is0 = p.is0();
22401
22563
  if (iz == null)
22402
- iz = is0 ? Fp5.ONE : Fp5.inv(z5);
22564
+ iz = is0 ? Fp5.ONE : Fp5.inv(z6);
22403
22565
  const ax = Fp5.mul(x, iz);
22404
22566
  const ay = Fp5.mul(y, iz);
22405
- const zz = Fp5.mul(z5, iz);
22567
+ const zz = Fp5.mul(z6, iz);
22406
22568
  if (is0)
22407
22569
  return { x: Fp5.ZERO, y: Fp5.ZERO };
22408
22570
  if (!Fp5.eql(zz, Fp5.ONE))
@@ -24054,13 +24216,13 @@ var { Fp, Fp2, Fp6, Fp4Square, Fp12 } = tower12({
24054
24216
  };
24055
24217
  },
24056
24218
  Fp12cyclotomicExp(num, n) {
24057
- let z5 = Fp12.ONE;
24219
+ let z6 = Fp12.ONE;
24058
24220
  for (let i = BLS_X_LEN - 1; i >= 0; i--) {
24059
- z5 = Fp12._cyclotomicSquare(z5);
24221
+ z6 = Fp12._cyclotomicSquare(z6);
24060
24222
  if (bitGet(n, i))
24061
- z5 = Fp12.mul(z5, num);
24223
+ z6 = Fp12.mul(z6, num);
24062
24224
  }
24063
- return z5;
24225
+ return z6;
24064
24226
  },
24065
24227
  // https://eprint.iacr.org/2010/354.pdf
24066
24228
  // https://eprint.iacr.org/2009/565.pdf
@@ -24241,7 +24403,7 @@ function pointG2FromBytes(bytes2) {
24241
24403
  sort && infinity && compressed) {
24242
24404
  throw new Error("invalid encoding flag: " + (bytes2[0] & 224));
24243
24405
  }
24244
- const slc = (b, from, to) => bytesToNumberBE2(b.slice(from, to));
24406
+ const slc = (b, from2, to) => bytesToNumberBE2(b.slice(from2, to));
24245
24407
  if (value.length === 96 && compressed) {
24246
24408
  if (infinity) {
24247
24409
  if (value.reduce((p, c) => p !== 0 ? c + 1 : c, 0) > 0) {
@@ -25147,16 +25309,16 @@ var Kr160 = /* @__PURE__ */ Uint32Array.from([
25147
25309
  2053994217,
25148
25310
  0
25149
25311
  ]);
25150
- function ripemd_f(group, x, y, z5) {
25312
+ function ripemd_f(group, x, y, z6) {
25151
25313
  if (group === 0)
25152
- return x ^ y ^ z5;
25314
+ return x ^ y ^ z6;
25153
25315
  if (group === 1)
25154
- return x & y | ~x & z5;
25316
+ return x & y | ~x & z6;
25155
25317
  if (group === 2)
25156
- return (x | ~y) ^ z5;
25318
+ return (x | ~y) ^ z6;
25157
25319
  if (group === 3)
25158
- return x & z5 | y & ~z5;
25159
- return x ^ (y | ~z5);
25320
+ return x & z6 | y & ~z6;
25321
+ return x ^ (y | ~z6);
25160
25322
  }
25161
25323
  var BUF_160 = /* @__PURE__ */ new Uint32Array(16);
25162
25324
  var RIPEMD160 = class extends HashMD {
@@ -25980,13 +26142,13 @@ var { Fp: Fp3, Fp2: Fp22, Fp6: Fp62, Fp4Square: Fp4Square2, Fp12: Fp122 } = towe
25980
26142
  };
25981
26143
  },
25982
26144
  Fp12cyclotomicExp(num, n) {
25983
- let z5 = Fp122.ONE;
26145
+ let z6 = Fp122.ONE;
25984
26146
  for (let i = BN_X_LEN - 1; i >= 0; i--) {
25985
- z5 = Fp122._cyclotomicSquare(z5);
26147
+ z6 = Fp122._cyclotomicSquare(z6);
25986
26148
  if (bitGet(n, i))
25987
- z5 = Fp122.mul(z5, num);
26149
+ z6 = Fp122.mul(z6, num);
25988
26150
  }
25989
- return z5;
26151
+ return z6;
25990
26152
  },
25991
26153
  // https://eprint.iacr.org/2010/354.pdf
25992
26154
  // https://eprint.iacr.org/2009/565.pdf
@@ -36020,14 +36182,14 @@ var createAddress = (address) => {
36020
36182
  });
36021
36183
  }
36022
36184
  };
36023
- var createContractAddress = (from, nonce) => {
36024
- if (!(from.bytes instanceof Uint8Array)) {
36185
+ var createContractAddress = (from2, nonce) => {
36186
+ if (!(from2.bytes instanceof Uint8Array)) {
36025
36187
  throw new InvalidAddressError("Expected from to be an Address or ethereumjs Address");
36026
36188
  }
36027
36189
  if (nonce === 0n) {
36028
- return createAddress(utils.keccak256(utils.toRlp([from.bytes, Uint8Array.from([])]), "bytes").subarray(-20));
36190
+ return createAddress(utils.keccak256(utils.toRlp([from2.bytes, Uint8Array.from([])]), "bytes").subarray(-20));
36029
36191
  }
36030
- return createAddress(utils.keccak256(utils.toRlp([from.bytes, viem.numberToBytes(nonce)]), "bytes").subarray(-20));
36192
+ return createAddress(utils.keccak256(utils.toRlp([from2.bytes, viem.numberToBytes(nonce)]), "bytes").subarray(-20));
36031
36193
  };
36032
36194
 
36033
36195
  // ../../node_modules/.pnpm/@ethereumjs+tx@10.0.0/node_modules/@ethereumjs/tx/dist/esm/types.js
@@ -40463,13 +40625,13 @@ function weierstrassPoints3(opts) {
40463
40625
  // Can accept precomputed Z^-1 - for example, from invertBatch.
40464
40626
  // (x, y, z) ∋ (x=x/z, y=y/z)
40465
40627
  toAffine(iz) {
40466
- const { px: x, py: y, pz: z5 } = this;
40628
+ const { px: x, py: y, pz: z6 } = this;
40467
40629
  const is0 = this.is0();
40468
40630
  if (iz == null)
40469
- iz = is0 ? Fp5.ONE : Fp5.inv(z5);
40631
+ iz = is0 ? Fp5.ONE : Fp5.inv(z6);
40470
40632
  const ax = Fp5.mul(x, iz);
40471
40633
  const ay = Fp5.mul(y, iz);
40472
- const zz = Fp5.mul(z5, iz);
40634
+ const zz = Fp5.mul(z6, iz);
40473
40635
  if (is0)
40474
40636
  return { x: Fp5.ZERO, y: Fp5.ZERO };
40475
40637
  if (!Fp5.eql(zz, Fp5.ONE))
@@ -40589,7 +40751,7 @@ function weierstrass3(curveDef) {
40589
40751
  function normalizeS(s) {
40590
40752
  return isBiggerThanHalfOrder(s) ? modN(-s) : s;
40591
40753
  }
40592
- const slcNum = (b, from, to) => bytesToNumberBE3(b.slice(from, to));
40754
+ const slcNum = (b, from2, to) => bytesToNumberBE3(b.slice(from2, to));
40593
40755
  class Signature {
40594
40756
  constructor(r, s, recovery) {
40595
40757
  this.r = r;
@@ -47440,10 +47602,10 @@ var ReceiptsManager = class _ReceiptsManager {
47440
47602
  * // Get logs with specific topics
47441
47603
  * const logs = await receiptManager.getLogs(block100, block200, undefined, [eventTopic])
47442
47604
  */
47443
- async getLogs(from, to, addresses, topics = []) {
47605
+ async getLogs(from2, to, addresses, topics = []) {
47444
47606
  const returnedLogs = [];
47445
47607
  let returnedLogsSize = 0;
47446
- for (let i = from.header.number; i <= to.header.number; i++) {
47608
+ for (let i = from2.header.number; i <= to.header.number; i++) {
47447
47609
  const block = await getBlock(this.chain)(i);
47448
47610
  const receipts = await this.getReceipts(block.hash());
47449
47611
  if (receipts.length === 0) continue;
@@ -54418,7 +54580,7 @@ var anvilStopImpersonatingAccountJsonRpcProcedure = (client) => {
54418
54580
  };
54419
54581
  var ethCreateAccessListProcedure = (client) => async (req) => {
54420
54582
  const [tx, blockTag] = req.params;
54421
- const { data, from, to, gas, gasPrice, value } = tx;
54583
+ const { data, from: from2, to, gas, gasPrice, value } = tx;
54422
54584
  const response = await callProcedure(client)({
54423
54585
  ...req.id !== void 0 ? { id: req.id } : {},
54424
54586
  jsonrpc: req.jsonrpc,
@@ -54430,7 +54592,7 @@ var ethCreateAccessListProcedure = (client) => async (req) => {
54430
54592
  ...gas !== void 0 ? { gas } : {},
54431
54593
  ...value !== void 0 ? { value } : {},
54432
54594
  ...to !== void 0 ? { to } : {},
54433
- ...from !== void 0 ? { from } : {},
54595
+ ...from2 !== void 0 ? { from: from2 } : {},
54434
54596
  ...blockTag !== void 0 ? { blockTag } : {},
54435
54597
  createAccessList: true
54436
54598
  }
@@ -54820,7 +54982,7 @@ var ethBlobBaseFeeJsonRpcProcedure = (client) => {
54820
54982
  };
54821
54983
  var ethCallProcedure = (client) => async (req) => {
54822
54984
  const [tx, blockTag, stateOverrideSet, blockOverrideSet] = req.params;
54823
- const { data, from, to, gas, gasPrice, value } = tx;
54985
+ const { data, from: from2, to, gas, gasPrice, value } = tx;
54824
54986
  const response = await callProcedure(client)({
54825
54987
  ...req.id !== void 0 ? { id: req.id } : {},
54826
54988
  jsonrpc: req.jsonrpc,
@@ -54832,7 +54994,7 @@ var ethCallProcedure = (client) => async (req) => {
54832
54994
  ...gas !== void 0 ? { gas } : {},
54833
54995
  ...value !== void 0 ? { value } : {},
54834
54996
  ...to !== void 0 ? { to } : {},
54835
- ...from !== void 0 ? { from } : {},
54997
+ ...from2 !== void 0 ? { from: from2 } : {},
54836
54998
  ...blockTag !== void 0 ? { blockTag } : {}
54837
54999
  },
54838
55000
  stateOverrideSet,
@@ -56591,14 +56753,14 @@ var debugTraceBlockJsonRpcProcedure = (client) => {
56591
56753
  };
56592
56754
  var debugTraceCallJsonRpcProcedure = (client) => {
56593
56755
  return async (request) => {
56594
- const { blockTag, tracer, to, gas, data, from, value, timeout, gasPrice, tracerConfig } = request.params[0];
56756
+ const { blockTag, tracer, to, gas, data, from: from2, value, timeout, gasPrice, tracerConfig } = request.params[0];
56595
56757
  if (timeout !== void 0) {
56596
56758
  client.logger.warn("Warning: timeout is currently respected param of debug_traceCall");
56597
56759
  }
56598
56760
  const traceResult = await traceCallHandler(client)({
56599
56761
  tracer,
56600
56762
  ...to !== void 0 ? { to } : {},
56601
- ...from !== void 0 ? { from } : {},
56763
+ ...from2 !== void 0 ? { from: from2 } : {},
56602
56764
  ...gas !== void 0 ? { gas: typeof gas === "bigint" ? gas : utils.hexToBigInt(gas) } : {},
56603
56765
  ...gasPrice !== void 0 ? { gasPrice: typeof gasPrice === "bigint" ? gasPrice : utils.hexToBigInt(gasPrice) } : {},
56604
56766
  ...value !== void 0 ? { value: typeof value === "bigint" ? value : utils.hexToBigInt(value) } : {},
@@ -57637,6 +57799,7 @@ exports.RouterOffer = RouterOffer_exports;
57637
57799
  exports.Validation = Validation_exports;
57638
57800
  exports.ValidationRule = ValidationRule_exports;
57639
57801
  exports.batch = batch;
57802
+ exports.consumed = consumed;
57640
57803
  exports.decodeCursor = decodeCursor;
57641
57804
  exports.encodeCursor = encodeCursor;
57642
57805
  exports.offerCollaterals = offerCollaterals;