@morpho-org/blue-sdk 6.2.0 → 6.3.0

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.
package/lib/cjs/chain.js CHANGED
@@ -1,434 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChainUtils = exports.ChainId = void 0;
4
- /** Supported EIP-155 chain ids with Morpho Blue deployments or registry metadata. */
5
- var ChainId;
6
- (function (ChainId) {
7
- ChainId[ChainId["EthMainnet"] = 1] = "EthMainnet";
8
- ChainId[ChainId["BaseMainnet"] = 8453] = "BaseMainnet";
9
- ChainId[ChainId["PolygonMainnet"] = 137] = "PolygonMainnet";
10
- ChainId[ChainId["ArbitrumMainnet"] = 42161] = "ArbitrumMainnet";
11
- ChainId[ChainId["OptimismMainnet"] = 10] = "OptimismMainnet";
12
- ChainId[ChainId["WorldChainMainnet"] = 480] = "WorldChainMainnet";
13
- ChainId[ChainId["FraxtalMainnet"] = 252] = "FraxtalMainnet";
14
- ChainId[ChainId["ScrollMainnet"] = 534352] = "ScrollMainnet";
15
- ChainId[ChainId["InkMainnet"] = 57073] = "InkMainnet";
16
- ChainId[ChainId["Unichain"] = 130] = "Unichain";
17
- ChainId[ChainId["SonicMainnet"] = 146] = "SonicMainnet";
18
- ChainId[ChainId["HemiMainnet"] = 43111] = "HemiMainnet";
19
- ChainId[ChainId["ModeMainnet"] = 34443] = "ModeMainnet";
20
- ChainId[ChainId["CornMainnet"] = 21000000] = "CornMainnet";
21
- ChainId[ChainId["PlumeMainnet"] = 98866] = "PlumeMainnet";
22
- ChainId[ChainId["CampMainnet"] = 123420001114] = "CampMainnet";
23
- ChainId[ChainId["KatanaMainnet"] = 747474] = "KatanaMainnet";
24
- ChainId[ChainId["EtherlinkMainnet"] = 42793] = "EtherlinkMainnet";
25
- ChainId[ChainId["TacMainnet"] = 239] = "TacMainnet";
26
- ChainId[ChainId["LiskMainnet"] = 1135] = "LiskMainnet";
27
- ChainId[ChainId["HyperliquidMainnet"] = 999] = "HyperliquidMainnet";
28
- ChainId[ChainId["SeiMainnet"] = 1329] = "SeiMainnet";
29
- ChainId[ChainId["ZeroGMainnet"] = 16661] = "ZeroGMainnet";
30
- ChainId[ChainId["LineaMainnet"] = 59144] = "LineaMainnet";
31
- ChainId[ChainId["MonadMainnet"] = 143] = "MonadMainnet";
32
- ChainId[ChainId["StableMainnet"] = 988] = "StableMainnet";
33
- ChainId[ChainId["CronosMainnet"] = 25] = "CronosMainnet";
34
- ChainId[ChainId["CeloMainnet"] = 42220] = "CeloMainnet";
35
- ChainId[ChainId["AbstractMainnet"] = 2741] = "AbstractMainnet";
36
- ChainId[ChainId["BitlayerMainnet"] = 200901] = "BitlayerMainnet";
37
- ChainId[ChainId["BscMainnet"] = 56] = "BscMainnet";
38
- ChainId[ChainId["SoneiumMainnet"] = 1868] = "SoneiumMainnet";
39
- ChainId[ChainId["TempoMainnet"] = 4217] = "TempoMainnet";
40
- ChainId[ChainId["EdenMainnet"] = 714] = "EdenMainnet";
41
- ChainId[ChainId["PharosMainnet"] = 1672] = "PharosMainnet";
42
- ChainId[ChainId["GensynMainnet"] = 685689] = "GensynMainnet";
43
- ChainId[ChainId["FlareMainnet"] = 14] = "FlareMainnet";
44
- ChainId[ChainId["XdcMainnet"] = 50] = "XdcMainnet";
45
- ChainId[ChainId["KaiaMainnet"] = 8217] = "KaiaMainnet";
46
- ChainId[ChainId["ArcMainnet"] = 5042] = "ArcMainnet";
47
- ChainId[ChainId["MorphMainnet"] = 2818] = "MorphMainnet";
48
- ChainId[ChainId["MegaEthMainnet"] = 4326] = "MegaEthMainnet";
49
- })(ChainId || (exports.ChainId = ChainId = {}));
50
- /** Chain metadata helpers and registries. */
51
- var ChainUtils;
52
- (function (ChainUtils) {
53
- /**
54
- * Returns whether native token balances are reliable on a chain.
55
- *
56
- * @param chainId - The EIP-155 chain id to inspect.
57
- * @returns `false` only for chains whose metadata marks native balances as unreliable.
58
- * @example
59
- * ```ts
60
- * import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
61
- *
62
- * const reliable = ChainUtils.hasReliableNativeBalance(ChainId.EthMainnet);
63
- * // reliable === true
64
- * ```
65
- */
66
- ChainUtils.hasReliableNativeBalance = (chainId) => {
67
- return (ChainUtils.CHAIN_METADATA[chainId]
68
- ?.hasReliableNativeBalance ?? true);
69
- };
70
- /**
71
- * Converts a supported chain id to its hexadecimal JSON-RPC form.
72
- *
73
- * @param chainId - The supported chain id.
74
- * @returns The chain id as a `0x`-prefixed hexadecimal string.
75
- * @example
76
- * ```ts
77
- * import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
78
- *
79
- * const hexChainId = ChainUtils.toHexChainId(ChainId.EthMainnet);
80
- * // hexChainId === "0x1"
81
- * ```
82
- */
83
- ChainUtils.toHexChainId = (chainId) => {
84
- return `0x${chainId.toString(16)}`;
85
- };
86
- /**
87
- * Returns the block explorer base URL for a supported chain.
88
- *
89
- * @param chainId - The supported chain id.
90
- * @returns The chain's configured block explorer base URL.
91
- * @example
92
- * ```ts
93
- * import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
94
- *
95
- * const explorerUrl = ChainUtils.getExplorerUrl(ChainId.EthMainnet);
96
- * // explorerUrl === "https://etherscan.io"
97
- * ```
98
- */
99
- ChainUtils.getExplorerUrl = (chainId) => {
100
- return ChainUtils.CHAIN_METADATA[chainId].explorerUrl;
101
- };
102
- /**
103
- * Returns a block explorer address URL for a supported chain.
104
- *
105
- * @param chainId - The supported chain id.
106
- * @param address - The address to link to.
107
- * @returns The block explorer URL for `address`.
108
- * @example
109
- * ```ts
110
- * import { ChainId, ChainUtils, NATIVE_ADDRESS } from "@morpho-org/blue-sdk";
111
- *
112
- * const url = ChainUtils.getExplorerAddressUrl(ChainId.EthMainnet, NATIVE_ADDRESS);
113
- * // url satisfies string
114
- * ```
115
- */
116
- ChainUtils.getExplorerAddressUrl = (chainId, address) => {
117
- return `${ChainUtils.getExplorerUrl(chainId)}/address/${address}`;
118
- };
119
- /**
120
- * Returns a block explorer transaction URL for a supported chain.
121
- *
122
- * @param chainId - The supported chain id.
123
- * @param tx - The transaction hash to link to.
124
- * @returns The block explorer URL for `tx`.
125
- * @example
126
- * ```ts
127
- * import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
128
- *
129
- * const url = ChainUtils.getExplorerTransactionUrl(ChainId.EthMainnet, "0xabc");
130
- * // url satisfies string
131
- * ```
132
- */
133
- ChainUtils.getExplorerTransactionUrl = (chainId, tx) => {
134
- return `${ChainUtils.getExplorerUrl(chainId)}/tx/${tx}`;
135
- };
136
- /** Metadata for each supported chain, keyed by `ChainId`. */
137
- ChainUtils.CHAIN_METADATA = {
138
- [ChainId.EthMainnet]: {
139
- name: "Ethereum",
140
- id: ChainId.EthMainnet,
141
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
142
- explorerUrl: "https://etherscan.io",
143
- identifier: "mainnet",
144
- },
145
- [ChainId.BaseMainnet]: {
146
- name: "Base",
147
- id: ChainId.BaseMainnet,
148
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
149
- explorerUrl: "https://basescan.org",
150
- identifier: "base",
151
- },
152
- [ChainId.PolygonMainnet]: {
153
- name: "Polygon",
154
- id: ChainId.PolygonMainnet,
155
- nativeCurrency: { name: "Polygon", symbol: "POL", decimals: 18 },
156
- explorerUrl: "https://polygonscan.com",
157
- identifier: "polygon",
158
- },
159
- [ChainId.ArbitrumMainnet]: {
160
- name: "Arbitrum One",
161
- id: ChainId.ArbitrumMainnet,
162
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
163
- explorerUrl: "https://arbiscan.io",
164
- identifier: "arbitrum",
165
- },
166
- [ChainId.OptimismMainnet]: {
167
- name: "OP Mainnet",
168
- id: ChainId.OptimismMainnet,
169
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
170
- explorerUrl: "https://optimistic.etherscan.io",
171
- identifier: "optimism",
172
- },
173
- [ChainId.WorldChainMainnet]: {
174
- name: "World Chain",
175
- id: ChainId.WorldChainMainnet,
176
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
177
- explorerUrl: "https://worldscan.org",
178
- identifier: "worldchain",
179
- },
180
- [ChainId.FraxtalMainnet]: {
181
- name: "Fraxtal",
182
- id: ChainId.FraxtalMainnet,
183
- nativeCurrency: { name: "Frax Ether", symbol: "frxETH", decimals: 18 },
184
- explorerUrl: "https://fraxscan.com",
185
- identifier: "fraxtal",
186
- },
187
- [ChainId.ScrollMainnet]: {
188
- name: "Scroll",
189
- id: ChainId.ScrollMainnet,
190
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
191
- explorerUrl: "https://scrollscan.com",
192
- identifier: "scroll",
193
- },
194
- [ChainId.InkMainnet]: {
195
- name: "Ink",
196
- id: ChainId.InkMainnet,
197
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
198
- explorerUrl: "https://explorer.inkonchain.com",
199
- identifier: "ink",
200
- },
201
- [ChainId.Unichain]: {
202
- name: "Unichain",
203
- id: ChainId.Unichain,
204
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
205
- explorerUrl: "https://uniscan.xyz",
206
- identifier: "unichain",
207
- },
208
- [ChainId.SonicMainnet]: {
209
- name: "Sonic",
210
- id: ChainId.SonicMainnet,
211
- nativeCurrency: { name: "Sonic", symbol: "S", decimals: 18 },
212
- explorerUrl: "https://sonicscan.org",
213
- identifier: "sonic",
214
- },
215
- [ChainId.HemiMainnet]: {
216
- name: "Hemi",
217
- id: ChainId.HemiMainnet,
218
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
219
- explorerUrl: "https://explorer.hemi.xyz",
220
- identifier: "hemi",
221
- },
222
- [ChainId.ModeMainnet]: {
223
- name: "Mode",
224
- id: ChainId.ModeMainnet,
225
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
226
- explorerUrl: "https://modescan.io",
227
- identifier: "mode",
228
- },
229
- [ChainId.CornMainnet]: {
230
- name: "Corn",
231
- id: ChainId.CornMainnet,
232
- nativeCurrency: { name: "Bitcoin", symbol: "BTCN", decimals: 18 },
233
- explorerUrl: "https://cornscan.io",
234
- identifier: "corn",
235
- },
236
- [ChainId.PlumeMainnet]: {
237
- name: "Plume",
238
- id: ChainId.PlumeMainnet,
239
- nativeCurrency: { name: "Plume", symbol: "PLUME", decimals: 18 },
240
- explorerUrl: "https://explorer.plume.org",
241
- identifier: "plume",
242
- },
243
- [ChainId.CampMainnet]: {
244
- name: "Camp",
245
- id: ChainId.CampMainnet,
246
- nativeCurrency: { name: "Camp", symbol: "CAMP", decimals: 18 },
247
- explorerUrl: "https://basecamp.cloud.blockscout.com",
248
- identifier: "camp",
249
- },
250
- [ChainId.KatanaMainnet]: {
251
- name: "Katana",
252
- id: ChainId.KatanaMainnet,
253
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
254
- explorerUrl: "https://katanascan.com",
255
- identifier: "katana",
256
- },
257
- [ChainId.EtherlinkMainnet]: {
258
- name: "Etherlink",
259
- id: ChainId.EtherlinkMainnet,
260
- nativeCurrency: { name: "Tezos", symbol: "XTZ", decimals: 18 },
261
- explorerUrl: "https://explorer.etherlink.com",
262
- identifier: "etherlink",
263
- },
264
- [ChainId.TacMainnet]: {
265
- name: "TAC",
266
- id: ChainId.TacMainnet,
267
- nativeCurrency: { name: "TAC", symbol: "TAC", decimals: 18 },
268
- explorerUrl: "https://explorer.tac.build/",
269
- identifier: "tac",
270
- },
271
- [ChainId.LiskMainnet]: {
272
- name: "Lisk",
273
- id: ChainId.LiskMainnet,
274
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
275
- explorerUrl: "https://blockscout.lisk.com",
276
- identifier: "lisk",
277
- },
278
- [ChainId.HyperliquidMainnet]: {
279
- name: "Hyperliquid",
280
- id: ChainId.HyperliquidMainnet,
281
- nativeCurrency: { name: "Hype", symbol: "HYPE", decimals: 18 },
282
- explorerUrl: "https://hyperevmscan.io",
283
- identifier: "hyperliquid",
284
- },
285
- [ChainId.SeiMainnet]: {
286
- name: "Sei",
287
- id: ChainId.SeiMainnet,
288
- nativeCurrency: { name: "Sei", symbol: "SEI", decimals: 18 },
289
- explorerUrl: "https://seitrace.com",
290
- identifier: "sei",
291
- },
292
- [ChainId.ZeroGMainnet]: {
293
- name: "0G",
294
- id: ChainId.ZeroGMainnet,
295
- nativeCurrency: { name: "0G", symbol: "0G", decimals: 18 },
296
- explorerUrl: "https://chainscan.0g.ai",
297
- identifier: "0G",
298
- },
299
- [ChainId.LineaMainnet]: {
300
- name: "Linea",
301
- id: ChainId.LineaMainnet,
302
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
303
- explorerUrl: "https://lineascan.build",
304
- identifier: "linea",
305
- },
306
- [ChainId.MonadMainnet]: {
307
- name: "Monad",
308
- id: ChainId.MonadMainnet,
309
- nativeCurrency: { name: "Monad", symbol: "MON", decimals: 18 },
310
- explorerUrl: "https://monadscan.com",
311
- identifier: "monad",
312
- },
313
- [ChainId.StableMainnet]: {
314
- name: "Stable",
315
- id: ChainId.StableMainnet,
316
- nativeCurrency: { name: "USDT0", symbol: "USDT0", decimals: 18 },
317
- explorerUrl: "https://stablescan.xyz",
318
- identifier: "stable",
319
- },
320
- [ChainId.CronosMainnet]: {
321
- name: "Cronos",
322
- id: ChainId.CronosMainnet,
323
- nativeCurrency: { name: "Cronos", symbol: "CRO", decimals: 18 },
324
- explorerUrl: "https://explorer.cronos.org",
325
- identifier: "cronos",
326
- },
327
- [ChainId.CeloMainnet]: {
328
- name: "Celo",
329
- id: ChainId.CeloMainnet,
330
- nativeCurrency: { name: "Celo", symbol: "CELO", decimals: 18 },
331
- explorerUrl: "https://celoscan.io/",
332
- identifier: "celo",
333
- },
334
- [ChainId.AbstractMainnet]: {
335
- name: "Abstract",
336
- id: ChainId.AbstractMainnet,
337
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
338
- explorerUrl: "https://abscan.org/",
339
- identifier: "abstract",
340
- },
341
- [ChainId.BitlayerMainnet]: {
342
- name: "Bitlayer",
343
- id: ChainId.BitlayerMainnet,
344
- nativeCurrency: { name: "Bitcoin", symbol: "BTC", decimals: 18 },
345
- explorerUrl: "https://www.btrscan.com",
346
- identifier: "bitlayer",
347
- },
348
- [ChainId.BscMainnet]: {
349
- name: "Bnb Smart Chain",
350
- id: ChainId.BscMainnet,
351
- nativeCurrency: { name: "Bnb", symbol: "BNB", decimals: 18 },
352
- explorerUrl: "https://bscscan.com",
353
- identifier: "bsc",
354
- },
355
- [ChainId.SoneiumMainnet]: {
356
- name: "Soneium",
357
- id: ChainId.SoneiumMainnet,
358
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
359
- explorerUrl: "https://soneium.blockscout.com/",
360
- identifier: "soneium",
361
- },
362
- [ChainId.TempoMainnet]: {
363
- name: "Tempo",
364
- id: ChainId.TempoMainnet,
365
- nativeCurrency: { name: "USD", symbol: "USD", decimals: 18 },
366
- explorerUrl: "https://explore.tempo.xyz",
367
- identifier: "tempo",
368
- hasReliableNativeBalance: false,
369
- },
370
- [ChainId.EdenMainnet]: {
371
- name: "Eden",
372
- id: ChainId.EdenMainnet,
373
- nativeCurrency: { name: "TIA", symbol: "TIA", decimals: 18 },
374
- explorerUrl: "https://eden.blockscout.com",
375
- identifier: "eden",
376
- },
377
- [ChainId.PharosMainnet]: {
378
- name: "Pharos",
379
- id: ChainId.PharosMainnet,
380
- nativeCurrency: { name: "PharosCoin", symbol: "PROS", decimals: 18 },
381
- explorerUrl: "https://pharosscan.xyz",
382
- identifier: "pharos",
383
- },
384
- [ChainId.GensynMainnet]: {
385
- name: "Gensyn",
386
- id: ChainId.GensynMainnet,
387
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
388
- explorerUrl: "https://gensyn-mainnet.explorer.alchemy.com",
389
- identifier: "gensyn",
390
- },
391
- [ChainId.FlareMainnet]: {
392
- name: "Flare",
393
- id: ChainId.FlareMainnet,
394
- nativeCurrency: { name: "Flare", symbol: "FLR", decimals: 18 },
395
- explorerUrl: "https://mainnet.flarescan.com",
396
- identifier: "flare",
397
- },
398
- [ChainId.XdcMainnet]: {
399
- name: "XDC",
400
- id: ChainId.XdcMainnet,
401
- nativeCurrency: { name: "XDC", symbol: "XDC", decimals: 18 },
402
- explorerUrl: "https://xdcscan.com",
403
- identifier: "xdc",
404
- },
405
- [ChainId.KaiaMainnet]: {
406
- name: "Kaia",
407
- id: ChainId.KaiaMainnet,
408
- nativeCurrency: { name: "Kaia", symbol: "KAIA", decimals: 18 },
409
- explorerUrl: "https://kaiascan.io",
410
- identifier: "kaia",
411
- },
412
- [ChainId.ArcMainnet]: {
413
- name: "Arc",
414
- id: ChainId.ArcMainnet,
415
- nativeCurrency: { name: "USDC", symbol: "USDC", decimals: 18 },
416
- explorerUrl: "http://explorer.arc.io/",
417
- identifier: "arc",
418
- },
419
- [ChainId.MorphMainnet]: {
420
- name: "Morph",
421
- id: ChainId.MorphMainnet,
422
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
423
- explorerUrl: "https://explorer.morphl2.io",
424
- identifier: "morph",
425
- },
426
- [ChainId.MegaEthMainnet]: {
427
- name: "MegaETH",
428
- id: ChainId.MegaEthMainnet,
429
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
430
- explorerUrl: "https://mega.etherscan.io",
431
- identifier: "megaeth",
432
- },
433
- };
434
- })(ChainUtils || (exports.ChainUtils = ChainUtils = {}));
4
+ var morpho_ts_1 = require("@morpho-org/morpho-ts");
5
+ Object.defineProperty(exports, "ChainId", { enumerable: true, get: function () { return morpho_ts_1.ChainId; } });
6
+ Object.defineProperty(exports, "ChainUtils", { enumerable: true, get: function () { return morpho_ts_1.ChainUtils; } });
@@ -9,7 +9,7 @@ export declare const MAX_LIQUIDATION_INCENTIVE_FACTOR = 1150000000000000000n;
9
9
  /**
10
10
  * The scale of the oracle price. Hardcoded to 1e36.
11
11
  */
