@morpho-org/blue-sdk 2.0.0-test.1 → 2.1.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/LICENSE +21 -0
- package/README.md +46 -26
- package/lib/addresses.d.ts +59 -55
- package/lib/addresses.js +42 -43
- package/lib/chain.d.ts +1 -1
- package/lib/chain.js +3 -3
- package/lib/constants.d.ts +0 -9
- package/lib/constants.js +1 -10
- package/lib/errors.d.ts +7 -8
- package/lib/errors.js +21 -19
- package/lib/holding/AssetBalances.d.ts +3 -3
- package/lib/holding/Holding.d.ts +10 -5
- package/lib/holding/Holding.js +14 -4
- package/lib/holding/index.d.ts +2 -2
- package/lib/holding/index.js +2 -2
- package/lib/index.d.ts +12 -25
- package/lib/index.js +12 -38
- package/lib/market/Market.d.ts +48 -34
- package/lib/market/Market.js +76 -57
- package/lib/market/{MarketConfig.d.ts → MarketParams.d.ts} +8 -7
- package/lib/market/{MarketConfig.js → MarketParams.js} +20 -21
- package/lib/market/MarketUtils.d.ts +94 -42
- package/lib/market/MarketUtils.js +145 -67
- package/lib/market/index.d.ts +3 -3
- package/lib/market/index.js +3 -3
- package/lib/{maths → math}/AdaptiveCurveIrmLib.d.ts +1 -1
- package/lib/{maths → math}/AdaptiveCurveIrmLib.js +20 -20
- package/lib/{maths → math}/MathLib.d.ts +24 -42
- package/lib/{maths → math}/MathLib.js +41 -54
- package/lib/{maths → math}/SharesMath.d.ts +2 -2
- package/lib/{maths → math}/SharesMath.js +3 -3
- package/lib/math/index.d.ts +3 -0
- package/lib/{helpers/format → math}/index.js +3 -1
- package/lib/position/Position.d.ts +35 -25
- package/lib/position/Position.js +46 -44
- package/lib/position/index.d.ts +1 -1
- package/lib/position/index.js +1 -1
- package/lib/token/ConstantWrappedToken.d.ts +6 -7
- package/lib/token/ConstantWrappedToken.js +8 -10
- package/lib/token/ExchangeRateWrappedToken.d.ts +5 -5
- package/lib/token/ExchangeRateWrappedToken.js +5 -5
- package/lib/token/Token.d.ts +18 -18
- package/lib/token/Token.js +24 -27
- package/lib/token/VaultToken.d.ts +20 -11
- package/lib/token/VaultToken.js +15 -7
- package/lib/token/WrappedToken.d.ts +4 -4
- package/lib/token/WrappedToken.js +7 -7
- package/lib/token/index.d.ts +5 -5
- package/lib/token/index.js +5 -5
- package/lib/types.d.ts +3 -6
- package/lib/user/User.d.ts +1 -1
- package/lib/user/index.d.ts +1 -1
- package/lib/user/index.js +1 -1
- package/lib/vault/Vault.d.ts +22 -28
- package/lib/vault/Vault.js +43 -51
- package/lib/vault/VaultConfig.d.ts +6 -7
- package/lib/vault/VaultConfig.js +5 -5
- package/lib/vault/VaultMarketAllocation.d.ts +8 -8
- package/lib/vault/VaultMarketAllocation.js +3 -3
- package/lib/vault/VaultMarketConfig.d.ts +10 -10
- package/lib/vault/VaultMarketPublicAllocatorConfig.d.ts +6 -6
- package/lib/vault/VaultUser.d.ts +26 -0
- package/lib/vault/VaultUser.js +28 -0
- package/lib/vault/VaultUtils.d.ts +4 -6
- package/lib/vault/VaultUtils.js +6 -6
- package/lib/vault/index.d.ts +7 -6
- package/lib/vault/index.js +7 -6
- package/package.json +25 -56
- package/lib/chain.test.d.ts +0 -1
- package/lib/chain.test.js +0 -21
- package/lib/helpers/format/format.d.ts +0 -122
- package/lib/helpers/format/format.js +0 -286
- package/lib/helpers/format/format.test.d.ts +0 -1
- package/lib/helpers/format/format.test.js +0 -255
- package/lib/helpers/format/index.d.ts +0 -1
- package/lib/helpers/index.d.ts +0 -2
- package/lib/helpers/index.js +0 -18
- package/lib/helpers/locale.d.ts +0 -46
- package/lib/helpers/locale.js +0 -96
- package/lib/market/MarketUtils.test.d.ts +0 -1
- package/lib/market/MarketUtils.test.js +0 -38
- package/lib/maths/index.d.ts +0 -3
- package/lib/maths/index.js +0 -19
- package/lib/tests/mocks/markets.d.ts +0 -19
- package/lib/tests/mocks/markets.js +0 -121
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Morpho Association
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
# @morpho-org/blue-sdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
<a href="https://www.npmjs.com/package/@morpho-org/blue-sdk">
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/@morpho-org/blue-sdk?colorA=21262d&colorB=21262d&style=flat">
|
|
6
|
+
<img src="https://img.shields.io/npm/v/@morpho-org/blue-sdk?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Version">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://github.com/morpho-org/blue-sdk/blob/main/LICENSE">
|
|
10
|
+
<picture>
|
|
11
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/l/@morpho-org/blue-sdk?colorA=21262d&colorB=21262d&style=flat">
|
|
12
|
+
<img src="https://img.shields.io/npm/l/@morpho-org/blue-sdk?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="MIT License">
|
|
13
|
+
</picture>
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@morpho-org/blue-sdk">
|
|
16
|
+
<picture>
|
|
17
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/dm/@morpho-org/blue-sdk?colorA=21262d&colorB=21262d&style=flat">
|
|
18
|
+
<img src="https://img.shields.io/npm/dm/@morpho-org/blue-sdk?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Downloads per month">
|
|
19
|
+
</picture>
|
|
20
|
+
</a>
|
|
21
|
+
<br />
|
|
22
|
+
<br />
|
|
23
|
+
|
|
24
|
+
Framework-agnostic package that defines Morpho-related entity classes:
|
|
25
|
+
|
|
26
|
+
- [**`MarketParams`**](./src/market/MarketParams.ts): represents the immutable configuration of a market on Morpho
|
|
27
|
+
- [**`Market`**](./src/market/Market.ts): represents the state of a market on Morpho
|
|
28
|
+
- [**`Token`**](./src/token/Token.ts): represents a ERC20 token
|
|
29
|
+
- [**`User`**](./src/user/User.ts): represents a user of Morpho
|
|
30
|
+
- [**`VaultConfig`**](./src/vault/VaultConfig.ts): represents the configuration of a Morpho Vault
|
|
31
|
+
- [**`Vault`**](./src/vault/Vault.ts): represents the state of a Morpho Vault
|
|
32
|
+
- [**`VaultUser`**](./src/vault/VaultUser.ts): represents the state of a user on a Morpho Vault
|
|
33
|
+
- [**`VaultMarketAllocation`**](./src/vault/VaultMarketAllocation.ts): represents the allocation (and configuration) of a Morpho Vault on a Morpho market
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
9
36
|
|
|
10
37
|
```bash
|
|
11
38
|
npm install @morpho-org/blue-sdk
|
|
@@ -15,23 +42,21 @@ npm install @morpho-org/blue-sdk
|
|
|
15
42
|
yarn add @morpho-org/blue-sdk
|
|
16
43
|
```
|
|
17
44
|
|
|
18
|
-
---
|
|
19
|
-
|
|
20
45
|
## Getting Started
|
|
21
46
|
|
|
22
47
|
### Instance of the immutable configuration of a specific market
|
|
23
48
|
|
|
24
|
-
Leverage the [`
|
|
49
|
+
Leverage the [`MarketParams`](./src/market/MarketParams.ts) class to manipulate a given market's immutable configuration:
|
|
25
50
|
|
|
26
51
|
```typescript
|
|
27
|
-
import {
|
|
52
|
+
import { MarketParams } from "@morpho-org/blue-sdk";
|
|
28
53
|
|
|
29
|
-
const config = new
|
|
30
|
-
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
54
|
+
const config = new MarketParams({
|
|
55
|
+
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
31
56
|
collateralToken: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", // wstETH
|
|
32
57
|
oracle: "0x2a01EB9496094dA03c4E364Def50f5aD1280AD72",
|
|
33
|
-
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
|
|
34
|
-
lltv: 94_5000000000000000n,
|
|
58
|
+
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC", // AdaptiveCurveIrm
|
|
59
|
+
lltv: 94_5000000000000000n, // 94.5%
|
|
35
60
|
});
|
|
36
61
|
|
|
37
62
|
config.liquidationIncentiveFactor; // e.g. 1_090000000000000000n (109%).
|
|
@@ -42,16 +67,16 @@ config.liquidationIncentiveFactor; // e.g. 1_090000000000000000n (109%).
|
|
|
42
67
|
Leverage the [`Market`](./src/market/Market.ts) class to manipulate a specific market:
|
|
43
68
|
|
|
44
69
|
```typescript
|
|
45
|
-
import { Market } from "@morpho-org/blue-sdk";
|
|
70
|
+
import { Market, MarketParams } from "@morpho-org/blue-sdk";
|
|
46
71
|
import { Time } from "@morpho-org/morpho-ts";
|
|
47
72
|
|
|
48
73
|
const market = new Market({
|
|
49
|
-
config: new
|
|
50
|
-
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
74
|
+
config: new MarketParams({
|
|
75
|
+
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
51
76
|
collateralToken: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", // wstETH
|
|
52
77
|
oracle: "0x2a01EB9496094dA03c4E364Def50f5aD1280AD72",
|
|
53
|
-
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
|
|
54
|
-
lltv: 94_5000000000000000n,
|
|
78
|
+
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC", // AdaptiveCurveIrm
|
|
79
|
+
lltv: 94_5000000000000000n, // 94.5%
|
|
55
80
|
}),
|
|
56
81
|
totalSupplyAssets: 1000_000000000000000000n,
|
|
57
82
|
totalBorrowAssets: 920_000000000000000000n,
|
|
@@ -60,7 +85,7 @@ const market = new Market({
|
|
|
60
85
|
lastUpdate: 1721000000n,
|
|
61
86
|
fee: 0n,
|
|
62
87
|
price: 1_100000000000000000000000000000000000n,
|
|
63
|
-
rateAtTarget: 94850992095n
|
|
88
|
+
rateAtTarget: 94850992095n,
|
|
64
89
|
});
|
|
65
90
|
|
|
66
91
|
market.utilization; // e.g. 92_0000000000000000n (92%).
|
|
@@ -86,7 +111,7 @@ const position = new AccrualPosition(
|
|
|
86
111
|
marketId: market.id,
|
|
87
112
|
supplyShares: 0n,
|
|
88
113
|
borrowShares: 20_000000000000000000000000n,
|
|
89
|
-
collateral: 27_000000000000000000n
|
|
114
|
+
collateral: 27_000000000000000000n,
|
|
90
115
|
}),
|
|
91
116
|
market
|
|
92
117
|
);
|
|
@@ -99,8 +124,3 @@ const accruedPosition = position.accrueInterest(Time.timestamp()); // Accrue int
|
|
|
99
124
|
|
|
100
125
|
position.borrowAssets; // e.g. 20_400000000000000000n (in loan assets).
|
|
101
126
|
```
|
|
102
|
-
|
|
103
|
-
[downloads-img]: https://img.shields.io/npm/dt/@morpho-org/blue-sdk
|
|
104
|
-
[downloads-url]: https://www.npmtrends.com/@morpho-org/blue-sdk
|
|
105
|
-
[npm-img]: https://img.shields.io/npm/v/@morpho-org/blue-sdk
|
|
106
|
-
[npm-url]: https://www.npmjs.com/package/@morpho-org/blue-sdk
|
package/lib/addresses.d.ts
CHANGED
|
@@ -1,62 +1,65 @@
|
|
|
1
|
-
import { ChainId } from "./chain";
|
|
2
|
-
import { Address } from "./types";
|
|
1
|
+
import { ChainId } from "./chain.js";
|
|
2
|
+
import type { Address } from "./types.js";
|
|
3
3
|
/** Address used to replicate an erc20-behaviour for native token.
|
|
4
4
|
*
|
|
5
5
|
* NB: data might differ from expected onchain native token data
|
|
6
6
|
*/
|
|
7
7
|
export declare const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
8
8
|
export declare const addresses: {
|
|
9
|
-
1: {
|
|
10
|
-
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
11
|
-
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
12
|
-
bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077";
|
|
13
|
-
aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c";
|
|
14
|
-
aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76";
|
|
15
|
-
aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC";
|
|
16
|
-
compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558";
|
|
17
|
-
compoundV2Bundler: "
|
|
18
|
-
adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
|
|
19
|
-
publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
9
|
+
readonly 1: {
|
|
10
|
+
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
11
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
12
|
+
readonly bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077";
|
|
13
|
+
readonly aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c";
|
|
14
|
+
readonly aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76";
|
|
15
|
+
readonly aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC";
|
|
16
|
+
readonly compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558";
|
|
17
|
+
readonly compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647";
|
|
18
|
+
readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
|
|
19
|
+
readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
|
|
20
|
+
readonly metaMorphoFactory: "0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101";
|
|
21
|
+
readonly wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
22
|
+
readonly morphoToken: "0x9994E35Db50125E0DF82e4c2dde62496CE330999";
|
|
23
|
+
readonly dai: "0x6B175474E89094C44Da98b954EedeAC495271d0F";
|
|
24
|
+
readonly sDai: "0x83F20F44975D03b1b09e64809B757c47f942BEeA";
|
|
25
|
+
readonly mkr: "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2";
|
|
26
|
+
readonly stEth: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
|
|
27
|
+
readonly wstEth: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0";
|
|
28
|
+
readonly osEth: "0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38";
|
|
29
|
+
readonly bIB01: "0xCA30c93B02514f86d5C86a6e375E3A330B435Fb5";
|
|
30
|
+
readonly wbIB01: "0xcA2A7068e551d5C4482eb34880b194E4b945712F";
|
|
31
|
+
readonly bC3M: "0x2F123cF3F37CE3328CC9B5b8415f9EC5109b45e7";
|
|
32
|
+
readonly wbC3M: "0x95D7337d43340E2721960Dc402D9b9117f0d81a2";
|
|
33
|
+
readonly usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
34
|
+
readonly usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7";
|
|
35
|
+
readonly crvUsd: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E";
|
|
36
|
+
readonly "stkcvxcrvUSDTWBTCWETH-morpho": "0xb0Ce26C88e4e7DCa51968b6047f44646f5064278";
|
|
37
|
+
readonly crvUSDTWBTCWETH: "0xf5f5B97624542D72A9E06f04804Bf81baA15e2B4";
|
|
38
|
+
readonly "stkcvxcrvUSDCWBTCWETH-morpho": "0x0ea1a65A2c255f24Ee8D81eA6AaC54Decd9d269e";
|
|
39
|
+
readonly crvUSDCWBTCWETH: "0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B";
|
|
40
|
+
readonly "stkcvxcrvCRVUSDTBTCWSTETH-morpho": "0x3ce8Ec9f3d89aD0A2DdbCC3FDB8991BD241Fc82E";
|
|
41
|
+
readonly crvCRVUSDTBTCWSTETH: "0x2889302a794dA87fBF1D6Db415C1492194663D13";
|
|
42
|
+
readonly "stkcvxTryLSD-morpho": "0x6BA072F0d22806F2C52e9792AF47f2D59103BEBE";
|
|
43
|
+
readonly tryLSD: "0x2570f1bD5D2735314FC102eb12Fc1aFe9e6E7193";
|
|
44
|
+
readonly "stkcvxcrvUSDETHCRV-morpho": "0xAc904BAfBb5FB04Deb2b6198FdCEedE75a78Ce5a";
|
|
45
|
+
readonly crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14";
|
|
46
|
+
readonly "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e";
|
|
47
|
+
readonly "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726";
|
|
46
48
|
};
|
|
47
|
-
8453: {
|
|
48
|
-
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
49
|
-
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
50
|
-
bundler: "0x23055618898e202386e6c13955a58D3C68200BFB";
|
|
51
|
-
compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223";
|
|
52
|
-
aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108";
|
|
53
|
-
compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA";
|
|
54
|
-
adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
|
|
55
|
-
publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
readonly 8453: {
|
|
50
|
+
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
51
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
52
|
+
readonly bundler: "0x23055618898e202386e6c13955a58D3C68200BFB";
|
|
53
|
+
readonly compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223";
|
|
54
|
+
readonly aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108";
|
|
55
|
+
readonly compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA";
|
|
56
|
+
readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
|
|
57
|
+
readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
|
|
58
|
+
readonly metaMorphoFactory: "0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101";
|
|
59
|
+
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
60
|
+
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
61
|
+
readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
|
|
62
|
+
readonly testUsdc: "0xBC77067f829979812d795d516E523C4033b66409";
|
|
60
63
|
};
|
|
61
64
|
};
|
|
62
65
|
export interface ChainAddresses {
|
|
@@ -68,8 +71,9 @@ export interface ChainAddresses {
|
|
|
68
71
|
aaveV3Bundler?: Address;
|
|
69
72
|
compoundV3Bundler?: Address;
|
|
70
73
|
compoundV2Bundler?: Address;
|
|
71
|
-
adaptiveCurveIrm
|
|
72
|
-
publicAllocator
|
|
74
|
+
adaptiveCurveIrm: Address;
|
|
75
|
+
publicAllocator: Address;
|
|
76
|
+
metaMorphoFactory: Address;
|
|
73
77
|
wNative: Address;
|
|
74
78
|
morphoToken?: Address;
|
|
75
79
|
dai?: Address;
|
|
@@ -87,7 +91,7 @@ export declare const getChainAddresses: (chainId: number) => ChainAddresses;
|
|
|
87
91
|
* - unwrapped token has same number of decimals than wrapped tokens.
|
|
88
92
|
*/
|
|
89
93
|
export declare const unwrappedTokensMapping: Record<ChainId, Record<Address, Address>>;
|
|
90
|
-
export declare function getUnwrappedToken(wrappedToken: Address, chainId: ChainId): string | undefined;
|
|
94
|
+
export declare function getUnwrappedToken(wrappedToken: Address, chainId: ChainId): `0x${string}` | undefined;
|
|
91
95
|
/**
|
|
92
96
|
* The registry of all known ERC20Wrapper tokens.
|
|
93
97
|
*/
|
package/lib/addresses.js
CHANGED
|
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.convexWrapperTokens = exports.permissionedCoinbaseTokens = exports.permissionedBackedTokens = exports.permissionedWrapperTokens = exports.erc20WrapperTokens = exports.unwrappedTokensMapping = exports.getChainAddresses = exports.addresses = exports.NATIVE_ADDRESS = void 0;
|
|
4
4
|
exports.getUnwrappedToken = getUnwrappedToken;
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const
|
|
7
|
-
const errors_1 = require("./errors");
|
|
6
|
+
const chain_js_1 = require("./chain.js");
|
|
8
7
|
/** Address used to replicate an erc20-behaviour for native token.
|
|
9
8
|
*
|
|
10
9
|
* NB: data might differ from expected onchain native token data
|
|
11
10
|
*/
|
|
12
11
|
exports.NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
13
12
|
exports.addresses = {
|
|
14
|
-
[
|
|
13
|
+
[chain_js_1.ChainId.EthMainnet]: {
|
|
15
14
|
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
16
15
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
17
16
|
bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077",
|
|
@@ -19,9 +18,10 @@ exports.addresses = {
|
|
|
19
18
|
aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76",
|
|
20
19
|
aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC",
|
|
21
20
|
compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558",
|
|
22
|
-
compoundV2Bundler: "
|
|
21
|
+
compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647",
|
|
23
22
|
adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
|
|
24
23
|
publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D",
|
|
24
|
+
metaMorphoFactory: "0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101",
|
|
25
25
|
wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
26
26
|
morphoToken: "0x9994E35Db50125E0DF82e4c2dde62496CE330999",
|
|
27
27
|
dai: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
|
|
@@ -39,6 +39,7 @@ exports.addresses = {
|
|
|
39
39
|
// Currently, wbC3M is considered to have simple permit.
|
|
40
40
|
wbC3M: "0x95D7337d43340E2721960Dc402D9b9117f0d81a2",
|
|
41
41
|
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
42
|
+
usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
42
43
|
crvUsd: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
43
44
|
"stkcvxcrvUSDTWBTCWETH-morpho": "0xb0Ce26C88e4e7DCa51968b6047f44646f5064278",
|
|
44
45
|
crvUSDTWBTCWETH: "0xf5f5B97624542D72A9E06f04804Bf81baA15e2B4",
|
|
@@ -53,7 +54,7 @@ exports.addresses = {
|
|
|
53
54
|
"stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e",
|
|
54
55
|
"2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726",
|
|
55
56
|
},
|
|
56
|
-
[
|
|
57
|
+
[chain_js_1.ChainId.BaseMainnet]: {
|
|
57
58
|
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
58
59
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
59
60
|
bundler: "0x23055618898e202386e6c13955a58D3C68200BFB",
|
|
@@ -62,6 +63,7 @@ exports.addresses = {
|
|
|
62
63
|
compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA",
|
|
63
64
|
adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687",
|
|
64
65
|
publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
|
|
66
|
+
metaMorphoFactory: "0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101",
|
|
65
67
|
wNative: "0x4200000000000000000000000000000000000006",
|
|
66
68
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
67
69
|
verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b",
|
|
@@ -70,10 +72,7 @@ exports.addresses = {
|
|
|
70
72
|
};
|
|
71
73
|
exports.default = exports.addresses;
|
|
72
74
|
const getChainAddresses = (chainId) => {
|
|
73
|
-
|
|
74
|
-
if (!chainAddresses)
|
|
75
|
-
throw new errors_1.UnsupportedChainIdError(chainId);
|
|
76
|
-
return chainAddresses;
|
|
75
|
+
return exports.addresses[chain_js_1.ChainUtils.parseSupportedChainId(chainId)];
|
|
77
76
|
};
|
|
78
77
|
exports.getChainAddresses = getChainAddresses;
|
|
79
78
|
/**
|
|
@@ -81,23 +80,23 @@ exports.getChainAddresses = getChainAddresses;
|
|
|
81
80
|
* - unwrapped token has same number of decimals than wrapped tokens.
|
|
82
81
|
*/
|
|
83
82
|
exports.unwrappedTokensMapping = {
|
|
84
|
-
[
|
|
85
|
-
[exports.addresses[
|
|
86
|
-
[exports.addresses[
|
|
87
|
-
[exports.addresses[
|
|
88
|
-
[exports.addresses[
|
|
89
|
-
[exports.addresses[
|
|
90
|
-
[exports.addresses[
|
|
91
|
-
[exports.addresses[
|
|
92
|
-
[exports.addresses[
|
|
93
|
-
[exports.addresses[
|
|
94
|
-
[exports.addresses[
|
|
95
|
-
[exports.addresses[
|
|
83
|
+
[chain_js_1.ChainId.EthMainnet]: {
|
|
84
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet].wbIB01]: exports.addresses[chain_js_1.ChainId.EthMainnet].bIB01,
|
|
85
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet].wbC3M]: exports.addresses[chain_js_1.ChainId.EthMainnet].bC3M,
|
|
86
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
87
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet].stEth]: exports.NATIVE_ADDRESS,
|
|
88
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet].wstEth]: exports.addresses[chain_js_1.ChainId.EthMainnet].stEth,
|
|
89
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"]]: exports.addresses[chain_js_1.ChainId.EthMainnet].crvUSDTWBTCWETH,
|
|
90
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"]]: exports.addresses[chain_js_1.ChainId.EthMainnet].crvUSDCWBTCWETH,
|
|
91
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"]]: exports.addresses[chain_js_1.ChainId.EthMainnet].crvCRVUSDTBTCWSTETH,
|
|
92
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxTryLSD-morpho"]]: exports.addresses[chain_js_1.ChainId.EthMainnet].tryLSD,
|
|
93
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"]]: exports.addresses[chain_js_1.ChainId.EthMainnet].crvUSDETHCRV,
|
|
94
|
+
[exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvx2BTC-f-morpho"]]: exports.addresses[chain_js_1.ChainId.EthMainnet]["2BTC-f"],
|
|
96
95
|
},
|
|
97
|
-
[
|
|
98
|
-
[exports.addresses[
|
|
99
|
-
[exports.addresses[
|
|
100
|
-
[exports.addresses[
|
|
96
|
+
[chain_js_1.ChainId.BaseMainnet]: {
|
|
97
|
+
[exports.addresses[chain_js_1.ChainId.BaseMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
98
|
+
[exports.addresses[chain_js_1.ChainId.BaseMainnet].verUsdc]: exports.addresses[chain_js_1.ChainId.BaseMainnet].usdc,
|
|
99
|
+
[exports.addresses[chain_js_1.ChainId.BaseMainnet].testUsdc]: exports.addresses[chain_js_1.ChainId.BaseMainnet].usdc,
|
|
101
100
|
},
|
|
102
101
|
};
|
|
103
102
|
function getUnwrappedToken(wrappedToken, chainId) {
|
|
@@ -107,35 +106,35 @@ function getUnwrappedToken(wrappedToken, chainId) {
|
|
|
107
106
|
* The registry of all known ERC20Wrapper tokens.
|
|
108
107
|
*/
|
|
109
108
|
exports.erc20WrapperTokens = {
|
|
110
|
-
[
|
|
111
|
-
[
|
|
109
|
+
[chain_js_1.ChainId.EthMainnet]: new Set(),
|
|
110
|
+
[chain_js_1.ChainId.BaseMainnet]: new Set(),
|
|
112
111
|
};
|
|
113
112
|
/**
|
|
114
113
|
* The registry of all known PermissionedERC20Wrapper with a `hasPermission` getter.
|
|
115
114
|
* All permissioned wrapper tokens are considered ERC20Wrapper and automatically added to the erc20WrapperTokens registry.
|
|
116
115
|
*/
|
|
117
116
|
exports.permissionedWrapperTokens = {
|
|
118
|
-
[
|
|
119
|
-
[
|
|
117
|
+
[chain_js_1.ChainId.EthMainnet]: new Set(),
|
|
118
|
+
[chain_js_1.ChainId.BaseMainnet]: new Set([exports.addresses[chain_js_1.ChainId.BaseMainnet].testUsdc]),
|
|
120
119
|
};
|
|
121
120
|
/**
|
|
122
121
|
* The registry of all known permissioned wrapped Backed tokens.
|
|
123
122
|
* All permissioned Backed tokens are considered ERC20Wrapper and automatically added to the erc20WrapperTokens registry.
|
|
124
123
|
*/
|
|
125
124
|
exports.permissionedBackedTokens = {
|
|
126
|
-
[
|
|
127
|
-
exports.addresses[
|
|
128
|
-
exports.addresses[
|
|
125
|
+
[chain_js_1.ChainId.EthMainnet]: new Set([
|
|
126
|
+
exports.addresses[chain_js_1.ChainId.EthMainnet].wbIB01,
|
|
127
|
+
exports.addresses[chain_js_1.ChainId.EthMainnet].wbC3M,
|
|
129
128
|
]),
|
|
130
|
-
[
|
|
129
|
+
[chain_js_1.ChainId.BaseMainnet]: new Set(),
|
|
131
130
|
};
|
|
132
131
|
/**
|
|
133
132
|
* The registry of all known permissioned wrapped tokens that require a Coinbase attestation.
|
|
134
133
|
* All permissioned Coinbase tokens are considered PermissionedERC20Wrapper and automatically added to the permissionedWrapperTokens registry.
|
|
135
134
|
*/
|
|
136
135
|
exports.permissionedCoinbaseTokens = {
|
|
137
|
-
[
|
|
138
|
-
[
|
|
136
|
+
[chain_js_1.ChainId.EthMainnet]: new Set(),
|
|
137
|
+
[chain_js_1.ChainId.BaseMainnet]: new Set([exports.addresses[chain_js_1.ChainId.BaseMainnet].verUsdc]),
|
|
139
138
|
};
|
|
140
139
|
(0, morpho_ts_1.entries)(exports.permissionedBackedTokens).forEach(([chainId, tokens]) => {
|
|
141
140
|
tokens.forEach((token) => exports.erc20WrapperTokens[chainId].add(token));
|
|
@@ -150,13 +149,13 @@ exports.permissionedCoinbaseTokens = {
|
|
|
150
149
|
* - calling `depositFor` supplies on blue instead of minting wrapped token to the user
|
|
151
150
|
*/
|
|
152
151
|
exports.convexWrapperTokens = {
|
|
153
|
-
[
|
|
154
|
-
exports.addresses[
|
|
155
|
-
exports.addresses[
|
|
156
|
-
exports.addresses[
|
|
157
|
-
exports.addresses[
|
|
158
|
-
exports.addresses[
|
|
159
|
-
exports.addresses[
|
|
152
|
+
[chain_js_1.ChainId.EthMainnet]: new Set([
|
|
153
|
+
exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"],
|
|
154
|
+
exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"],
|
|
155
|
+
exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"],
|
|
156
|
+
exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxTryLSD-morpho"],
|
|
157
|
+
exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"],
|
|
158
|
+
exports.addresses[chain_js_1.ChainId.EthMainnet]["stkcvx2BTC-f-morpho"],
|
|
160
159
|
]),
|
|
161
|
-
[
|
|
160
|
+
[chain_js_1.ChainId.BaseMainnet]: new Set(),
|
|
162
161
|
};
|
package/lib/chain.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare namespace ChainUtils {
|
|
|
23
23
|
const getExplorerAddressUrl: (chainId: ChainId, address: string) => string;
|
|
24
24
|
const getExplorerTransactionUrl: (chainId: ChainId, tx: string) => string;
|
|
25
25
|
function isSupported(chainId: number): chainId is ChainId;
|
|
26
|
-
function parseSupportedChainId(candidate:
|
|
26
|
+
function parseSupportedChainId(candidate: unknown): ChainId;
|
|
27
27
|
const BLUE_AVAILABLE_CHAINS: [ChainId, ...ChainId[]];
|
|
28
28
|
const CHAIN_METADATA: Record<ChainId, ChainMetadata>;
|
|
29
29
|
}
|
package/lib/chain.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ChainUtils = exports.ChainId = void 0;
|
|
4
|
-
const
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
5
|
var ChainId;
|
|
6
6
|
(function (ChainId) {
|
|
7
7
|
ChainId[ChainId["EthMainnet"] = 1] = "EthMainnet";
|
|
@@ -48,9 +48,9 @@ var ChainUtils;
|
|
|
48
48
|
}
|
|
49
49
|
ChainUtils.isSupported = isSupported;
|
|
50
50
|
function parseSupportedChainId(candidate) {
|
|
51
|
-
const chainId = parseInt(candidate);
|
|
51
|
+
const chainId = Number.parseInt(candidate); // Force cast to string to silence TS because it works.
|
|
52
52
|
if (!isSupported(chainId))
|
|
53
|
-
throw new
|
|
53
|
+
throw new errors_js_1.UnsupportedChainIdError(chainId);
|
|
54
54
|
return chainId;
|
|
55
55
|
}
|
|
56
56
|
ChainUtils.parseSupportedChainId = parseSupportedChainId;
|
package/lib/constants.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export declare const LIQUIDATION_CURSOR = 300000000000000000n;
|
|
|
6
6
|
* The maximum liquidation incentive factor. Hardcoded to 115%.
|
|
7
7
|
*/
|
|
8
8
|
export declare const MAX_LIQUIDATION_INCENTIVE_FACTOR = 1150000000000000000n;
|
|
9
|
-
export declare const ORACLE_PRICE_OFFSET = 36;
|
|
10
9
|
/**
|
|
11
10
|
* The scale of the oracle price. Hardcoded to 1e36.
|
|
12
11
|
*/
|
|
@@ -15,14 +14,6 @@ export declare const ORACLE_PRICE_SCALE = 1000000000000000000000000000000000000n
|
|
|
15
14
|
* The default slippage tolerance used in the SDK. Hardcoded to 0.03%.
|
|
16
15
|
*/
|
|
17
16
|
export declare const DEFAULT_SLIPPAGE_TOLERANCE = 300000000000000n;
|
|
18
|
-
/**
|
|
19
|
-
* The default withdrawal target utilization used by the shared liquidity algorithm. Hardcoded to 92%.
|
|
20
|
-
*/
|
|
21
|
-
export declare const DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = 920000000000000000n;
|
|
22
|
-
/**
|
|
23
|
-
* The default supply target utilization used by the shared liquidity algorithm. Hardcoded to 90.5%.
|
|
24
|
-
*/
|
|
25
|
-
export declare const DEFAULT_SUPPLY_TARGET_UTILIZATION = 905000000000000000n;
|
|
26
17
|
/**
|
|
27
18
|
* The number of seconds in a year.
|
|
28
19
|
*/
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SECONDS_PER_YEAR = exports.
|
|
3
|
+
exports.SECONDS_PER_YEAR = exports.DEFAULT_SLIPPAGE_TOLERANCE = exports.ORACLE_PRICE_SCALE = exports.MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.LIQUIDATION_CURSOR = void 0;
|
|
4
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
5
|
/**
|
|
6
6
|
* The liquidation cursor used to calculate the liquidation incentive. Hardcoded to 30%.
|
|
@@ -10,7 +10,6 @@ exports.LIQUIDATION_CURSOR = 300000000000000000n;
|
|
|
10
10
|
* The maximum liquidation incentive factor. Hardcoded to 115%.
|
|
11
11
|
*/
|
|
12
12
|
exports.MAX_LIQUIDATION_INCENTIVE_FACTOR = 1150000000000000000n;
|
|
13
|
-
exports.ORACLE_PRICE_OFFSET = 36;
|
|
14
13
|
/**
|
|
15
14
|
* The scale of the oracle price. Hardcoded to 1e36.
|
|
16
15
|
*/
|
|
@@ -19,14 +18,6 @@ exports.ORACLE_PRICE_SCALE = 1000000000000000000000000000000000000n;
|
|
|
19
18
|
* The default slippage tolerance used in the SDK. Hardcoded to 0.03%.
|
|
20
19
|
*/
|
|
21
20
|
exports.DEFAULT_SLIPPAGE_TOLERANCE = 300000000000000n;
|
|
22
|
-
/**
|
|
23
|
-
* The default withdrawal target utilization used by the shared liquidity algorithm. Hardcoded to 92%.
|
|
24
|
-
*/
|
|
25
|
-
exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = 920000000000000000n;
|
|
26
|
-
/**
|
|
27
|
-
* The default supply target utilization used by the shared liquidity algorithm. Hardcoded to 90.5%.
|
|
28
|
-
*/
|
|
29
|
-
exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = 905000000000000000n;
|
|
30
21
|
/**
|
|
31
22
|
* The number of seconds in a year.
|
|
32
23
|
*/
|
package/lib/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, MarketId } from "./types";
|
|
1
|
+
import type { Address, MarketId } from "./types.js";
|
|
2
2
|
export declare class UnknownDataError extends Error {
|
|
3
3
|
}
|
|
4
4
|
export declare class UnknownTokenError extends UnknownDataError {
|
|
@@ -9,7 +9,7 @@ export declare class UnknownTokenPriceError extends UnknownDataError {
|
|
|
9
9
|
readonly address: Address;
|
|
10
10
|
constructor(address: Address);
|
|
11
11
|
}
|
|
12
|
-
export declare class
|
|
12
|
+
export declare class UnknownMarketParamsError extends UnknownDataError {
|
|
13
13
|
readonly marketId: MarketId;
|
|
14
14
|
constructor(marketId: MarketId);
|
|
15
15
|
}
|
|
@@ -35,6 +35,10 @@ export declare namespace BlueErrors {
|
|
|
35
35
|
readonly marketId: MarketId;
|
|
36
36
|
constructor(marketId: MarketId);
|
|
37
37
|
}
|
|
38
|
+
class UnknownOraclePrice extends Error {
|
|
39
|
+
readonly marketId: MarketId;
|
|
40
|
+
constructor(marketId: MarketId);
|
|
41
|
+
}
|
|
38
42
|
class InsufficientPosition extends Error {
|
|
39
43
|
readonly user: Address;
|
|
40
44
|
readonly marketId: MarketId;
|
|
@@ -46,13 +50,8 @@ export declare namespace BlueErrors {
|
|
|
46
50
|
constructor(user: Address, marketId: MarketId);
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
|
-
export declare class InvalidSignatureError extends Error {
|
|
50
|
-
readonly hash: string;
|
|
51
|
-
readonly signer: Address;
|
|
52
|
-
readonly recovered: Address;
|
|
53
|
-
constructor(hash: string, signer: Address, recovered: Address);
|
|
54
|
-
}
|
|
55
53
|
export interface ErrorClass<E extends Error> {
|
|
56
54
|
new (...args: any[]): E;
|
|
57
55
|
}
|
|
56
|
+
export declare function _try<T, E extends Error>(accessor: () => Promise<T>, ...errorClasses: ErrorClass<E>[]): Promise<T | undefined>;
|
|
58
57
|
export declare function _try<T, E extends Error>(accessor: () => T, ...errorClasses: ErrorClass<E>[]): T | undefined;
|