@morpho-org/blue-sdk 2.0.0-next.1 → 2.0.0-next.11
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 +16 -15
- package/lib/addresses.d.ts +117 -0
- package/lib/addresses.js +156 -0
- package/lib/chain.d.ts +29 -0
- package/lib/chain.js +286 -0
- package/lib/constants.d.ts +29 -0
- package/lib/constants.js +30 -0
- package/lib/errors.d.ts +52 -0
- package/lib/errors.js +97 -0
- package/lib/holding/AssetBalances.d.ts +48 -0
- package/lib/holding/AssetBalances.js +38 -0
- package/lib/holding/Holding.d.ts +64 -0
- package/lib/holding/Holding.js +65 -0
- package/lib/holding/index.d.ts +2 -0
- package/lib/holding/index.js +2 -0
- package/lib/index.js +12 -0
- package/lib/market/Market.d.ts +332 -0
- package/lib/market/Market.js +459 -0
- package/lib/market/MarketParams.d.ts +52 -0
- package/lib/market/MarketParams.js +71 -0
- package/lib/market/MarketUtils.d.ts +233 -0
- package/lib/market/MarketUtils.js +257 -0
- package/lib/market/index.d.ts +3 -0
- package/lib/market/index.js +3 -0
- package/lib/math/AdaptiveCurveIrmLib.d.ts +39 -0
- package/lib/math/AdaptiveCurveIrmLib.js +131 -0
- package/lib/math/MathLib.d.ts +111 -0
- package/lib/math/MathLib.js +185 -0
- package/lib/math/SharesMath.d.ts +12 -0
- package/lib/math/SharesMath.js +18 -0
- package/lib/math/index.d.ts +3 -0
- package/lib/math/index.js +3 -0
- package/lib/position/Position.d.ts +127 -0
- package/lib/position/Position.js +199 -0
- package/lib/position/index.d.ts +1 -0
- package/lib/position/index.js +1 -0
- package/lib/token/ConstantWrappedToken.d.ts +17 -0
- package/lib/token/ConstantWrappedToken.js +30 -0
- package/lib/token/ExchangeRateWrappedToken.d.ts +11 -0
- package/lib/token/ExchangeRateWrappedToken.js +17 -0
- package/lib/token/Token.d.ts +46 -0
- package/lib/token/Token.js +59 -0
- package/lib/token/VaultToken.d.ts +23 -0
- package/lib/token/VaultToken.js +27 -0
- package/lib/token/WrappedToken.d.ts +17 -0
- package/lib/token/WrappedToken.js +29 -0
- package/lib/token/index.d.ts +5 -0
- package/lib/token/index.js +5 -0
- package/lib/types.d.ts +27 -0
- package/lib/types.js +17 -0
- package/lib/user/User.d.ts +20 -0
- package/lib/user/User.js +19 -0
- package/lib/user/index.d.ts +1 -0
- package/lib/user/index.js +1 -0
- package/lib/vault/Vault.d.ts +152 -0
- package/lib/vault/Vault.js +221 -0
- package/lib/vault/VaultConfig.d.ts +22 -0
- package/lib/vault/VaultConfig.js +28 -0
- package/lib/vault/VaultMarketAllocation.d.ts +20 -0
- package/lib/vault/VaultMarketAllocation.js +26 -0
- package/lib/vault/VaultMarketConfig.d.ts +43 -0
- package/lib/vault/VaultMarketConfig.js +39 -0
- package/lib/vault/VaultMarketPublicAllocatorConfig.d.ts +29 -0
- package/lib/vault/VaultMarketPublicAllocatorConfig.js +24 -0
- package/lib/vault/VaultUser.d.ts +26 -0
- package/lib/vault/VaultUser.js +24 -0
- package/lib/vault/VaultUtils.d.ts +16 -0
- package/lib/vault/VaultUtils.js +17 -0
- package/lib/vault/index.d.ts +7 -0
- package/lib/vault/index.js +7 -0
- package/package.json +32 -36
- /package/{src/index.ts → lib/index.d.ts} +0 -0
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
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<img src="https://img.shields.io/npm/v/@morpho-org/blue-sdk?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Version">
|
|
7
7
|
</picture>
|
|
8
8
|
</a>
|
|
9
|
-
<a href="https://github.com/
|
|
9
|
+
<a href="https://github.com/morpho-org/blue-sdk/blob/main/LICENSE">
|
|
10
10
|
<picture>
|
|
11
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
12
|
<img src="https://img.shields.io/npm/l/@morpho-org/blue-sdk?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="MIT License">
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
<br />
|
|
23
23
|
|
|
24
24
|
Framework-agnostic package that defines Morpho-related entity classes:
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
- [**`MarketParams`**](./src/market/MarketParams.ts): represents the immutable configuration of a market on Morpho
|
|
26
27
|
- [**`Market`**](./src/market/Market.ts): represents the state of a market on Morpho
|
|
27
28
|
- [**`Token`**](./src/token/Token.ts): represents a ERC20 token
|
|
28
29
|
- [**`User`**](./src/user/User.ts): represents a user of Morpho
|
|
@@ -45,17 +46,17 @@ yarn add @morpho-org/blue-sdk
|
|
|
45
46
|
|
|
46
47
|
### Instance of the immutable configuration of a specific market
|
|
47
48
|
|
|
48
|
-
Leverage the [`
|
|
49
|
+
Leverage the [`MarketParams`](./src/market/MarketParams.ts) class to manipulate a given market's immutable configuration:
|
|
49
50
|
|
|
50
51
|
```typescript
|
|
51
|
-
import {
|
|
52
|
+
import { MarketParams } from "@morpho-org/blue-sdk";
|
|
52
53
|
|
|
53
|
-
const config = new
|
|
54
|
-
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
54
|
+
const config = new MarketParams({
|
|
55
|
+
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
55
56
|
collateralToken: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", // wstETH
|
|
56
57
|
oracle: "0x2a01EB9496094dA03c4E364Def50f5aD1280AD72",
|
|
57
|
-
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
|
|
58
|
-
lltv: 94_5000000000000000n,
|
|
58
|
+
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC", // AdaptiveCurveIrm
|
|
59
|
+
lltv: 94_5000000000000000n, // 94.5%
|
|
59
60
|
});
|
|
60
61
|
|
|
61
62
|
config.liquidationIncentiveFactor; // e.g. 1_090000000000000000n (109%).
|
|
@@ -66,16 +67,16 @@ config.liquidationIncentiveFactor; // e.g. 1_090000000000000000n (109%).
|
|
|
66
67
|
Leverage the [`Market`](./src/market/Market.ts) class to manipulate a specific market:
|
|
67
68
|
|
|
68
69
|
```typescript
|
|
69
|
-
import { Market } from "@morpho-org/blue-sdk";
|
|
70
|
+
import { Market, MarketParams } from "@morpho-org/blue-sdk";
|
|
70
71
|
import { Time } from "@morpho-org/morpho-ts";
|
|
71
72
|
|
|
72
73
|
const market = new Market({
|
|
73
|
-
config: new
|
|
74
|
-
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
74
|
+
config: new MarketParams({
|
|
75
|
+
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
75
76
|
collateralToken: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", // wstETH
|
|
76
77
|
oracle: "0x2a01EB9496094dA03c4E364Def50f5aD1280AD72",
|
|
77
|
-
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
|
|
78
|
-
lltv: 94_5000000000000000n,
|
|
78
|
+
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC", // AdaptiveCurveIrm
|
|
79
|
+
lltv: 94_5000000000000000n, // 94.5%
|
|
79
80
|
}),
|
|
80
81
|
totalSupplyAssets: 1000_000000000000000000n,
|
|
81
82
|
totalBorrowAssets: 920_000000000000000000n,
|
|
@@ -84,7 +85,7 @@ const market = new Market({
|
|
|
84
85
|
lastUpdate: 1721000000n,
|
|
85
86
|
fee: 0n,
|
|
86
87
|
price: 1_100000000000000000000000000000000000n,
|
|
87
|
-
rateAtTarget: 94850992095n
|
|
88
|
+
rateAtTarget: 94850992095n,
|
|
88
89
|
});
|
|
89
90
|
|
|
90
91
|
market.utilization; // e.g. 92_0000000000000000n (92%).
|
|
@@ -110,7 +111,7 @@ const position = new AccrualPosition(
|
|
|
110
111
|
marketId: market.id,
|
|
111
112
|
supplyShares: 0n,
|
|
112
113
|
borrowShares: 20_000000000000000000000000n,
|
|
113
|
-
collateral: 27_000000000000000000n
|
|
114
|
+
collateral: 27_000000000000000000n,
|
|
114
115
|
}),
|
|
115
116
|
market
|
|
116
117
|
);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ChainId } from "./chain.js";
|
|
2
|
+
import type { Address } from "./types.js";
|
|
3
|
+
/** Address used to replicate an erc20-behaviour for native token.
|
|
4
|
+
*
|
|
5
|
+
* NB: data might differ from expected onchain native token data
|
|
6
|
+
*/
|
|
7
|
+
export declare const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
8
|
+
export declare const addresses: {
|
|
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";
|
|
48
|
+
};
|
|
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";
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export interface ChainAddresses {
|
|
66
|
+
morpho: Address;
|
|
67
|
+
permit2: Address;
|
|
68
|
+
bundler: Address;
|
|
69
|
+
aaveV3OptimizerBundler?: Address;
|
|
70
|
+
aaveV2Bundler?: Address;
|
|
71
|
+
aaveV3Bundler?: Address;
|
|
72
|
+
compoundV3Bundler?: Address;
|
|
73
|
+
compoundV2Bundler?: Address;
|
|
74
|
+
adaptiveCurveIrm: Address;
|
|
75
|
+
publicAllocator: Address;
|
|
76
|
+
metaMorphoFactory: Address;
|
|
77
|
+
wNative: Address;
|
|
78
|
+
morphoToken?: Address;
|
|
79
|
+
dai?: Address;
|
|
80
|
+
mkr?: Address;
|
|
81
|
+
usdc?: Address;
|
|
82
|
+
stEth?: Address;
|
|
83
|
+
wstEth?: Address;
|
|
84
|
+
}
|
|
85
|
+
export type AddressLabel = keyof (typeof addresses)[ChainId];
|
|
86
|
+
declare const _default: { [n in ChainId]: ChainAddresses; };
|
|
87
|
+
export default _default;
|
|
88
|
+
export declare const getChainAddresses: (chainId: number) => ChainAddresses;
|
|
89
|
+
/**
|
|
90
|
+
* Assumptions:
|
|
91
|
+
* - unwrapped token has same number of decimals than wrapped tokens.
|
|
92
|
+
*/
|
|
93
|
+
export declare const unwrappedTokensMapping: Record<ChainId, Record<Address, Address>>;
|
|
94
|
+
export declare function getUnwrappedToken(wrappedToken: Address, chainId: ChainId): `0x${string}` | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* The registry of all known ERC20Wrapper tokens.
|
|
97
|
+
*/
|
|
98
|
+
export declare const erc20WrapperTokens: Record<ChainId, Set<Address>>;
|
|
99
|
+
/**
|
|
100
|
+
* The registry of all known PermissionedERC20Wrapper with a `hasPermission` getter.
|
|
101
|
+
* All permissioned wrapper tokens are considered ERC20Wrapper and automatically added to the erc20WrapperTokens registry.
|
|
102
|
+
*/
|
|
103
|
+
export declare const permissionedWrapperTokens: Record<ChainId, Set<Address>>;
|
|
104
|
+
/**
|
|
105
|
+
* The registry of all known permissioned wrapped Backed tokens.
|
|
106
|
+
* All permissioned Backed tokens are considered ERC20Wrapper and automatically added to the erc20WrapperTokens registry.
|
|
107
|
+
*/
|
|
108
|
+
export declare const permissionedBackedTokens: Record<ChainId, Set<Address>>;
|
|
109
|
+
/**
|
|
110
|
+
* The registry of all known permissioned wrapped tokens that require a Coinbase attestation.
|
|
111
|
+
* All permissioned Coinbase tokens are considered PermissionedERC20Wrapper and automatically added to the permissionedWrapperTokens registry.
|
|
112
|
+
*/
|
|
113
|
+
export declare const permissionedCoinbaseTokens: Record<ChainId, Set<Address>>;
|
|
114
|
+
/** /!\ These tokens can not be listed in `erc20WrapperTokens` because the following specs are different:
|
|
115
|
+
* - calling `depositFor` supplies on blue instead of minting wrapped token to the user
|
|
116
|
+
*/
|
|
117
|
+
export declare const convexWrapperTokens: Record<ChainId, Set<Address>>;
|
package/lib/addresses.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { entries } from "@morpho-org/morpho-ts";
|
|
2
|
+
import { ChainId, ChainUtils } from "./chain.js";
|
|
3
|
+
/** Address used to replicate an erc20-behaviour for native token.
|
|
4
|
+
*
|
|
5
|
+
* NB: data might differ from expected onchain native token data
|
|
6
|
+
*/
|
|
7
|
+
export const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
8
|
+
export const addresses = {
|
|
9
|
+
[ChainId.EthMainnet]: {
|
|
10
|
+
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
11
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
12
|
+
bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077",
|
|
13
|
+
aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c",
|
|
14
|
+
aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76",
|
|
15
|
+
aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC",
|
|
16
|
+
compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558",
|
|
17
|
+
compoundV2Bundler: "0x26bf52a84360ad3d01d7cdc28fc2ddc04d8c8647",
|
|
18
|
+
adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
|
|
19
|
+
publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D",
|
|
20
|
+
metaMorphoFactory: "0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101",
|
|
21
|
+
wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
22
|
+
morphoToken: "0x9994E35Db50125E0DF82e4c2dde62496CE330999",
|
|
23
|
+
dai: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
|
|
24
|
+
sDai: "0x83F20F44975D03b1b09e64809B757c47f942BEeA",
|
|
25
|
+
mkr: "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2",
|
|
26
|
+
stEth: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
|
|
27
|
+
wstEth: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
|
28
|
+
osEth: "0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38",
|
|
29
|
+
bIB01: "0xCA30c93B02514f86d5C86a6e375E3A330B435Fb5",
|
|
30
|
+
// If we want to change the wbIB01 address, we have to check if the new one has simple permit or not.
|
|
31
|
+
// Currently, wbIB01 is considered to have simple permit.
|
|
32
|
+
wbIB01: "0xcA2A7068e551d5C4482eb34880b194E4b945712F",
|
|
33
|
+
bC3M: "0x2F123cF3F37CE3328CC9B5b8415f9EC5109b45e7",
|
|
34
|
+
// If we want to change the wbC3M address, we have to check if the new one has simple permit or not.
|
|
35
|
+
// Currently, wbC3M is considered to have simple permit.
|
|
36
|
+
wbC3M: "0x95D7337d43340E2721960Dc402D9b9117f0d81a2",
|
|
37
|
+
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
38
|
+
usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
39
|
+
crvUsd: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
40
|
+
"stkcvxcrvUSDTWBTCWETH-morpho": "0xb0Ce26C88e4e7DCa51968b6047f44646f5064278",
|
|
41
|
+
crvUSDTWBTCWETH: "0xf5f5B97624542D72A9E06f04804Bf81baA15e2B4",
|
|
42
|
+
"stkcvxcrvUSDCWBTCWETH-morpho": "0x0ea1a65A2c255f24Ee8D81eA6AaC54Decd9d269e",
|
|
43
|
+
crvUSDCWBTCWETH: "0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B",
|
|
44
|
+
"stkcvxcrvCRVUSDTBTCWSTETH-morpho": "0x3ce8Ec9f3d89aD0A2DdbCC3FDB8991BD241Fc82E",
|
|
45
|
+
crvCRVUSDTBTCWSTETH: "0x2889302a794dA87fBF1D6Db415C1492194663D13",
|
|
46
|
+
"stkcvxTryLSD-morpho": "0x6BA072F0d22806F2C52e9792AF47f2D59103BEBE",
|
|
47
|
+
tryLSD: "0x2570f1bD5D2735314FC102eb12Fc1aFe9e6E7193",
|
|
48
|
+
"stkcvxcrvUSDETHCRV-morpho": "0xAc904BAfBb5FB04Deb2b6198FdCEedE75a78Ce5a",
|
|
49
|
+
crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14",
|
|
50
|
+
"stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e",
|
|
51
|
+
"2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726",
|
|
52
|
+
},
|
|
53
|
+
[ChainId.BaseMainnet]: {
|
|
54
|
+
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
55
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
56
|
+
bundler: "0x23055618898e202386e6c13955a58D3C68200BFB",
|
|
57
|
+
compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223",
|
|
58
|
+
aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108",
|
|
59
|
+
compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA",
|
|
60
|
+
adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687",
|
|
61
|
+
publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
|
|
62
|
+
metaMorphoFactory: "0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101",
|
|
63
|
+
wNative: "0x4200000000000000000000000000000000000006",
|
|
64
|
+
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
65
|
+
verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b",
|
|
66
|
+
testUsdc: "0xBC77067f829979812d795d516E523C4033b66409",
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
export default addresses;
|
|
70
|
+
export const getChainAddresses = (chainId) => {
|
|
71
|
+
return addresses[ChainUtils.parseSupportedChainId(chainId)];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Assumptions:
|
|
75
|
+
* - unwrapped token has same number of decimals than wrapped tokens.
|
|
76
|
+
*/
|
|
77
|
+
export const unwrappedTokensMapping = {
|
|
78
|
+
[ChainId.EthMainnet]: {
|
|
79
|
+
[addresses[ChainId.EthMainnet].wbIB01]: addresses[ChainId.EthMainnet].bIB01,
|
|
80
|
+
[addresses[ChainId.EthMainnet].wbC3M]: addresses[ChainId.EthMainnet].bC3M,
|
|
81
|
+
[addresses[ChainId.EthMainnet].wNative]: NATIVE_ADDRESS,
|
|
82
|
+
[addresses[ChainId.EthMainnet].stEth]: NATIVE_ADDRESS,
|
|
83
|
+
[addresses[ChainId.EthMainnet].wstEth]: addresses[ChainId.EthMainnet].stEth,
|
|
84
|
+
[addresses[ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"]]: addresses[ChainId.EthMainnet].crvUSDTWBTCWETH,
|
|
85
|
+
[addresses[ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"]]: addresses[ChainId.EthMainnet].crvUSDCWBTCWETH,
|
|
86
|
+
[addresses[ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"]]: addresses[ChainId.EthMainnet].crvCRVUSDTBTCWSTETH,
|
|
87
|
+
[addresses[ChainId.EthMainnet]["stkcvxTryLSD-morpho"]]: addresses[ChainId.EthMainnet].tryLSD,
|
|
88
|
+
[addresses[ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"]]: addresses[ChainId.EthMainnet].crvUSDETHCRV,
|
|
89
|
+
[addresses[ChainId.EthMainnet]["stkcvx2BTC-f-morpho"]]: addresses[ChainId.EthMainnet]["2BTC-f"],
|
|
90
|
+
},
|
|
91
|
+
[ChainId.BaseMainnet]: {
|
|
92
|
+
[addresses[ChainId.BaseMainnet].wNative]: NATIVE_ADDRESS,
|
|
93
|
+
[addresses[ChainId.BaseMainnet].verUsdc]: addresses[ChainId.BaseMainnet].usdc,
|
|
94
|
+
[addresses[ChainId.BaseMainnet].testUsdc]: addresses[ChainId.BaseMainnet].usdc,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
export function getUnwrappedToken(wrappedToken, chainId) {
|
|
98
|
+
return unwrappedTokensMapping[chainId][wrappedToken];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The registry of all known ERC20Wrapper tokens.
|
|
102
|
+
*/
|
|
103
|
+
export const erc20WrapperTokens = {
|
|
104
|
+
[ChainId.EthMainnet]: new Set(),
|
|
105
|
+
[ChainId.BaseMainnet]: new Set(),
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* The registry of all known PermissionedERC20Wrapper with a `hasPermission` getter.
|
|
109
|
+
* All permissioned wrapper tokens are considered ERC20Wrapper and automatically added to the erc20WrapperTokens registry.
|
|
110
|
+
*/
|
|
111
|
+
export const permissionedWrapperTokens = {
|
|
112
|
+
[ChainId.EthMainnet]: new Set(),
|
|
113
|
+
[ChainId.BaseMainnet]: new Set([addresses[ChainId.BaseMainnet].testUsdc]),
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* The registry of all known permissioned wrapped Backed tokens.
|
|
117
|
+
* All permissioned Backed tokens are considered ERC20Wrapper and automatically added to the erc20WrapperTokens registry.
|
|
118
|
+
*/
|
|
119
|
+
export const permissionedBackedTokens = {
|
|
120
|
+
[ChainId.EthMainnet]: new Set([
|
|
121
|
+
addresses[ChainId.EthMainnet].wbIB01,
|
|
122
|
+
addresses[ChainId.EthMainnet].wbC3M,
|
|
123
|
+
]),
|
|
124
|
+
[ChainId.BaseMainnet]: new Set(),
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* The registry of all known permissioned wrapped tokens that require a Coinbase attestation.
|
|
128
|
+
* All permissioned Coinbase tokens are considered PermissionedERC20Wrapper and automatically added to the permissionedWrapperTokens registry.
|
|
129
|
+
*/
|
|
130
|
+
export const permissionedCoinbaseTokens = {
|
|
131
|
+
[ChainId.EthMainnet]: new Set(),
|
|
132
|
+
[ChainId.BaseMainnet]: new Set([addresses[ChainId.BaseMainnet].verUsdc]),
|
|
133
|
+
};
|
|
134
|
+
entries(permissionedBackedTokens).forEach(([chainId, tokens]) => {
|
|
135
|
+
tokens.forEach((token) => erc20WrapperTokens[chainId].add(token));
|
|
136
|
+
});
|
|
137
|
+
entries(permissionedCoinbaseTokens).forEach(([chainId, tokens]) => {
|
|
138
|
+
tokens.forEach((token) => permissionedWrapperTokens[chainId].add(token));
|
|
139
|
+
});
|
|
140
|
+
entries(permissionedWrapperTokens).forEach(([chainId, tokens]) => {
|
|
141
|
+
tokens.forEach((token) => erc20WrapperTokens[chainId].add(token));
|
|
142
|
+
});
|
|
143
|
+
/** /!\ These tokens can not be listed in `erc20WrapperTokens` because the following specs are different:
|
|
144
|
+
* - calling `depositFor` supplies on blue instead of minting wrapped token to the user
|
|
145
|
+
*/
|
|
146
|
+
export const convexWrapperTokens = {
|
|
147
|
+
[ChainId.EthMainnet]: new Set([
|
|
148
|
+
addresses[ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"],
|
|
149
|
+
addresses[ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"],
|
|
150
|
+
addresses[ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"],
|
|
151
|
+
addresses[ChainId.EthMainnet]["stkcvxTryLSD-morpho"],
|
|
152
|
+
addresses[ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"],
|
|
153
|
+
addresses[ChainId.EthMainnet]["stkcvx2BTC-f-morpho"],
|
|
154
|
+
]),
|
|
155
|
+
[ChainId.BaseMainnet]: new Set(),
|
|
156
|
+
};
|
package/lib/chain.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare enum ChainId {
|
|
2
|
+
EthMainnet = 1,
|
|
3
|
+
BaseMainnet = 8453
|
|
4
|
+
}
|
|
5
|
+
export interface ChainMetadata {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly id: ChainId;
|
|
8
|
+
readonly defaultRpcUrl: string;
|
|
9
|
+
readonly explorerUrl: string;
|
|
10
|
+
readonly nativeCurrency: {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly symbol: string;
|
|
13
|
+
readonly decimals: number;
|
|
14
|
+
};
|
|
15
|
+
readonly isTestnet: boolean;
|
|
16
|
+
readonly shortName: string;
|
|
17
|
+
readonly identifier: string;
|
|
18
|
+
readonly logoSrc: string;
|
|
19
|
+
}
|
|
20
|
+
export declare namespace ChainUtils {
|
|
21
|
+
const toHexChainId: (chainId: ChainId) => string;
|
|
22
|
+
const getExplorerUrl: (chainId: ChainId) => string;
|
|
23
|
+
const getExplorerAddressUrl: (chainId: ChainId, address: string) => string;
|
|
24
|
+
const getExplorerTransactionUrl: (chainId: ChainId, tx: string) => string;
|
|
25
|
+
function isSupported(chainId: number): chainId is ChainId;
|
|
26
|
+
function parseSupportedChainId(candidate: unknown): ChainId;
|
|
27
|
+
const BLUE_AVAILABLE_CHAINS: [ChainId, ...ChainId[]];
|
|
28
|
+
const CHAIN_METADATA: Record<ChainId, ChainMetadata>;
|
|
29
|
+
}
|