12
- export declare const ORACLE_PRICE_SCALE = 1000000000000000000000000000000000000n;
12
+ export declare const ORACLE_PRICE_SCALE: bigint;
13
13
  /**
14
14
  * The default slippage tolerance used in the SDK. Hardcoded to 0.03%.
15
15
  */
@@ -13,7 +13,7 @@ exports.MAX_LIQUIDATION_INCENTIVE_FACTOR = 1150000000000000000n;
13
13
  /**
14
14
  * The scale of the oracle price. Hardcoded to 1e36.
15
15
  */
16
- exports.ORACLE_PRICE_SCALE = 1000000000000000000000000000000000000n;
16
+ exports.ORACLE_PRICE_SCALE = morpho_ts_1.ORACLE_PRICE_SCALE;
17
17
  /**
18
18
  * The default slippage tolerance used in the SDK. Hardcoded to 0.03%.
19
19
  */
@@ -1,3 +1,4 @@
1
+ export { _try, DivisionByZeroError, type ErrorClass, IncompleteChainRegistryError, InvalidBitLengthError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnsupportedChainIdError, } from "@morpho-org/morpho-ts";
1
2
  import { type Hex } from "viem";
2
3
  import type { Address, MarketId } from "./types.js";
3
4
  /** Error thrown when bytes cannot be decoded into valid Morpho Blue market params. */
