@morpho-dev/router 0.1.15 → 0.1.16

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.
@@ -12,7 +12,7 @@ var jsBase64 = require('js-base64');
12
12
  var accounts = require('viem/accounts');
13
13
  var drizzleOrm = require('drizzle-orm');
14
14
  var pgCore = require('drizzle-orm/pg-core');
15
- var path2 = require('path');
15
+ var path = require('path');
16
16
  var pglite = require('@electric-sql/pglite');
17
17
  var nodePostgres = require('drizzle-orm/node-postgres');
18
18
  var migrator = require('drizzle-orm/node-postgres/migrator');
@@ -21,10 +21,6 @@ var migrator$1 = require('drizzle-orm/pglite/migrator');
21
21
  var pg = require('pg');
22
22
  var v4 = require('zod/v4');
23
23
  var zodOpenapi = require('zod-openapi');
24
- var child_process = require('child_process');
25
- var fs = require('fs');
26
- var tevm = require('tevm');
27
- var common = require('tevm/common');
28
24
 
29
25
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
30
26
 
@@ -47,8 +43,7 @@ function _interopNamespace(e) {
47
43
  }
48
44
 
49
45
  var z6__namespace = /*#__PURE__*/_interopNamespace(z6);
50
- var path2__default = /*#__PURE__*/_interopDefault(path2);
51
- var fs__default = /*#__PURE__*/_interopDefault(fs);
46
+ var path__default = /*#__PURE__*/_interopDefault(path);
52
47
 
53
48
  var __defProp = Object.defineProperty;
