@morpho-dev/router 0.1.0 → 0.1.2

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.
@@ -1,54 +1,15 @@
1
1
  import * as _morpho_dev_mempool from '@morpho-dev/mempool';
2
- import { Compute, Offer, Errors, Format, Maturity, LLTV } from '@morpho-dev/mempool';
2
+ import { Offer, Errors, Format, Maturity, LLTV, Compute, Chain } from '@morpho-dev/mempool';
3
3
  export * from '@morpho-dev/mempool';
4
- import * as viem from 'viem';
5
- import { Address, Hex, PublicClient } from 'viem';
6
- import { Chain as Chain$2 } from 'viem/chains';
7
4
  import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
8
- import * as zod_v4 from 'zod/v4';
9
5
  import { z, ZodError } from 'zod/v4';
10
- import * as zod_v4_core from 'zod/v4/core';
6
+ import * as viem from 'viem';
7
+ import { Address, Hex, PublicClient } from 'viem';
11
8
  import * as hono_utils_types from 'hono/utils/types';
12
9
  import * as hono from 'hono';
13
10
  import { Context } from 'hono';
14
11
  import * as hono_utils_http_status from 'hono/utils/http-status';
15
12
 
16
- declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
17
- type ChainName = (typeof chainNames)[number];
18
- declare const ChainId: {
19
- ETHEREUM: bigint;
20
- BASE: bigint;
21
- "ETHEREUM-VIRTUAL-TESTNET": bigint;
22
- };
23
- type ChainId = (typeof ChainId)[keyof typeof ChainId];
24
- declare const chainIds: Set<bigint>;
25
- type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
26
- id: ChainId;
27
- name: ChainName;
28
- whitelistedAssets: Set<Address>;
29
- morpho: Address;
30
- mempool?: {
31
- address: Address;
32
- deploymentBlock: number;
33
- reindexBuffer: number;
34
- };
35
- }>;
36
- declare function getChain(chainId: ChainId): Chain | undefined;
37
- declare const getWhitelistedChains: () => Chain[];
38
- declare const chains: Record<ChainName, Chain>;
39
-
40
- type Chain$1_Chain = Chain;
41
- type Chain$1_ChainId = ChainId;
42
- type Chain$1_ChainName = ChainName;
43
- declare const Chain$1_chainIds: typeof chainIds;
44
- declare const Chain$1_chainNames: typeof chainNames;
45
- declare const Chain$1_chains: typeof chains;
46
- declare const Chain$1_getChain: typeof getChain;
47
- declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
48
- declare namespace Chain$1 {
49
- export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain, Chain$1_getWhitelistedChains as getWhitelistedChains };
50
- }
51
-
52
13
  declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
53
14
 
