@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.
@@ -2,7 +2,7 @@ import { serve as serve$1 } from '@hono/node-server';
2
2
  import { Hono } from 'hono';
3
3
  import { cors } from 'hono/cors';
4
4
  import { AsyncLocalStorage } from 'async_hooks';
5
- import { maxUint256, keccak256, toHex, isAddress, isHex, decodeAbiParameters, encodeAbiParameters, zeroAddress, hashTypedData, publicActions, parseUnits, createWalletClient, http, encodeFunctionData, parseEther, erc20Abi, stringify, getAddress, concatHex, pad, decodeFunctionResult, parseEventLogs } from 'viem';
5
+ import { maxUint256, isAddress, isHex, decodeAbiParameters, encodeAbiParameters, keccak256, zeroAddress, hashTypedData, publicActions, parseUnits, createWalletClient, http, erc20Abi, stringify, getAddress, parseEventLogs } from 'viem';
6
6
  import { getBlock, getLogs } from 'viem/actions';
7
7
  import { base, mainnet, anvil } from 'viem/chains';
8
8
  import * as z6 from 'zod';
@@ -10,7 +10,7 @@ import { Base64 } from 'js-base64';
10
10
  import { privateKeyToAccount, generatePrivateKey } from 'viem/accounts';
11
11
  import { asc, desc, sql, and, eq, gt, gte, lte, inArray } from 'drizzle-orm';
12
12
  import { pgSchema, integer, varchar, bigint, timestamp, text, boolean, numeric, index, primaryKey, uniqueIndex } from 'drizzle-orm/pg-core';
13
- import path2 from 'path';
13
+ import path from 'path';
14
14
  import { PGlite } from '@electric-sql/pglite';
15
15
  import { drizzle } from 'drizzle-orm/node-postgres';
16
16
  import { migrate } from 'drizzle-orm/node-postgres/migrator';
@@ -19,10 +19,6 @@ import { migrate as migrate$1 } from 'drizzle-orm/pglite/migrator';
19
19
  import { Pool } from 'pg';
20
20
  import { z } from 'zod/v4';
21
21
  import { createDocument } from 'zod-openapi';
22
- import { spawn } from 'child_process';
23
- import fs from 'fs';
24
- import { createMemoryClient, tevmCall, tevmSetAccount } from 'tevm';
25
- import { mainnet as mainnet$1 } from 'tevm/common';
26
22
 
27
23
  var __defProp = Object.defineProperty;
