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