@@ -33,11 +34,6 @@ export declare class UnknownMarketAllocationError extends UnknownDataError {
33
34
  readonly marketId: MarketId;
34
35
  constructor(marketId: MarketId);
35
36
  }
36
- /** Error thrown when a chain id has no configured SDK registry entry. */
37
- export declare class UnsupportedChainIdError extends Error {
38
- readonly chainId: number;
39
- constructor(chainId: number);
40
- }
41
37
  /** Error thrown when no default pre-liquidation params exist for an LLTV. */
42
38
  export declare class UnsupportedPreLiquidationParamsError extends Error {
43
39
  readonly lltv: bigint;
@@ -122,19 +118,3 @@ export declare class UnknownOfFactory extends Error {
122
118
  readonly address: Address;
123
119
  constructor(factory: Address, address: Address);
124
120
  }
125
- /** Constructor type for errors accepted by `_try`. */
126
- export interface ErrorClass<E extends Error = Error> {
127
- new (...args: any[]): E;
128
- }
129
- /**
130
- * Runs an async accessor and returns `undefined` for expected lookup errors.
131
- *
132
- * @internal
133
- */
134
- export declare function _try<T, ErrorClasses extends readonly ErrorClass[] = []>(accessor: () => Promise<T>, ...errorClasses: ErrorClasses): Promise<T | undefined>;
135
- /**
136
- * Runs a sync accessor and returns `undefined` for expected lookup errors.
137
- *
138
- * @internal
139
- */
140
- export declare function _try<T, ErrorClasses extends readonly ErrorClass[] = []>(accessor: () => T, ...errorClasses: ErrorClasses): T | undefined;
package/lib/cjs/errors.js CHANGED
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnknownOfFactory = exports.UnknownFactory = exports.VaultV2Errors = exports.BlueErrors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownMarketAllocationError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = exports.InvalidMarketParamsError = void 0;
4
- exports._try = _try;
3
+ exports.UnknownOfFactory = exports.UnknownFactory = exports.VaultV2Errors = exports.BlueErrors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnknownMarketAllocationError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = exports.InvalidMarketParamsError = exports.UnsupportedChainIdError = exports.UnknownAddressError = exports.RegistryValueAlreadyRegisteredError = exports.InvalidBitLengthError = exports.IncompleteChainRegistryError = exports.DivisionByZeroError = exports._try = void 0;
4
+ var morpho_ts_1 = require("@morpho-org/morpho-ts");
5
+ Object.defineProperty(exports, "_try", { enumerable: true, get: function () { return morpho_ts_1._try; } });
6
+ Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return morpho_ts_1.DivisionByZeroError; } });
7
+ Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: true, get: function () { return morpho_ts_1.IncompleteChainRegistryError; } });
8
+ Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return morpho_ts_1.InvalidBitLengthError; } });
9
+ Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return morpho_ts_1.RegistryValueAlreadyRegisteredError; } });
10
+ Object.defineProperty(exports, "UnknownAddressError", { enumerable: true, get: function () { return morpho_ts_1.UnknownAddressError; } });
11
+ Object.defineProperty(exports, "UnsupportedChainIdError", { enumerable: true, get: function () { return morpho_ts_1.UnsupportedChainIdError; } });
5
12
  const viem_1 = require("viem");
