@morpho-dev/router 0.0.25 → 0.0.26

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.
@@ -51,7 +51,8 @@ var chains = {
51
51
  // DAI
52
52
  ].map((address) => address.toLowerCase())
53
53
  ),
54
- morpho: "0x0000000000000000000000000000000000000000"
54
+ morpho: "0x0000000000000000000000000000000000000000",
55
+ termsContract: "0x0000000000000000000000000000000000000000"
55
56
  },
56
57
  base: {
57
58
  ...base,
@@ -65,7 +66,8 @@ var chains = {
65
66
  // DAI
66
67
  ].map((address) => address.toLowerCase())
67
68
  ),
68
- morpho: "0x0000000000000000000000000000000000000000"
69
+ morpho: "0x0000000000000000000000000000000000000000",
70
+ termsContract: "0x0000000000000000000000000000000000000000"
69
71
  },
70
72
  "ethereum-virtual-testnet": {
71
73
  ...mainnet,
@@ -80,6 +82,7 @@ var chains = {
80
82
  ].map((address) => address.toLowerCase())
81
83
  ),
82
84
  morpho: "0x0000000000000000000000000000000000000000",
85
+ termsContract: "0xa85d462ceb11d6f91f003072fdc701b0a1bbd8bd",
83
86
  mempool: {
84
87
  address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
85
88
  deploymentBlock: 23223727,
@@ -107,7 +110,9 @@ __export(RouterOffer_exports, {
107
110
  InvalidRouterOfferError: () => InvalidRouterOfferError,
108
111
  OfferStatusValues: () => OfferStatusValues,
109
112
  RouterOfferSchema: () => RouterOfferSchema,
113
+ consumedEvent: () => consumedEvent,
110
114
  from: () => from,
115
+ fromConsumedLog: () => fromConsumedLog,
111
116
  fromSnakeCase: () => fromSnakeCase,
112
117
  random: () => random,
113
118
  toSnakeCase: () => toSnakeCase
@@ -125,6 +130,16 @@ var RouterOfferSchema = (parameters) => Offer.OfferSchema(parameters).extend({
125
130
  issue: z.string()
126
131
  }).optional()
127
132
  });
133
+ var consumedEvent = {
134
+ type: "event",
135
+ name: "Consumed",
136
+ inputs: [
137
+ { name: "user", type: "address", indexed: true, internalType: "address" },
138
+ { name: "nonce", type: "uint256", indexed: true, internalType: "uint256" },
139
+ { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
140
+ ],
141
+ anonymous: false
142
+ };
128
143
  function from(input) {
129
144
  try {
130
145
  const parsedOffer = RouterOfferSchema({ omitHash: true }).parse(input);
@@ -152,6 +167,16 @@ function random() {
152
167
  consumed: 0n
153
168
  });
154
169
  }
170
+ function fromConsumedLog(parameters) {
171
+ const { blockNumber, logIndex, chainId, transactionHash, user, nonce, amount } = parameters;
172
+ return {
173
+ id: `${blockNumber.toString()}-${logIndex.toString()}-${chainId}-${transactionHash}`,
174
+ chainId: BigInt(chainId),
175
+ offering: user,
176
+ nonce,
177
+ amount
178
+ };
179
+ }
155
180
  var InvalidRouterOfferError = class extends Errors.BaseError {
156
181
  constructor(error) {
157
182
  super("Invalid router offer.", { cause: error });
@@ -1089,6 +1114,7 @@ __export(OfferStore_exports, {
1089
1114
  function memory(parameters) {
1090
1115
  const map = parameters.offers;
1091
1116
  const filled = parameters.filled;
1117
+ const consumedIds = /* @__PURE__ */ new Set();
1092
1118
  const indexingProgress = /* @__PURE__ */ new Map();
1093
1119
  const create = async (parameters2) => {
1094
1120
  if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
@@ -1422,12 +1448,15 @@ function memory(parameters) {
1422
1448
  });
1423
1449
  },
1424
1450
  updateConsumedAmount: async (parameters2) => {
1451
+ if (consumedIds.has(parameters2.id)) return;
1452
+ consumedIds.add(parameters2.id);
1425
1453
  const chainId = parameters2.chainId;
1426
1454
  const address = parameters2.offering.toLowerCase();
1427
1455
  const nonce = parameters2.nonce;
1428
1456
  const filledForChain = filled.get(chainId) || /* @__PURE__ */ new Map();
1429
1457
  const filledForOffering = filledForChain.get(address) || /* @__PURE__ */ new Map();
1430
- filledForOffering.set(nonce, parameters2.consumed);
1458
+ const current = filledForOffering.get(nonce) || 0n;
1459
+ filledForOffering.set(nonce, current + parameters2.consumed);
1431
1460
  filledForChain.set(address, filledForOffering);
1432
1461
  filled.set(chainId, filledForChain);
1433
1462
  },
@@ -1449,9 +1478,9 @@ __export(RouterEvent_exports, {
1449
1478
  from: () => from2,
1450
1479
  types: () => types
1451
1480
  });
1452
- var types = ["offer_created", "offer_matched", "offer_validation"];
1481
+ var types = ["offer_created", "offer_consumed", "offer_validation"];
1453
1482
  function from2(base) {
1454
- const id = `${base.type}:${base.offer.hash.toLowerCase()}`;
1483
+ const id = base.type === "offer_consumed" ? `${base.type}:${base.offerConsumed.id}` : `${base.type}:${base.offer.hash.toLowerCase()}`;
1455
1484
  return { id, ...base };
1456
1485
  }
1457
1486