54
15
  declare const schemas: {
@@ -137,29 +98,29 @@ type OfferConsumed = {
137
98
  };
138
99
  declare const RouterOfferSchema: (parameters?: {
139
100
  omitHash?: boolean;
140
- }) => zod_v4.ZodObject<{
141
- offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
142
- assets: zod_v4.ZodBigInt;
143
- rate: zod_v4.ZodBigInt;
144
- maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
145
- expiry: zod_v4.ZodNumber;
146
- start: zod_v4.ZodNumber;
147
- nonce: zod_v4.ZodBigInt;
148
- buy: zod_v4.ZodBoolean;
149
- chainId: zod_v4.ZodBigInt;
150
- loanToken: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
151
- collaterals: zod_v4.ZodArray<zod_v4.ZodObject<{
152
- asset: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
153
- oracle: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
154
- lltv: zod_v4.ZodPipe<zod_v4.ZodBigInt, zod_v4.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
155
- }, zod_v4_core.$strip>>;
156
- callback: zod_v4.ZodObject<{
157
- address: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
158
- data: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
159
- gasLimit: zod_v4.ZodBigInt;
160
- }, zod_v4_core.$strip>;
161
- signature: zod_v4.ZodOptional<zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>>;
162
- createdAt: zod_v4.ZodOptional<zod_v4.ZodNumber>;
101
+ }) => z.ZodObject<{
102
+ offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
103
+ assets: z.ZodBigInt;
104
+ rate: z.ZodBigInt;
105
+ maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
106
+ expiry: z.ZodNumber;
107
+ start: z.ZodNumber;
108
+ nonce: z.ZodBigInt;
109
+ buy: z.ZodBoolean;
110
+ chainId: z.ZodBigInt;
111
+ loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
112
+ collaterals: z.ZodArray<z.ZodObject<{
113
+ asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
114
+ oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
115
+ lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
116
+ }, z.core.$strip>>;
117
+ callback: z.ZodObject<{
118
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
119
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
120
+ gasLimit: z.ZodBigInt;
121
+ }, z.core.$strip>;
122
+ signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
123
+ createdAt: z.ZodOptional<z.ZodNumber>;
163
124
  consumed: z.ZodBigInt;
164
125
  status: z.ZodEnum<{
165
126
  valid: "valid";
@@ -170,7 +131,7 @@ declare const RouterOfferSchema: (parameters?: {
170
131
  metadata: z.ZodOptional<z.ZodObject<{
171
132
  issue: z.ZodString;
172
133
  }, z.core.$strip>>;
173
- }, zod_v4_core.$strip>;
134
+ }, z.core.$strip>;
174
135
  /**
175
136
  * ABI for the Consumed event emitted by the terms contract.
176
137
  */
@@ -475,19 +436,6 @@ type OfferStore = {
475
436
  nonce: Offer.Offer["nonce"];
476
437
  consumed: bigint;
477
438
  }) => Promise<void>;
478
- /** Persist latest indexing progress for a chain and event type. */
479
- saveLatestBlockNumberProcessed: (parameters: {
480
- chainId: Offer.Offer["chainId"];
481
- eventType: "offer_created" | "offer_consumed";
482
- latestBlockNumber: number;
483
- }) => Promise<void>;
484
- /** Retrieve latest indexing progress for a chain and event type. */
485
- getLatestBlockNumberProcessed: (parameters: {
486
- chainId: Offer.Offer["chainId"];
487
- eventType: "offer_created" | "offer_consumed";
488
- }) => Promise<{
489
- latestBlockNumber: number;
490
- } | null>;
491
439
  };
492
440
  type GetOffersFilters = {
493
441
  creators?: string[];
@@ -548,7 +496,7 @@ declare function memory(parameters: {
548
496
  status: OfferStatus;
549
497
  metadata?: OfferMetadata;
550
498
  }>;
551
- filled: Map<ChainId, Map<Address, Map<bigint, bigint>>>;
499
+ filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
552
500
  }): OfferStore;
553
501
 
554
502
  type index$2_FindMatchingOffersParams = FindMatchingOffersParams;