6
13
  /** Error thrown when bytes cannot be decoded into valid Morpho Blue market params. */
7
14
  class InvalidMarketParamsError extends Error {
@@ -61,15 +68,6 @@ class UnknownMarketAllocationError extends UnknownDataError {
61
68
  }
62
69
  }
63
70
  exports.UnknownMarketAllocationError = UnknownMarketAllocationError;
64
- /** Error thrown when a chain id has no configured SDK registry entry. */
65
- class UnsupportedChainIdError extends Error {
66
- chainId;
67
- constructor(chainId) {
68
- super(`unsupported chain ${chainId}`);
69
- this.chainId = chainId;
70
- }
71
- }
72
- exports.UnsupportedChainIdError = UnsupportedChainIdError;
73
71
  /** Error thrown when no default pre-liquidation params exist for an LLTV. */
74
72
  class UnsupportedPreLiquidationParamsError extends Error {
75
73
  lltv;
@@ -222,25 +220,3 @@ class UnknownOfFactory extends Error {
222
220
  }
223
221
  }
224
222
  exports.UnknownOfFactory = UnknownOfFactory;
225
- /**
226
- * Runs an accessor and returns `undefined` for expected lookup errors.
227
- *
228
- * @internal
229
- */
230
- function _try(accessor, ...errorClasses) {
231
- const maybeCatchError = (error) => {
232
- if (errorClasses.length === 0 ||
233
- errorClasses.some((errorClass) => error instanceof errorClass))
234
- return;
235
- throw error;
236
- };
237
- try {
238
- const res = accessor();
239
- if (res instanceof Promise)
240
- return res.catch(maybeCatchError);
241
- return res;
242
- }
243
- catch (error) {
244
- return maybeCatchError(error);
245
- }
246
- }