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