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