@@ -850,10 +798,10 @@ declare function single<Name extends string, T, Ctx = void>(name: Name, run: Sin
850
798
  */
851
799
  declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
852
800
  type MorphoContext = {
853
- publicClients: Partial<Record<ChainName, PublicClient>>;
801
+ publicClients: Partial<Record<Chain.ChainName, PublicClient>>;
854
802
  };
855
803
  declare function morpho(parameters: {
856
- whitelistedChains: Chain[];
804
+ whitelistedChains: Chain.Chain[];
857
805
  }): (Rule<{
858
806
  readonly offering: Address;
859
807
  readonly assets: bigint;
@@ -1053,4 +1001,4 @@ declare namespace Validation {
1053
1001
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
1054
1002
  }
1055
1003
 
1056
- export { index$3 as ApiSchema, Chain$1 as Chain, Logger$1 as Logger, index$2 as OfferStore, index$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
1004
+ export { index$3 as ApiSchema, Logger$1 as Logger, index$2 as OfferStore, index$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
@@ -1,54 +1,15 @@
1
1
  import * as _morpho_dev_mempool from '@morpho-dev/mempool';
2
- import { Compute, Offer, Errors, Format, Maturity, LLTV } from '@morpho-dev/mempool';
2
+ import { Offer, Errors, Format, Maturity, LLTV, Compute, Chain } from '@morpho-dev/mempool';
3
3
  export * from '@morpho-dev/mempool';
4
- import * as viem from 'viem';
5
- import { Address, Hex, PublicClient } from 'viem';
6
- import { Chain as Chain$2 } from 'viem/chains';
7
4
  import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
8
- import * as zod_v4 from 'zod/v4';
9
5
  import { z, ZodError } from 'zod/v4';
10
- import * as zod_v4_core from 'zod/v4/core';
6
+ import * as viem from 'viem';
7
+ import { Address, Hex, PublicClient } from 'viem';
11
8
  import * as hono_utils_types from 'hono/utils/types';
12
9
  import * as hono from 'hono';
13
10
  import { Context } from 'hono';
14
11
  import * as hono_utils_http_status from 'hono/utils/http-status';
15
12
 
16
- declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
17
- type ChainName = (typeof chainNames)[number];
18
- declare const ChainId: {
19
- ETHEREUM: bigint;
20
- BASE: bigint;
21
- "ETHEREUM-VIRTUAL-TESTNET": bigint;
22
- };
23
- type ChainId = (typeof ChainId)[keyof typeof ChainId];
24
- declare const chainIds: Set<bigint>;
25
- type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
26
- id: ChainId;
27
- name: ChainName;
28
- whitelistedAssets: Set<Address>;
29
- morpho: Address;
30
- mempool?: {
31
- address: Address;
32
- deploymentBlock: number;
33
- reindexBuffer: number;
34
- };
35
- }>;
36
- declare function getChain(chainId: ChainId): Chain | undefined;
37
- declare const getWhitelistedChains: () => Chain[];
38
- declare const chains: Record<ChainName, Chain>;
39
-
40
- type Chain$1_Chain = Chain;
41
- type Chain$1_ChainId = ChainId;
42
- type Chain$1_ChainName = ChainName;
43
- declare const Chain$1_chainIds: typeof chainIds;
44
- declare const Chain$1_chainNames: typeof chainNames;
45
- declare const Chain$1_chains: typeof chains;
46
- declare const Chain$1_getChain: typeof getChain;
47
- declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
48
- declare namespace Chain$1 {
49
- export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain, Chain$1_getWhitelistedChains as getWhitelistedChains };
50
- }
51
-
52
13
  declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;
53
14
 
54
15
  declare const schemas: {
@@ -137,29 +98,29 @@ type OfferConsumed = {
137
98
  };
138
99
  declare const RouterOfferSchema: (parameters?: {
139
100
  omitHash?: boolean;
140
- }) => zod_v4.ZodObject<{
141
- offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
142
- assets: zod_v4.ZodBigInt;
143
- rate: zod_v4.ZodBigInt;
144
- maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
145
- expiry: zod_v4.ZodNumber;
146
- start: zod_v4.ZodNumber;
147
- nonce: zod_v4.ZodBigInt;
148
- buy: zod_v4.ZodBoolean;
149
- chainId: zod_v4.ZodBigInt;
150
- loanToken: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
151
- collaterals: zod_v4.ZodArray<zod_v4.ZodObject<{
152
- asset: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
153
- oracle: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
154
- lltv: zod_v4.ZodPipe<zod_v4.ZodBigInt, zod_v4.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
155
- }, zod_v4_core.$strip>>;
156
- callback: zod_v4.ZodObject<{
157
- address: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
158
- data: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
159
- gasLimit: zod_v4.ZodBigInt;
160
- }, zod_v4_core.$strip>;
161
- signature: zod_v4.ZodOptional<zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>>;
162
- createdAt: zod_v4.ZodOptional<zod_v4.ZodNumber>;
101
+ }) => z.ZodObject<{
102
+ offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
103
+ assets: z.ZodBigInt;
104
+ rate: z.ZodBigInt;
105
+ maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
106
+ expiry: z.ZodNumber;
107
+ start: z.ZodNumber;
108
+ nonce: z.ZodBigInt;
109
+ buy: z.ZodBoolean;
110
+ chainId: z.ZodBigInt;
111
+ loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
112
+ collaterals: z.ZodArray<z.ZodObject<{
113
+ asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
114
+ oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
115
+ lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
116
+ }, z.core.$strip>>;
117
+ callback: z.ZodObject<{
118
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
119
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
120
+ gasLimit: z.ZodBigInt;
121
+ }, z.core.$strip>;
122
+ signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
123
+ createdAt: z.ZodOptional<z.ZodNumber>;
163
124
  consumed: z.ZodBigInt;
164
125
  status: z.ZodEnum<{
165
126
  valid: "valid";
@@ -170,7 +131,7 @@ declare const RouterOfferSchema: (parameters?: {
170
131
  metadata: z.ZodOptional<z.ZodObject<{
171
132
  issue: z.ZodString;
172
133
  }, z.core.$strip>>;
173
- }, zod_v4_core.$strip>;
134
+ }, z.core.$strip>;
174
135
  /**
175
136
  * ABI for the Consumed event emitted by the terms contract.
176
137
  */
@@ -475,19 +436,6 @@ type OfferStore = {
475
436
  nonce: Offer.Offer["nonce"];
476
437
  consumed: bigint;
477
438
  }) => Promise<void>;
478
- /** Persist latest indexing progress for a chain and event type. */
479
- saveLatestBlockNumberProcessed: (parameters: {
480
- chainId: Offer.Offer["chainId"];
481
- eventType: "offer_created" | "offer_consumed";
482
- latestBlockNumber: number;
483
- }) => Promise<void>;
484
- /** Retrieve latest indexing progress for a chain and event type. */
485
- getLatestBlockNumberProcessed: (parameters: {
486
- chainId: Offer.Offer["chainId"];
487
- eventType: "offer_created" | "offer_consumed";
488
- }) => Promise<{
489
- latestBlockNumber: number;
490
- } | null>;
491
439
  };
492
440
  type GetOffersFilters = {
493
441
  creators?: string[];
@@ -548,7 +496,7 @@ declare function memory(parameters: {
548
496
  status: OfferStatus;
549
497
  metadata?: OfferMetadata;
550
498
  }>;
551
- filled: Map<ChainId, Map<Address, Map<bigint, bigint>>>;
499
+ filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
552
500
  }): OfferStore;
553
501
 
554
502
  type index$2_FindMatchingOffersParams = FindMatchingOffersParams;
@@ -850,10 +798,10 @@ declare function single<Name extends string, T, Ctx = void>(name: Name, run: Sin
850
798
  */
851
799
  declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
852
800
  type MorphoContext = {
853
- publicClients: Partial<Record<ChainName, PublicClient>>;
801
+ publicClients: Partial<Record<Chain.ChainName, PublicClient>>;
854
802
  };
855
803
  declare function morpho(parameters: {
856
- whitelistedChains: Chain[];
804
+ whitelistedChains: Chain.Chain[];
857
805
  }): (Rule<{
858
806
  readonly offering: Address;
859
807
  readonly assets: bigint;
@@ -1053,4 +1001,4 @@ declare namespace Validation {
1053
1001
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
1054
1002
  }
1055
1003
 
1056
- export { index$3 as ApiSchema, Chain$1 as Chain, Logger$1 as Logger, index$2 as OfferStore, index$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
1004
+ export { index$3 as ApiSchema, Logger$1 as Logger, index$2 as OfferStore, index$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var mempool = require('@morpho-dev/mempool');
4
- var chains$1 = require('viem/chains');
5
4
  var v4 = require('zod/v4');
6
5
  var zodOpenapi = require('zod-openapi');
7
6
  var viem = require('viem');
@@ -16,85 +15,6 @@ var __export = (target, all) => {
16
15
  __defProp(target, name, { get: all[name], enumerable: true });
17
16
  };
18
17
 
19
- // src/Chain.ts
20
- var Chain_exports = {};
21
- __export(Chain_exports, {
22
- ChainId: () => ChainId,
23
- chainIds: () => chainIds,
24
- chainNames: () => chainNames,
25
- chains: () => chains,
26
- getChain: () => getChain,
27
- getWhitelistedChains: () => getWhitelistedChains
28
- });
29
- var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
30
- var ChainId = {
31
- ETHEREUM: BigInt(chains$1.mainnet.id),
32
- BASE: BigInt(chains$1.base.id),
33
- "ETHEREUM-VIRTUAL-TESTNET": 109111114n
34
- };
35
- var chainIds = new Set(Object.values(ChainId));
36
- var chainNameLookup = new Map(Object.entries(ChainId).map(([key, value]) => [value, key]));
37
- function getChain(chainId) {
38
- const chainName = chainNameLookup.get(chainId)?.toLowerCase();
39
- if (!chainName) {
40
- return void 0;
41
- }
42
- return chains[chainName];
43
- }
44
- var getWhitelistedChains = () => {
45
- return [chains.ethereum, chains.base, chains["ethereum-virtual-testnet"]];
46
- };
47
- var chains = {
48
- ethereum: {
49
- ...chains$1.mainnet,
50
- id: ChainId.ETHEREUM,
51
- name: "ethereum",
52
- whitelistedAssets: new Set(
53
- [
54
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
55
- // USDC
56
- "0x6B175474E89094C44Da98b954EedeAC495271d0F"
57
- // DAI
58
- ].map((address) => address.toLowerCase())
59
- ),
60
- morpho: "0x0000000000000000000000000000000000000000"
61
- },
62
- base: {
63
- ...chains$1.base,
64
- id: ChainId.BASE,
65
- name: "base",
66
- whitelistedAssets: new Set(
67
- [
68
- "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
69
- // USDC
70
- "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"
71
- // DAI
72
- ].map((address) => address.toLowerCase())
73
- ),
74
- morpho: "0x0000000000000000000000000000000000000000"
75
- },
76
- "ethereum-virtual-testnet": {
77
- ...chains$1.mainnet,
78
- id: 109111114n,
79
- name: "ethereum-virtual-testnet",
80
- whitelistedAssets: new Set(
81
- [
82
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
83
- // USDC
84
- "0x6B175474E89094C44Da98b954EedeAC495271d0F"
85
- // DAI
86
- ].map((address) => address.toLowerCase())
87
- ),
88
- morpho: "0x11a002d45db720ed47a80d2f3489cba5b833eaf5",
89
- // @TODO: This is mock Consumed contract, update with Terms once stable
90
- mempool: {
91
- address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
92
- deploymentBlock: 23223727,
93
- reindexBuffer: 10
94
- }
95
- }
96
- };
97
-
98
18
  // src/core/apiSchema/index.ts
99
19
  var apiSchema_exports = {};
100
20
  __export(apiSchema_exports, {
@@ -418,12 +338,15 @@ var GetOffersQueryParams = v4.z.object({
418
338
  description: "Filter by multiple rate oracles (comma-separated)",
419
339
  example: "0x1234567890123456789012345678901234567890,0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"
420
340
  }),
421
- collateral_tuple: v4.z.string().regex(
422
- /^(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]+)?)?)*$/,
423
- {
424
- 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)."
341
+ collateral_tuple: v4.z.string().transform((val, ctx) => {
342
+ const pattern = /^(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]+)?)?)*$/;
343
+ if (!pattern.test(val)) {
344
+ ctx.addIssue({
345
+ code: "custom",
346
+ message: "collateral_tuple has an invalid format",
347
+ input: val
348
+ });
425
349
  }
426
- ).transform((val, ctx) => {
427
350
  return val.split("#").map((tuple) => {
428
351
  const parts = tuple.split(":");
429
352
  if (parts.length === 0 || !parts[0]) {
@@ -553,9 +476,23 @@ var MatchOffersQueryParams = v4.z.object({
553
476
  description: "The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell. If your intent is to sell, buy offers will be returned, and vice versa.",
554
477
  example: "buy"
555
478
  }),
556
- chain_id: v4.z.string().regex(/^\d+$/, {
557
- message: "Chain ID must be a positive integer"
558
- }).transform((val) => Number.parseInt(val, 10)).pipe(v4.z.number().positive()).meta({
479
+ chain_id: v4.z.string().transform((val, ctx) => {
480
+ const numericLike = /^-?\d+$/.test(val);
481
+ if (!numericLike) {
482
+ ctx.addIssue({
483
+ code: "custom",
484
+ message: "chain_id has an invalid format",
485
+ input: val
486
+ });
487
+ ctx.addIssue({
488
+ code: "custom",
489
+ message: "Invalid input: expected number, received NaN",
490
+ input: val
491
+ });
492
+ return v4.z.NEVER;
493
+ }
494
+ return Number.parseInt(val, 10);
495
+ }).pipe(v4.z.number().positive()).meta({
559
496
  description: "The blockchain network chain ID",
560
497
  example: "1"
561
498
  }),
@@ -567,12 +504,15 @@ var MatchOffersQueryParams = v4.z.object({
567
504
  example: "1000000000000000000"
568
505
  }),
569
506
  // Collateral filtering
570
- collaterals: v4.z.string().regex(
571
- /^(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]+)?)*$/,
572
- {
573
- message: "Collaterals must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. All fields are required for each collateral."
507
+ collaterals: v4.z.string().transform((val, ctx) => {
508
+ const pattern = /^(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]+)?)*$/;
509
+ if (!pattern.test(val)) {
510
+ ctx.addIssue({
511
+ code: "custom",
512
+ message: "Collaterals must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. All fields are required for each collateral.",
513
+ input: val
514
+ });
574
515
  }
575
- ).transform((val, ctx) => {
576
516
  return val.split("#").map((collateral) => {
577
517
  const parts = collateral.split(":");
578
518
  if (parts.length !== 3) {
@@ -1082,7 +1022,6 @@ function memory(parameters) {
1082
1022
  const map = parameters.offers;
1083
1023
  const filled = parameters.filled;
1084
1024
  const consumedIds = /* @__PURE__ */ new Set();
1085
- const indexingProgress = /* @__PURE__ */ new Map();
1086
1025
  const create = async (parameters2) => {
1087
1026
  if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
1088
1027
  map.set(parameters2.offer.hash.toLowerCase(), {
@@ -1153,7 +1092,7 @@ function memory(parameters) {
1153
1092
  let {
1154
1093
  creators,
1155
1094
  side,
1156
- chains: chains2,
1095
+ chains,
1157
1096
  loanTokens,
1158
1097
  status = ["valid"],
1159
1098
  callbackAddresses,
@@ -1224,7 +1163,7 @@ function memory(parameters) {
1224
1163
  offers = offers.filter((o) => o.expiry >= now);
1225
1164
  creators && (offers = offers.filter((o) => creators.includes(o.offering.toLowerCase())));
1226
1165
  side && (offers = offers.filter((o) => o.buy === buy));
1227
- chains2 && (offers = offers.filter((o) => chains2.includes(Number(o.chainId))));
1166
+ chains && (offers = offers.filter((o) => chains.includes(Number(o.chainId))));
1228
1167
  loanTokens && (offers = offers.filter((o) => loanTokens.includes(o.loanToken.toLowerCase())));
1229
1168
  status && (offers = offers.filter((o) => status.includes(o.status)));
1230
1169
  callbackAddresses && (offers = offers.filter(
@@ -1430,15 +1369,6 @@ function memory(parameters) {
1430
1369
  filledForOffering.set(nonce, current + parameters2.consumed);
1431
1370
  filledForChain.set(address, filledForOffering);
1432
1371
  filled.set(chainId, filledForChain);
1433
- },
1434
- saveLatestBlockNumberProcessed: async (parameters2) => {
1435
- const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
1436
- indexingProgress.set(key, parameters2.latestBlockNumber);
1437
- },
1438
- getLatestBlockNumberProcessed: async (parameters2) => {
1439
- const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
1440
- const value = indexingProgress.get(key);
1441
- return value === void 0 ? null : { latestBlockNumber: value };
1442
1372
  }
1443
1373
  };
1444
1374
  }
@@ -1826,7 +1756,7 @@ function morpho(parameters) {
1826
1756
  );
1827
1757
  const buyOffersPerLoanAsset = /* @__PURE__ */ new Map();
1828
1758
  for (const offer of buyOffers) {
1829
- const chainName = getChain(offer.chainId)?.name;
1759
+ const chainName = mempool.Chain.getChain(offer.chainId)?.name;
1830
1760
  const loanTokens = buyOffersPerLoanAsset.get(chainName) ?? /* @__PURE__ */ new Map();
1831
1761
  const offers2 = loanTokens.get(offer.loanToken.toLowerCase()) ?? [];
1832
1762
  offers2.push(offer);
@@ -1837,7 +1767,7 @@ function morpho(parameters) {
1837
1767
  Array.from(buyOffersPerLoanAsset.entries()).map(async ([name, loanTokens]) => {
1838
1768
  const chainName = name;
1839
1769
  const publicClient = publicClients[chainName];
1840
- const morpho2 = morphoPerChain.get(chains[chainName].id);
1770
+ const morpho2 = morphoPerChain.get(mempool.Chain.chains[chainName].id);
1841
1771
  if (!publicClient) {
1842
1772
  const offers2 = Array.from(loanTokens.values()).flat();
1843
1773
  for (const offer of offers2) {
@@ -1918,7 +1848,6 @@ function morpho(parameters) {
1918
1848
  }
1919
1849
 
1920
1850
  exports.ApiSchema = apiSchema_exports;
1921
- exports.Chain = Chain_exports;
1922
1851
  exports.Logger = Logger_exports;
1923
1852
  exports.OfferStore = OfferStore_exports;
1924
1853
  exports.Router = router_exports;