54
49
  var __export = (target, all) => {
@@ -3261,23 +3256,23 @@ async function nodeJsFindMatchingOffers(db, params) {
3261
3256
  })) {
3262
3257
  if (pathsChunk.length === 0) continue;
3263
3258
  for (let i = 0; i < pathsChunk.length; i++) {
3264
- const path3 = pathsChunk[i];
3265
- const offerHash = path3.offer_hash;
3259
+ const path2 = pathsChunk[i];
3260
+ const offerHash = path2.offer_hash;
3266
3261
  if (offerHashInvalid.has(offerHash) || offerHashValid.has(offerHash)) continue;
3267
- for (const poolId of path3.path) {
3262
+ for (const poolId of path2.path) {
3268
3263
  if (intermediateState.has(poolId)) continue;
3269
- const poolAmount = globalState.has(poolId) ? globalState.get(poolId) : BigInt(path3.pools.find((p) => p.pool_id === poolId)?.amount || 0);
3264
+ const poolAmount = globalState.has(poolId) ? globalState.get(poolId) : BigInt(path2.pools.find((p) => p.pool_id === poolId)?.amount || 0);
3270
3265
  intermediateState.set(poolId, poolAmount);
3271
3266
  }
3272
3267
  const bottleneck = Array.from(intermediateState.entries()).reduce((acc, [id2, curr]) => {
3273
- if (!path3.path.includes(id2) || id2 === path3.root_id) return acc;
3268
+ if (!path2.path.includes(id2) || id2 === path2.root_id) return acc;
3274
3269
  return acc < curr ? acc : curr;
3275
- }, intermediateState.get(path3.root_id));
3270
+ }, intermediateState.get(path2.root_id));
3276
3271
  for (const [poolId, amount] of intermediateState.entries()) {
3277
- if (!path3.path.includes(poolId)) continue;
3272
+ if (!path2.path.includes(poolId)) continue;
3278
3273
  intermediateState.set(poolId, amount - bottleneck);
3279
3274
  }
3280
- const isPoolRootUsedBeforeByAnotherOffer = globalState.has(path3.root_id) && globalState.get(path3.root_id) === 0n;
3275
+ const isPoolRootUsedBeforeByAnotherOffer = globalState.has(path2.root_id) && globalState.get(path2.root_id) === 0n;
3281
3276
  if (isPoolRootUsedBeforeByAnotherOffer) {
3282
3277
  offerHashInvalid.add(offerHash);
3283
3278
  intermediateState.clear();
@@ -3291,8 +3286,8 @@ async function nodeJsFindMatchingOffers(db, params) {
3291
3286
  intermediateState.clear();
3292
3287
  continue;
3293
3288
  }
3294
- const isNextPathUsingSameRoot = path3.root_id === pathsChunk[i + 1]?.root_id;
3295
- const isPoolRootTotallyConsumed = intermediateState.get(path3.root_id) === 0n;
3289
+ const isNextPathUsingSameRoot = path2.root_id === pathsChunk[i + 1]?.root_id;
3290
+ const isPoolRootTotallyConsumed = intermediateState.get(path2.root_id) === 0n;
3296
3291
  if (!isNextPathUsingSameRoot && !isPoolRootTotallyConsumed) {
3297
3292
  offerHashInvalid.add(offerHash);
3298
3293
  intermediateState.clear();
@@ -3800,7 +3795,7 @@ function connect2(parameters) {
3800
3795
  return Object.assign(client, { name: "pglite", pool });
3801
3796
  }
3802
3797
  async function applyMigrations(pg) {
3803
- const migrationsFolder = process.env.AWS_LAMBDA_FUNCTION_NAME ? path2__default.default.join(process.cwd(), "drizzle", VERSION) : path2__default.default.join(__dirname, "drizzle", VERSION);
3798
+ const migrationsFolder = process.env.AWS_LAMBDA_FUNCTION_NAME ? path__default.default.join(process.cwd(), "drizzle", VERSION) : path__default.default.join(__dirname, "drizzle", VERSION);
3804
3799
  await pg.execute(`create schema if not exists "${VERSION}"`);
3805
3800
  if (pg.name === "pg") {
3806
3801
  await migrator.migrate(pg, { migrationsFolder });
@@ -6029,588 +6024,6 @@ var HttpGetApiFailedError = class extends BaseError {
6029
6024
  }
6030
6025
  };
6031
6026
 
6032
- // src/evm/EVM.ts
6033
- var EVM_exports = {};
6034
- __export(EVM_exports, {
6035
- assetList: () => assetList,
6036
- assetMethods: () => assetMethods,
6037
- encodeConsumedEvent: () => encodeConsumedEvent,
6038
- factoryMethods: () => factoryMethods,
6039
- mock: () => mock,
6040
- mockAddress: () => mockAddress,
6041
- mockFactoryAddress: () => mockFactoryAddress,
6042
- mockMorphoAddress: () => mockMorphoAddress,
6043
- mockOracleAddress: () => mockOracleAddress,
6044
- morphoMethods: () => morphoMethods,
6045
- oracleMethods: () => oracleMethods,
6046
- serve: () => serve2,
6047
- users: () => users,
6048
- vaultMethods: () => vaultMethods
6049
- });
6050
- var users = [
6051
- accounts.privateKeyToAccount(
6052
- // first anvil account private key
6053
- "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
6054
- )
6055
- ];
6056
- var assetList = ["USDC", "DAI"];
6057
- var mockAddress = (asset) => {
6058
- return accounts.privateKeyToAccount(viem.keccak256(viem.toHex(asset))).address;
6059
- };
6060
- var mockOracleAddress = accounts.privateKeyToAccount(viem.keccak256(viem.toHex("ORACLE"))).address;
6061
- var mockMorphoAddress = accounts.privateKeyToAccount(viem.keccak256(viem.toHex("MORPHO"))).address;
6062
- var mockFactoryAddress = accounts.privateKeyToAccount(viem.keccak256(viem.toHex("FACTORY"))).address;
6063
- var encodeConsumedEvent = (parameters) => {
6064
- return viem.encodeFunctionData({
6065
- abi: [
6066
- {
6067
- type: "function",
6068
- name: "consume",
6069
- stateMutability: "nonpayable",
6070
- inputs: [
6071
- { name: "user", type: "address" },
6072
- { name: "nonce", type: "uint256" },
6073
- { name: "amount", type: "uint256" }
6074
- ],
6075
- outputs: []
6076
- }
6077
- ],
6078
- functionName: "consume",
6079
- args: [parameters.user, parameters.nonce, parameters.amount]
6080
- });
6081
- };
6082
- var assetMethods = ["balanceOf", "allowance"];
6083
- var oracleMethods = ["price"];
6084
- var morphoMethods = ["debtOf", "collateralOf", "market", "position"];
6085
- var vaultMethods = [
6086
- "asset",
6087
- "balanceOf",
6088
- "totalSupply",
6089
- "totalAssets",
6090
- "withdrawQueue"
6091
- ];
6092
- var factoryMethods = ["isMetaMorpho", "morpho"];
6093
- async function mock(name) {
6094
- const client = tevm.createMemoryClient({
6095
- account: users[0],
6096
- common: common.mainnet,
6097
- miningConfig: {
6098
- // makes tests deterministic by forcing to call mine() manually
6099
- type: "manual"
6100
- },
6101
- // makes tests faster by only waiting 50ms to fetch the current state
6102
- pollingInterval: 50
6103
- });
6104
- await client.tevmReady();
6105
- const mine = async () => {
6106
- await client.mine({ blocks: 1 });
6107
- };
6108
- const globalState = {};
6109
- const { createdAddress: mempoolAddress } = await tevm.tevmCall(client, {
6110
- data: fs__default.default.readFileSync(path2__default.default.join(__dirname, "bytecode", "mempool.txt"), "utf8"),
6111
- addToBlockchain: true
6112
- });
6113
- if (!mempoolAddress) throw new Error("Failed to deploy mempool contract");
6114
- const { createdAddress: termsAddress } = await tevm.tevmCall(client, {
6115
- data: fs__default.default.readFileSync(path2__default.default.join(__dirname, "bytecode", "terms.txt"), "utf8"),
6116
- addToBlockchain: true
6117
- });
6118
- if (!termsAddress) throw new Error("Failed to deploy terms contract");
6119
- await Promise.all(
6120
- users.map(
6121
- (u) => tevm.tevmSetAccount(client, {
6122
- address: u.address,
6123
- balance: viem.parseEther("100")
6124
- })
6125
- )
6126
- );
6127
- await Promise.all(
6128
- assetList.map((a) => {
6129
- const bytecode = fs__default.default.readFileSync(
6130
- path2__default.default.join(__dirname, "bytecode", "erc20.txt"),
6131
- "utf8"
6132
- );
6133
- return tevm.tevmSetAccount(client, {
6134
- address: mockAddress(a),
6135
- deployedBytecode: bytecode
6136
- });
6137
- })
6138
- );
6139
- const setAccount = async ({ address, state }) => {
6140
- const previousState = globalState[address] ?? {};
6141
- globalState[address] = { ...previousState, ...state };
6142
- await tevm.tevmSetAccount(client, {
6143
- address,
6144
- state: globalState[address]
6145
- });
6146
- };
6147
- const translate = (patch) => {
6148
- return Object.fromEntries(
6149
- Object.entries(patch).map(([k, v]) => {
6150
- if (typeof k === "string" && k.startsWith("0x")) {
6151
- if (typeof v !== "bigint" && typeof v !== "string") {
6152
- throw new Error("Invalid value");
6153
- }
6154
- return [k, typeof v === "bigint" ? viem.toHex(v) : v];
6155
- }
6156
- return stateFromAssetMethod(k, v);
6157
- })
6158
- );
6159
- };
6160
- const stateFromAssetMethod = (method, parameters) => {
6161
- if (method === "balanceOf") {
6162
- const { address: key, value } = parameters;
6163
- const slot = 9;
6164
- return [
6165
- viem.keccak256(viem.concatHex([viem.pad(key, { size: 32 }), viem.pad(viem.toHex(slot), { size: 32 })])),
6166
- viem.toHex(value)
6167
- ];
6168
- }
6169
- if (method === "allowance") {
6170
- const { owner: key, spender: key2, value } = parameters;
6171
- const slot = 10;
6172
- const outer = viem.keccak256(viem.concatHex([viem.pad(key, { size: 32 }), viem.pad(viem.toHex(slot), { size: 32 })]));
6173
- const inner = viem.keccak256(viem.concatHex([viem.pad(key2, { size: 32 }), viem.pad(outer, { size: 32 })]));
6174
- return [inner, viem.toHex(value)];
6175
- }
6176
- return ["0x0", "0x0"];
6177
- };
6178
- const mockedAssets = Object.fromEntries(
6179
- assetList.map((name2) => [
6180
- name2,
6181
- {
6182
- address: mockAddress(name2),
6183
- set: async (slot, parameters) => {
6184
- const patch = { [slot]: parameters };
6185
- await setAccount({
6186
- address: mockAddress(name2),
6187
- state: translate(
6188
- patch
6189
- )
6190
- });
6191
- }
6192
- }
6193
- ])
6194
- );
6195
- await Promise.all([
6196
- tevm.tevmSetAccount(client, {
6197
- address: mockOracleAddress,
6198
- deployedBytecode: fs__default.default.readFileSync(
6199
- path2__default.default.join(__dirname, "bytecode", "oracle.txt"),
6200
- "utf8"
6201
- )
6202
- }),
6203
- tevm.tevmSetAccount(client, {
6204
- address: mockMorphoAddress,
6205
- deployedBytecode: fs__default.default.readFileSync(
6206
- path2__default.default.join(__dirname, "bytecode", "morpho.txt"),
6207
- "utf8"
6208
- )
6209
- }),
6210
- tevm.tevmSetAccount(client, {
6211
- address: mockFactoryAddress,
6212
- deployedBytecode: fs__default.default.readFileSync(
6213
- path2__default.default.join(__dirname, "bytecode", "factory.txt"),
6214
- "utf8"
6215
- )
6216
- })
6217
- ]);
6218
- const mockedOracle = {
6219
- address: mockOracleAddress,
6220
- set: async (method, parameters) => {
6221
- if (method === "price") {
6222
- const { value } = parameters;
6223
- await tevm.tevmCall(client, {
6224
- to: mockOracleAddress,
6225
- data: viem.encodeFunctionData({
6226
- abi: [
6227
- {
6228
- type: "function",
6229
- name: "setPrice",
6230
- inputs: [{ name: "newPrice", type: "uint256" }],
6231
- outputs: [],
6232
- stateMutability: "nonpayable"
6233
- }
6234
- ],
6235
- functionName: "setPrice",
6236
- args: [value]
6237
- }),
6238
- addToBlockchain: true
6239
- });
6240
- }
6241
- }
6242
- };
6243
- const mockedMorpho = {
6244
- address: mockMorphoAddress,
6245
- set: async (method, parameters) => {
6246
- if (method === "debtOf") {
6247
- const { user, obligationId: obligationId2, value } = parameters;
6248
- await tevm.tevmCall(client, {
6249
- to: mockMorphoAddress,
6250
- data: viem.encodeFunctionData({
6251
- abi: [
6252
- {
6253
- type: "function",
6254
- name: "setDebtOf",
6255
- inputs: [
6256
- { name: "user", type: "address" },
6257
- { name: "termId", type: "bytes32" },
6258
- { name: "debt", type: "uint256" }
6259
- ],
6260
- outputs: [],
6261
- stateMutability: "nonpayable"
6262
- }
6263
- ],
6264
- functionName: "setDebtOf",
6265
- args: [user, obligationId2, value]
6266
- }),
6267
- addToBlockchain: true
6268
- });
6269
- } else if (method === "collateralOf") {
6270
- const { user, obligationId: obligationId2, collateralAsset, value } = parameters;
6271
- await tevm.tevmCall(client, {
6272
- to: mockMorphoAddress,
6273
- data: viem.encodeFunctionData({
6274
- abi: [
6275
- {
6276
- type: "function",
6277
- name: "setCollateralOf",
6278
- inputs: [
6279
- { name: "user", type: "address" },
6280
- { name: "termId", type: "bytes32" },
6281
- { name: "collateralAsset", type: "address" },
6282
- { name: "amount", type: "uint256" }
6283
- ],
6284
- outputs: [],
6285
- stateMutability: "nonpayable"
6286
- }
6287
- ],
6288
- functionName: "setCollateralOf",
6289
- args: [user, obligationId2, collateralAsset, value]
6290
- }),
6291
- addToBlockchain: true
6292
- });
6293
- } else if (method === "market") {
6294
- const {
6295
- marketId,
6296
- totalSupplyAssets,
6297
- totalSupplyShares,
6298
- totalBorrowAssets,
6299
- totalBorrowShares,
6300
- lastUpdate,
6301
- fee
6302
- } = parameters;
6303
- await tevm.tevmCall(client, {
6304
- to: mockMorphoAddress,
6305
- data: viem.encodeFunctionData({
6306
- abi: [
6307
- {
6308
- type: "function",
6309
- name: "setMarket",
6310
- inputs: [
6311
- { name: "id", type: "bytes32" },
6312
- { name: "totalSupplyAssets", type: "uint128" },
6313
- { name: "totalSupplyShares", type: "uint128" },
6314
- { name: "totalBorrowAssets", type: "uint128" },
6315
- { name: "totalBorrowShares", type: "uint128" },
6316
- { name: "lastUpdate", type: "uint128" },
6317
- { name: "fee", type: "uint128" }
6318
- ],
6319
- outputs: [],
6320
- stateMutability: "nonpayable"
6321
- }
6322
- ],
6323
- functionName: "setMarket",
6324
- args: [
6325
- marketId,
6326
- totalSupplyAssets,
6327
- totalSupplyShares,
6328
- totalBorrowAssets,
6329
- totalBorrowShares,
6330
- lastUpdate,
6331
- fee
6332
- ]
6333
- }),
6334
- addToBlockchain: true
6335
- });
6336
- } else if (method === "position") {
6337
- const { marketId, user, supplyShares, borrowShares, collateral } = parameters;
6338
- await tevm.tevmCall(client, {
6339
- to: mockMorphoAddress,
6340
- data: viem.encodeFunctionData({
6341
- abi: [
6342
- {
6343
- type: "function",
6344
- name: "setPosition",
6345
- inputs: [
6346
- { name: "id", type: "bytes32" },
6347
- { name: "user", type: "address" },
6348
- { name: "supplyShares", type: "uint256" },
6349
- { name: "borrowShares", type: "uint128" },
6350
- { name: "collateral", type: "uint128" }
6351
- ],
6352
- outputs: [],
6353
- stateMutability: "nonpayable"
6354
- }
6355
- ],
6356
- functionName: "setPosition",
6357
- args: [marketId, user, supplyShares, borrowShares, collateral]
6358
- }),
6359
- addToBlockchain: true
6360
- });
6361
- }
6362
- }
6363
- };
6364
- const mockedFactory = {
6365
- address: mockFactoryAddress,
6366
- set: async (method, parameters) => {
6367
- if (method === "isMetaMorpho") {
6368
- const { vault, value } = parameters;
6369
- await tevm.tevmCall(client, {
6370
- to: mockFactoryAddress,
6371
- data: viem.encodeFunctionData({
6372
- abi: [
6373
- {
6374
- type: "function",
6375
- name: "setIsMetaMorpho",
6376
- inputs: [
6377
- { name: "vault", type: "address" },
6378
- { name: "isValid", type: "bool" }
6379
- ],
6380
- outputs: [],
6381
- stateMutability: "nonpayable"
6382
- }
6383
- ],
6384
- functionName: "setIsMetaMorpho",
6385
- args: [vault, value]
6386
- }),
6387
- addToBlockchain: true
6388
- });
6389
- } else if (method === "morpho") {
6390
- const { value } = parameters;
6391
- await tevm.tevmCall(client, {
6392
- to: mockFactoryAddress,
6393
- data: viem.encodeFunctionData({
6394
- abi: [
6395
- {
6396
- type: "function",
6397
- name: "setMorpho",
6398
- inputs: [{ name: "morpho_", type: "address" }],
6399
- outputs: [],
6400
- stateMutability: "nonpayable"
6401
- }
6402
- ],
6403
- functionName: "setMorpho",
6404
- args: [value]
6405
- }),
6406
- addToBlockchain: true
6407
- });
6408
- }
6409
- }
6410
- };
6411
- const deployVault = async () => {
6412
- const vaultAddress = accounts.privateKeyToAccount(
6413
- viem.keccak256(viem.toHex(`VAULT_${Date.now()}_${Math.random()}`))
6414
- ).address;
6415
- await tevm.tevmSetAccount(client, {
6416
- address: vaultAddress,
6417
- deployedBytecode: fs__default.default.readFileSync(
6418
- path2__default.default.join(__dirname, "bytecode", "vault.txt"),
6419
- "utf8"
6420
- )
6421
- });
6422
- if (!vaultAddress) throw new Error("Failed to deploy vault contract");
6423
- return {
6424
- address: vaultAddress,
6425
- set: async (method, parameters) => {
6426
- if (method === "asset") {
6427
- const { value } = parameters;
6428
- await tevm.tevmCall(client, {
6429
- to: vaultAddress,
6430
- data: viem.encodeFunctionData({
6431
- abi: [
6432
- {
6433
- type: "function",
6434
- name: "setAsset",
6435
- inputs: [{ name: "asset_", type: "address" }],
6436
- outputs: [],
6437
- stateMutability: "nonpayable"
6438
- }
6439
- ],
6440
- functionName: "setAsset",
6441
- args: [value]
6442
- }),
6443
- addToBlockchain: true
6444
- });
6445
- } else if (method === "balanceOf") {
6446
- const { user, value } = parameters;
6447
- await tevm.tevmCall(client, {
6448
- to: vaultAddress,
6449
- data: viem.encodeFunctionData({
6450
- abi: [
6451
- {
6452
- type: "function",
6453
- name: "setBalanceOf",
6454
- inputs: [
6455
- { name: "user", type: "address" },
6456
- { name: "amount", type: "uint256" }
6457
- ],
6458
- outputs: [],
6459
- stateMutability: "nonpayable"
6460
- }
6461
- ],
6462
- functionName: "setBalanceOf",
6463
- args: [user, value]
6464
- }),
6465
- addToBlockchain: true
6466
- });
6467
- } else if (method === "totalSupply") {
6468
- const { value } = parameters;
6469
- await tevm.tevmCall(client, {
6470
- to: vaultAddress,
6471
- data: viem.encodeFunctionData({
6472
- abi: [
6473
- {
6474
- type: "function",
6475
- name: "setTotalSupply",
6476
- inputs: [{ name: "amount", type: "uint256" }],
6477
- outputs: [],
6478
- stateMutability: "nonpayable"
6479
- }
6480
- ],
6481
- functionName: "setTotalSupply",
6482
- args: [value]
6483
- }),
6484
- addToBlockchain: true
6485
- });
6486
- } else if (method === "totalAssets") {
6487
- const { value } = parameters;
6488
- await tevm.tevmCall(client, {
6489
- to: vaultAddress,
6490
- data: viem.encodeFunctionData({
6491
- abi: [
6492
- {
6493
- type: "function",
6494
- name: "setTotalAssets",
6495
- inputs: [{ name: "amount", type: "uint256" }],
6496
- outputs: [],
6497
- stateMutability: "nonpayable"
6498
- }
6499
- ],
6500
- functionName: "setTotalAssets",
6501
- args: [value]
6502
- }),
6503
- addToBlockchain: true
6504
- });
6505
- } else if (method === "withdrawQueue") {
6506
- const { value } = parameters;
6507
- await tevm.tevmCall(client, {
6508
- to: vaultAddress,
6509
- data: viem.encodeFunctionData({
6510
- abi: [
6511
- {
6512
- type: "function",
6513
- name: "setWithdrawQueue",
6514
- inputs: [{ name: "queue", type: "bytes32[]" }],
6515
- outputs: [],
6516
- stateMutability: "nonpayable"
6517
- }
6518
- ],
6519
- functionName: "setWithdrawQueue",
6520
- args: [value]
6521
- }),
6522
- addToBlockchain: true
6523
- });
6524
- }
6525
- }
6526
- };
6527
- };
6528
- return {
6529
- name,
6530
- client: Object.assign(client, {
6531
- extend: /* @__PURE__ */ ((originalExtend) => (actions) => {
6532
- const extended = originalExtend(actions);
6533
- const multicall = async (parameters) => {
6534
- const results = [];
6535
- for (const c of parameters.contracts) {
6536
- const data = viem.encodeFunctionData({
6537
- abi: c.abi,
6538
- functionName: c.functionName,
6539
- args: c.args ?? []
6540
- });
6541
- const callResult = await client.call({
6542
- to: c.address,
6543
- data,
6544
- ...parameters.blockNumber ? { blockNumber: parameters.blockNumber } : {}
6545
- });
6546
- try {
6547
- const decoded = viem.decodeFunctionResult({
6548
- abi: c.abi,
6549
- functionName: c.functionName,
6550
- data: callResult.data
6551
- });
6552
- if (parameters.allowFailure === true) {
6553
- results.push({ status: "success", result: decoded });
6554
- } else {
6555
- results.push(decoded);
6556
- }
6557
- } catch (err) {
6558
- if (parameters.allowFailure !== true) throw err;
6559
- results.push({ status: "failure", error: err });
6560
- }
6561
- }
6562
- return results;
6563
- };
6564
- return Object.assign({}, extended, { multicall });
6565
- })(client.extend.bind(client))
6566
- }),
6567
- mempoolAddress,
6568
- termsAddress,
6569
- mine,
6570
- reset: async () => await client.reset({ blockNumber: 0n }),
6571
- deployVault,
6572
- oracle: mockedOracle,
6573
- morpho: mockedMorpho,
6574
- factory: mockedFactory,
6575
- ...mockedAssets
6576
- };
6577
- }
6578
- async function serve2(parameters) {
6579
- const { port, forkUrl, blockNumber } = parameters;
6580
- let started = false;
6581
- const args = [
6582
- "--chain-id",
6583
- Chain_exports.ChainId.ANVIL.toString(),
6584
- "--fork-url",
6585
- forkUrl,
6586
- "--port",
6587
- String(port)
6588
- ];
6589
- if (blockNumber) args.push("--fork-block-number", String(blockNumber));
6590
- const stop = await new Promise((resolve, reject) => {
6591
- const subprocess = child_process.spawn("anvil", args, {
6592
- env: { ...process.env, FOUNDRY_DISABLE_NIGHTLY_WARNING: "1" }
6593
- });
6594
- subprocess.stdout.on("data", (data) => {
6595
- const message = `[port ${port}] ${data.toString()}`;
6596
- if (message.includes("Listening on")) {
6597
- started = true;
6598
- resolve(() => subprocess.kill("SIGINT"));
6599
- }
6600
- });
6601
- subprocess.stderr.on("data", (data) => {
6602
- const message = `[port ${port}] ${data.toString()}`;
6603
- console.warn(message);
6604
- if (!started) reject(message);
6605
- else console.warn(message);
6606
- });
6607
- });
6608
- return {
6609
- rpcUrl: `http://localhost:${port}`,
6610
- stop
6611
- };
6612
- }
6613
-
6614
6027
  exports.Abi = Abi_exports;
6615
6028
  exports.BrandTypeId = BrandTypeId;
6616
6029
  exports.Callback = Callback_exports;
@@ -6624,7 +6037,6 @@ exports.CollectorHealth = CollectorHealth;
6624
6037
  exports.CollectorStore = CollectorStore_exports;
6625
6038
  exports.CollectorsHealthResponse = CollectorsHealthResponse;
6626
6039
  exports.Cursor = Cursor_exports;
6627
- exports.EVM = EVM_exports;
6628
6040
  exports.Errors = Errors_exports;
6629
6041
  exports.Format = Format_exports;
6630
6042
  exports.Health = Health_exports;