28
24
  var __export = (target, all) => {
@@ -3235,23 +3231,23 @@ async function nodeJsFindMatchingOffers(db, params) {
3235
3231
  })) {
3236
3232
  if (pathsChunk.length === 0) continue;
3237
3233
  for (let i = 0; i < pathsChunk.length; i++) {
3238
- const path3 = pathsChunk[i];
3239
- const offerHash = path3.offer_hash;
3234
+ const path2 = pathsChunk[i];
3235
+ const offerHash = path2.offer_hash;
3240
3236
  if (offerHashInvalid.has(offerHash) || offerHashValid.has(offerHash)) continue;
3241
- for (const poolId of path3.path) {
3237
+ for (const poolId of path2.path) {
3242
3238
  if (intermediateState.has(poolId)) continue;
3243
- const poolAmount = globalState.has(poolId) ? globalState.get(poolId) : BigInt(path3.pools.find((p) => p.pool_id === poolId)?.amount || 0);
3239
+ const poolAmount = globalState.has(poolId) ? globalState.get(poolId) : BigInt(path2.pools.find((p) => p.pool_id === poolId)?.amount || 0);
3244
3240
  intermediateState.set(poolId, poolAmount);
3245
3241
  }
3246
3242
  const bottleneck = Array.from(intermediateState.entries()).reduce((acc, [id2, curr]) => {
3247
- if (!path3.path.includes(id2) || id2 === path3.root_id) return acc;
3243
+ if (!path2.path.includes(id2) || id2 === path2.root_id) return acc;
3248
3244
  return acc < curr ? acc : curr;
3249
- }, intermediateState.get(path3.root_id));
3245
+ }, intermediateState.get(path2.root_id));
3250
3246
  for (const [poolId, amount] of intermediateState.entries()) {
3251
- if (!path3.path.includes(poolId)) continue;
3247
+ if (!path2.path.includes(poolId)) continue;
3252
3248
  intermediateState.set(poolId, amount - bottleneck);
3253
3249
  }
3254
- const isPoolRootUsedBeforeByAnotherOffer = globalState.has(path3.root_id) && globalState.get(path3.root_id) === 0n;
3250
+ const isPoolRootUsedBeforeByAnotherOffer = globalState.has(path2.root_id) && globalState.get(path2.root_id) === 0n;
3255
3251
  if (isPoolRootUsedBeforeByAnotherOffer) {
3256
3252
  offerHashInvalid.add(offerHash);
3257
3253
  intermediateState.clear();
@@ -3265,8 +3261,8 @@ async function nodeJsFindMatchingOffers(db, params) {
3265
3261
  intermediateState.clear();
3266
3262
  continue;
3267
3263
  }
3268
- const isNextPathUsingSameRoot = path3.root_id === pathsChunk[i + 1]?.root_id;
3269
- const isPoolRootTotallyConsumed = intermediateState.get(path3.root_id) === 0n;
3264
+ const isNextPathUsingSameRoot = path2.root_id === pathsChunk[i + 1]?.root_id;
3265
+ const isPoolRootTotallyConsumed = intermediateState.get(path2.root_id) === 0n;
3270
3266
  if (!isNextPathUsingSameRoot && !isPoolRootTotallyConsumed) {
3271
3267
  offerHashInvalid.add(offerHash);
3272
3268
  intermediateState.clear();
@@ -3774,7 +3770,7 @@ function connect2(parameters) {
3774
3770
  return Object.assign(client, { name: "pglite", pool });
3775
3771
  }
3776
3772
  async function applyMigrations(pg) {
3777
- const migrationsFolder = process.env.AWS_LAMBDA_FUNCTION_NAME ? path2.join(process.cwd(), "drizzle", VERSION) : path2.join(__dirname, "drizzle", VERSION);
3773
+ const migrationsFolder = process.env.AWS_LAMBDA_FUNCTION_NAME ? path.join(process.cwd(), "drizzle", VERSION) : path.join(__dirname, "drizzle", VERSION);
3778
3774
  await pg.execute(`create schema if not exists "${VERSION}"`);
3779
3775
  if (pg.name === "pg") {
3780
3776
  await migrate(pg, { migrationsFolder });
@@ -6003,588 +5999,6 @@ var HttpGetApiFailedError = class extends BaseError {
6003
5999
  }
6004
6000
  };
6005
6001
 
6006
- // src/evm/EVM.ts
6007
- var EVM_exports = {};
6008
- __export(EVM_exports, {
6009
- assetList: () => assetList,
6010
- assetMethods: () => assetMethods,
6011
- encodeConsumedEvent: () => encodeConsumedEvent,
6012
- factoryMethods: () => factoryMethods,
6013
- mock: () => mock,
6014
- mockAddress: () => mockAddress,
6015
- mockFactoryAddress: () => mockFactoryAddress,
6016
- mockMorphoAddress: () => mockMorphoAddress,
6017
- mockOracleAddress: () => mockOracleAddress,
6018
- morphoMethods: () => morphoMethods,
6019
- oracleMethods: () => oracleMethods,
6020
- serve: () => serve2,
6021
- users: () => users,
6022
- vaultMethods: () => vaultMethods
6023
- });
6024
- var users = [
6025
- privateKeyToAccount(
6026
- // first anvil account private key
6027
- "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
6028
- )
6029
- ];
6030
- var assetList = ["USDC", "DAI"];
6031
- var mockAddress = (asset) => {
6032
- return privateKeyToAccount(keccak256(toHex(asset))).address;
6033
- };
6034
- var mockOracleAddress = privateKeyToAccount(keccak256(toHex("ORACLE"))).address;
6035
- var mockMorphoAddress = privateKeyToAccount(keccak256(toHex("MORPHO"))).address;
6036
- var mockFactoryAddress = privateKeyToAccount(keccak256(toHex("FACTORY"))).address;
6037
- var encodeConsumedEvent = (parameters) => {
6038
- return encodeFunctionData({
6039
- abi: [
6040
- {
6041
- type: "function",
6042
- name: "consume",
6043
- stateMutability: "nonpayable",
6044
- inputs: [
6045
- { name: "user", type: "address" },
6046
- { name: "nonce", type: "uint256" },
6047
- { name: "amount", type: "uint256" }
6048
- ],
6049
- outputs: []
6050
- }
6051
- ],
6052
- functionName: "consume",
6053
- args: [parameters.user, parameters.nonce, parameters.amount]
6054
- });
6055
- };
6056
- var assetMethods = ["balanceOf", "allowance"];
6057
- var oracleMethods = ["price"];
6058
- var morphoMethods = ["debtOf", "collateralOf", "market", "position"];
6059
- var vaultMethods = [
6060
- "asset",
6061
- "balanceOf",
6062
- "totalSupply",
6063
- "totalAssets",
6064
- "withdrawQueue"
6065
- ];
6066
- var factoryMethods = ["isMetaMorpho", "morpho"];
6067
- async function mock(name) {
6068
- const client = createMemoryClient({
6069
- account: users[0],
6070
- common: mainnet$1,
6071
- miningConfig: {
6072
- // makes tests deterministic by forcing to call mine() manually
6073
- type: "manual"
6074
- },
6075
- // makes tests faster by only waiting 50ms to fetch the current state
6076
- pollingInterval: 50
6077
- });
6078
- await client.tevmReady();
6079
- const mine = async () => {
6080
- await client.mine({ blocks: 1 });
6081
- };
6082
- const globalState = {};
6083
- const { createdAddress: mempoolAddress } = await tevmCall(client, {
6084
- data: fs.readFileSync(path2.join(__dirname, "bytecode", "mempool.txt"), "utf8"),
6085
- addToBlockchain: true
6086
- });
6087
- if (!mempoolAddress) throw new Error("Failed to deploy mempool contract");
6088
- const { createdAddress: termsAddress } = await tevmCall(client, {
6089
- data: fs.readFileSync(path2.join(__dirname, "bytecode", "terms.txt"), "utf8"),
6090
- addToBlockchain: true
6091
- });
6092
- if (!termsAddress) throw new Error("Failed to deploy terms contract");
6093
- await Promise.all(
6094
- users.map(
6095
- (u) => tevmSetAccount(client, {
6096
- address: u.address,
6097
- balance: parseEther("100")
6098
- })
6099
- )
6100
- );
6101
- await Promise.all(
6102
- assetList.map((a) => {
6103
- const bytecode = fs.readFileSync(
6104
- path2.join(__dirname, "bytecode", "erc20.txt"),
6105
- "utf8"
6106
- );
6107
- return tevmSetAccount(client, {
6108
- address: mockAddress(a),
6109
- deployedBytecode: bytecode
6110
- });
6111
- })
6112
- );
6113
- const setAccount = async ({ address, state }) => {
6114
- const previousState = globalState[address] ?? {};
6115
- globalState[address] = { ...previousState, ...state };
6116
- await tevmSetAccount(client, {
6117
- address,
6118
- state: globalState[address]
6119
- });
6120
- };
6121
- const translate = (patch) => {
6122
- return Object.fromEntries(
6123
- Object.entries(patch).map(([k, v]) => {
6124
- if (typeof k === "string" && k.startsWith("0x")) {
6125
- if (typeof v !== "bigint" && typeof v !== "string") {
6126
- throw new Error("Invalid value");
6127
- }
6128
- return [k, typeof v === "bigint" ? toHex(v) : v];
6129
- }
6130
- return stateFromAssetMethod(k, v);
6131
- })
6132
- );
6133
- };
6134
- const stateFromAssetMethod = (method, parameters) => {
6135
- if (method === "balanceOf") {
6136
- const { address: key, value } = parameters;
6137
- const slot = 9;
6138
- return [
6139
- keccak256(concatHex([pad(key, { size: 32 }), pad(toHex(slot), { size: 32 })])),
6140
- toHex(value)
6141
- ];
6142
- }
6143
- if (method === "allowance") {
6144
- const { owner: key, spender: key2, value } = parameters;
6145
- const slot = 10;
6146
- const outer = keccak256(concatHex([pad(key, { size: 32 }), pad(toHex(slot), { size: 32 })]));
6147
- const inner = keccak256(concatHex([pad(key2, { size: 32 }), pad(outer, { size: 32 })]));
6148
- return [inner, toHex(value)];
6149
- }
6150
- return ["0x0", "0x0"];
6151
- };
6152
- const mockedAssets = Object.fromEntries(
6153
- assetList.map((name2) => [
6154
- name2,
6155
- {
6156
- address: mockAddress(name2),
6157
- set: async (slot, parameters) => {
6158
- const patch = { [slot]: parameters };
6159
- await setAccount({
6160
- address: mockAddress(name2),
6161
- state: translate(
6162
- patch
6163
- )
6164
- });
6165
- }
6166
- }
6167
- ])
6168
- );
6169
- await Promise.all([
6170
- tevmSetAccount(client, {
6171
- address: mockOracleAddress,
6172
- deployedBytecode: fs.readFileSync(
6173
- path2.join(__dirname, "bytecode", "oracle.txt"),
6174
- "utf8"
6175
- )
6176
- }),
6177
- tevmSetAccount(client, {
6178
- address: mockMorphoAddress,
6179
- deployedBytecode: fs.readFileSync(
6180
- path2.join(__dirname, "bytecode", "morpho.txt"),
6181
- "utf8"
6182
- )
6183
- }),
6184
- tevmSetAccount(client, {
6185
- address: mockFactoryAddress,
6186
- deployedBytecode: fs.readFileSync(
6187
- path2.join(__dirname, "bytecode", "factory.txt"),
6188
- "utf8"
6189
- )
6190
- })
6191
- ]);
6192
- const mockedOracle = {
6193
- address: mockOracleAddress,
6194
- set: async (method, parameters) => {
6195
- if (method === "price") {
6196
- const { value } = parameters;
6197
- await tevmCall(client, {
6198
- to: mockOracleAddress,
6199
- data: encodeFunctionData({
6200
- abi: [
6201
- {
6202
- type: "function",
6203
- name: "setPrice",
6204
- inputs: [{ name: "newPrice", type: "uint256" }],
6205
- outputs: [],
6206
- stateMutability: "nonpayable"
6207
- }
6208
- ],
6209
- functionName: "setPrice",
6210
- args: [value]
6211
- }),
6212
- addToBlockchain: true
6213
- });
6214
- }
6215
- }
6216
- };
6217
- const mockedMorpho = {
6218
- address: mockMorphoAddress,
6219
- set: async (method, parameters) => {
6220
- if (method === "debtOf") {
6221
- const { user, obligationId: obligationId2, value } = parameters;
6222
- await tevmCall(client, {
6223
- to: mockMorphoAddress,
6224
- data: encodeFunctionData({
6225
- abi: [
6226
- {
6227
- type: "function",
6228
- name: "setDebtOf",
6229
- inputs: [
6230
- { name: "user", type: "address" },
6231
- { name: "termId", type: "bytes32" },
6232
- { name: "debt", type: "uint256" }
6233
- ],
6234
- outputs: [],
6235
- stateMutability: "nonpayable"
6236
- }
6237
- ],
6238
- functionName: "setDebtOf",
6239
- args: [user, obligationId2, value]
6240
- }),
6241
- addToBlockchain: true
6242
- });
6243
- } else if (method === "collateralOf") {
6244
- const { user, obligationId: obligationId2, collateralAsset, value } = parameters;
6245
- await tevmCall(client, {
6246
- to: mockMorphoAddress,
6247
- data: encodeFunctionData({
6248
- abi: [
6249
- {
6250
- type: "function",
6251
- name: "setCollateralOf",
6252
- inputs: [
6253
- { name: "user", type: "address" },
6254
- { name: "termId", type: "bytes32" },
6255
- { name: "collateralAsset", type: "address" },
6256
- { name: "amount", type: "uint256" }
6257
- ],
6258
- outputs: [],
6259
- stateMutability: "nonpayable"
6260
- }
6261
- ],
6262
- functionName: "setCollateralOf",
6263
- args: [user, obligationId2, collateralAsset, value]
6264
- }),
6265
- addToBlockchain: true
6266
- });
6267
- } else if (method === "market") {
6268
- const {
6269
- marketId,
6270
- totalSupplyAssets,
6271
- totalSupplyShares,
6272
- totalBorrowAssets,
6273
- totalBorrowShares,
6274
- lastUpdate,
6275
- fee
6276
- } = parameters;
6277
- await tevmCall(client, {
6278
- to: mockMorphoAddress,
6279
- data: encodeFunctionData({
6280
- abi: [
6281
- {
6282
- type: "function",
6283
- name: "setMarket",
6284
- inputs: [
6285
- { name: "id", type: "bytes32" },
6286
- { name: "totalSupplyAssets", type: "uint128" },
6287
- { name: "totalSupplyShares", type: "uint128" },
6288
- { name: "totalBorrowAssets", type: "uint128" },
6289
- { name: "totalBorrowShares", type: "uint128" },
6290
- { name: "lastUpdate", type: "uint128" },
6291
- { name: "fee", type: "uint128" }
6292
- ],
6293
- outputs: [],
6294
- stateMutability: "nonpayable"
6295
- }
6296
- ],
6297
- functionName: "setMarket",
6298
- args: [
6299
- marketId,
6300
- totalSupplyAssets,
6301
- totalSupplyShares,
6302
- totalBorrowAssets,
6303
- totalBorrowShares,
6304
- lastUpdate,
6305
- fee
6306
- ]
6307
- }),
6308
- addToBlockchain: true
6309
- });
6310
- } else if (method === "position") {
6311
- const { marketId, user, supplyShares, borrowShares, collateral } = parameters;
6312
- await tevmCall(client, {
6313
- to: mockMorphoAddress,
6314
- data: encodeFunctionData({
6315
- abi: [
6316
- {
6317
- type: "function",
6318
- name: "setPosition",
6319
- inputs: [
6320
- { name: "id", type: "bytes32" },
6321
- { name: "user", type: "address" },
6322
- { name: "supplyShares", type: "uint256" },
6323
- { name: "borrowShares", type: "uint128" },
6324
- { name: "collateral", type: "uint128" }
6325
- ],
6326
- outputs: [],
6327
- stateMutability: "nonpayable"
6328
- }
6329
- ],
6330
- functionName: "setPosition",
6331
- args: [marketId, user, supplyShares, borrowShares, collateral]
6332
- }),
6333
- addToBlockchain: true
6334
- });
6335
- }
6336
- }
6337
- };
6338
- const mockedFactory = {
6339
- address: mockFactoryAddress,
6340
- set: async (method, parameters) => {
6341
- if (method === "isMetaMorpho") {
6342
- const { vault, value } = parameters;
6343
- await tevmCall(client, {
6344
- to: mockFactoryAddress,
6345
- data: encodeFunctionData({
6346
- abi: [
6347
- {
6348
- type: "function",
6349
- name: "setIsMetaMorpho",
6350
- inputs: [
6351
- { name: "vault", type: "address" },
6352
- { name: "isValid", type: "bool" }
6353
- ],
6354
- outputs: [],
6355
- stateMutability: "nonpayable"
6356
- }
6357
- ],
6358
- functionName: "setIsMetaMorpho",
6359
- args: [vault, value]
6360
- }),
6361
- addToBlockchain: true
6362
- });
6363
- } else if (method === "morpho") {
6364
- const { value } = parameters;
6365
- await tevmCall(client, {
6366
- to: mockFactoryAddress,
6367
- data: encodeFunctionData({
6368
- abi: [
6369
- {
6370
- type: "function",
6371
- name: "setMorpho",
6372
- inputs: [{ name: "morpho_", type: "address" }],
6373
- outputs: [],
6374
- stateMutability: "nonpayable"
6375
- }
6376
- ],
6377
- functionName: "setMorpho",
6378
- args: [value]
6379
- }),
6380
- addToBlockchain: true
6381
- });
6382
- }
6383
- }
6384
- };
6385
- const deployVault = async () => {
6386
- const vaultAddress = privateKeyToAccount(
6387
- keccak256(toHex(`VAULT_${Date.now()}_${Math.random()}`))
6388
- ).address;
6389
- await tevmSetAccount(client, {
6390
- address: vaultAddress,
6391
- deployedBytecode: fs.readFileSync(
6392
- path2.join(__dirname, "bytecode", "vault.txt"),
6393
- "utf8"
6394
- )
6395
- });
6396
- if (!vaultAddress) throw new Error("Failed to deploy vault contract");
6397
- return {
6398
- address: vaultAddress,
6399
- set: async (method, parameters) => {
6400
- if (method === "asset") {
6401
- const { value } = parameters;
6402
- await tevmCall(client, {
6403
- to: vaultAddress,
6404
- data: encodeFunctionData({
6405
- abi: [
6406
- {
6407
- type: "function",
6408
- name: "setAsset",
6409
- inputs: [{ name: "asset_", type: "address" }],
6410
- outputs: [],
6411
- stateMutability: "nonpayable"
6412
- }
6413
- ],
6414
- functionName: "setAsset",
6415
- args: [value]
6416
- }),
6417
- addToBlockchain: true
6418
- });
6419
- } else if (method === "balanceOf") {
6420
- const { user, value } = parameters;
6421
- await tevmCall(client, {
6422
- to: vaultAddress,
6423
- data: encodeFunctionData({
6424
- abi: [
6425
- {
6426
- type: "function",
6427
- name: "setBalanceOf",
6428
- inputs: [
6429
- { name: "user", type: "address" },
6430
- { name: "amount", type: "uint256" }
6431
- ],
6432
- outputs: [],
6433
- stateMutability: "nonpayable"
6434
- }
6435
- ],
6436
- functionName: "setBalanceOf",
6437
- args: [user, value]
6438
- }),
6439
- addToBlockchain: true
6440
- });
6441
- } else if (method === "totalSupply") {
6442
- const { value } = parameters;
6443
- await tevmCall(client, {
6444
- to: vaultAddress,
6445
- data: encodeFunctionData({
6446
- abi: [
6447
- {
6448
- type: "function",
6449
- name: "setTotalSupply",
6450
- inputs: [{ name: "amount", type: "uint256" }],
6451
- outputs: [],
6452
- stateMutability: "nonpayable"
6453
- }
6454
- ],
6455
- functionName: "setTotalSupply",
6456
- args: [value]
6457
- }),
6458
- addToBlockchain: true
6459
- });
6460
- } else if (method === "totalAssets") {
6461
- const { value } = parameters;
6462
- await tevmCall(client, {
6463
- to: vaultAddress,
6464
- data: encodeFunctionData({
6465
- abi: [
6466
- {
6467
- type: "function",
6468
- name: "setTotalAssets",
6469
- inputs: [{ name: "amount", type: "uint256" }],
6470
- outputs: [],
6471
- stateMutability: "nonpayable"
6472
- }
6473
- ],
6474
- functionName: "setTotalAssets",
6475
- args: [value]
6476
- }),
6477
- addToBlockchain: true
6478
- });
6479
- } else if (method === "withdrawQueue") {
6480
- const { value } = parameters;
6481
- await tevmCall(client, {
6482
- to: vaultAddress,
6483
- data: encodeFunctionData({
6484
- abi: [
6485
- {
6486
- type: "function",
6487
- name: "setWithdrawQueue",
6488
- inputs: [{ name: "queue", type: "bytes32[]" }],
6489
- outputs: [],
6490
- stateMutability: "nonpayable"
6491
- }
6492
- ],
6493
- functionName: "setWithdrawQueue",
6494
- args: [value]
6495
- }),
6496
- addToBlockchain: true
6497
- });
6498
- }
6499
- }
6500
- };
6501
- };
6502
- return {
6503
- name,
6504
- client: Object.assign(client, {
6505
- extend: /* @__PURE__ */ ((originalExtend) => (actions) => {
6506
- const extended = originalExtend(actions);
6507
- const multicall = async (parameters) => {
6508
- const results = [];
6509
- for (const c of parameters.contracts) {
6510
- const data = encodeFunctionData({
6511
- abi: c.abi,
6512
- functionName: c.functionName,
6513
- args: c.args ?? []
6514
- });
6515
- const callResult = await client.call({
6516
- to: c.address,
6517
- data,
6518
- ...parameters.blockNumber ? { blockNumber: parameters.blockNumber } : {}
6519
- });
6520
- try {
6521
- const decoded = decodeFunctionResult({
6522
- abi: c.abi,
6523
- functionName: c.functionName,
6524
- data: callResult.data
6525
- });
6526
- if (parameters.allowFailure === true) {
6527
- results.push({ status: "success", result: decoded });
6528
- } else {
6529
- results.push(decoded);
6530
- }
6531
- } catch (err) {
6532
- if (parameters.allowFailure !== true) throw err;
6533
- results.push({ status: "failure", error: err });
6534
- }
6535
- }
6536
- return results;
6537
- };
6538
- return Object.assign({}, extended, { multicall });
6539
- })(client.extend.bind(client))
6540
- }),
6541
- mempoolAddress,
6542
- termsAddress,
6543
- mine,
6544
- reset: async () => await client.reset({ blockNumber: 0n }),
6545
- deployVault,
6546
- oracle: mockedOracle,
6547
- morpho: mockedMorpho,
6548
- factory: mockedFactory,
6549
- ...mockedAssets
6550
- };
6551
- }
6552
- async function serve2(parameters) {
6553
- const { port, forkUrl, blockNumber } = parameters;
6554
- let started = false;
6555
- const args = [
6556
- "--chain-id",
6557
- Chain_exports.ChainId.ANVIL.toString(),
6558
- "--fork-url",
6559
- forkUrl,
6560
- "--port",
6561
- String(port)
6562
- ];
6563
- if (blockNumber) args.push("--fork-block-number", String(blockNumber));
6564
- const stop = await new Promise((resolve, reject) => {
6565
- const subprocess = spawn("anvil", args, {
6566
- env: { ...process.env, FOUNDRY_DISABLE_NIGHTLY_WARNING: "1" }
6567
- });
6568
- subprocess.stdout.on("data", (data) => {
6569
- const message = `[port ${port}] ${data.toString()}`;
6570
- if (message.includes("Listening on")) {
6571
- started = true;
6572
- resolve(() => subprocess.kill("SIGINT"));
6573
- }
6574
- });
6575
- subprocess.stderr.on("data", (data) => {
6576
- const message = `[port ${port}] ${data.toString()}`;
6577
- console.warn(message);
6578
- if (!started) reject(message);
6579
- else console.warn(message);
6580
- });
6581
- });
6582
- return {
6583
- rpcUrl: `http://localhost:${port}`,
6584
- stop
6585
- };
6586
- }
6587
-
6588
- export { Abi_exports as Abi, BrandTypeId, Callback_exports as Callback, Chain_exports as Chain, ChainHealth, ChainStore_exports as ChainStore, ChainsHealthResponse, Collateral_exports as Collateral, collectors_exports as Collector, CollectorHealth, CollectorStore_exports as CollectorStore, CollectorsHealthResponse, Cursor_exports as Cursor, EVM_exports as EVM, Errors_exports as Errors, Format_exports as Format, Health_exports as Health, LLTV_exports as LLTV, Liquidity_exports as Liquidity, LiquidityStore_exports as LiquidityStore, Logger_exports as Logger, Maturity_exports as Maturity, mempool_exports as Mempool, Obligation_exports as Obligation, ObligationResponse_exports as ObligationResponse, Offer_exports as Offer, OfferResponse_exports as OfferResponse, OfferStore_exports as OfferStore, schema_exports as OffersSchema, OpenApi, PG_exports as PG, Api_exports2 as RouterApi, Client_exports as RouterClient, RouterIndexer_exports as RouterIndexer, RouterStatusResponse, Services_exports as Services, time_exports as Time, utils_exports as Utils, Validation_exports as Validation, ValidationRule_exports as ValidationRule, parse, safeParse };
6002
+ export { Abi_exports as Abi, BrandTypeId, Callback_exports as Callback, Chain_exports as Chain, ChainHealth, ChainStore_exports as ChainStore, ChainsHealthResponse, Collateral_exports as Collateral, collectors_exports as Collector, CollectorHealth, CollectorStore_exports as CollectorStore, CollectorsHealthResponse, Cursor_exports as Cursor, Errors_exports as Errors, Format_exports as Format, Health_exports as Health, LLTV_exports as LLTV, Liquidity_exports as Liquidity, LiquidityStore_exports as LiquidityStore, Logger_exports as Logger, Maturity_exports as Maturity, mempool_exports as Mempool, Obligation_exports as Obligation, ObligationResponse_exports as ObligationResponse, Offer_exports as Offer, OfferResponse_exports as OfferResponse, OfferStore_exports as OfferStore, schema_exports as OffersSchema, OpenApi, PG_exports as PG, Api_exports2 as RouterApi, Client_exports as RouterClient, RouterIndexer_exports as RouterIndexer, RouterStatusResponse, Services_exports as Services, time_exports as Time, utils_exports as Utils, Validation_exports as Validation, ValidationRule_exports as ValidationRule, parse, safeParse };
6589
6003
  //# sourceMappingURL=index.node.mjs.map
6590
6004
  //# sourceMappingURL=index.node.mjs.map