@morpho-org/blue-sdk 1.0.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 (59) hide show
  1. package/README.md +98 -0
  2. package/package.json +54 -0
  3. package/src/addresses.ts +261 -0
  4. package/src/chain/chain.constants.ts +235 -0
  5. package/src/chain/chain.test.ts +51 -0
  6. package/src/chain/chain.types.ts +42 -0
  7. package/src/chain/chain.utils.ts +44 -0
  8. package/src/chain/index.ts +2 -0
  9. package/src/constants.ts +18 -0
  10. package/src/errors.ts +75 -0
  11. package/src/ethers/ethers.test.ts +17 -0
  12. package/src/ethers/index.ts +2 -0
  13. package/src/ethers/safeGetAddress.ts +4 -0
  14. package/src/ethers/safeParseUnits.ts +29 -0
  15. package/src/evm.ts +172 -0
  16. package/src/helpers/format/format.test.ts +340 -0
  17. package/src/helpers/format/format.ts +416 -0
  18. package/src/helpers/format/index.ts +1 -0
  19. package/src/helpers/getChecksumedAddress.ts +15 -0
  20. package/src/helpers/index.ts +4 -0
  21. package/src/helpers/isZeroAddressOrUnset.ts +13 -0
  22. package/src/helpers/locale.ts +108 -0
  23. package/src/holding/Holding.ts +109 -0
  24. package/src/holding/index.ts +1 -0
  25. package/src/index.ts +34 -0
  26. package/src/market/Market.ts +479 -0
  27. package/src/market/MarketConfig.ts +108 -0
  28. package/src/market/MarketUtils.test.ts +25 -0
  29. package/src/market/MarketUtils.ts +467 -0
  30. package/src/market/index.ts +3 -0
  31. package/src/maths/AdaptiveCurveIrmLib.ts +143 -0
  32. package/src/maths/MathLib.ts +208 -0
  33. package/src/maths/MathUtils.ts +31 -0
  34. package/src/maths/SharesMath.ts +40 -0
  35. package/src/maths/index.ts +4 -0
  36. package/src/notifications.ts +167 -0
  37. package/src/position/Position.ts +251 -0
  38. package/src/position/index.ts +1 -0
  39. package/src/signatures/index.ts +18 -0
  40. package/src/signatures/manager.ts +50 -0
  41. package/src/signatures/permit.ts +126 -0
  42. package/src/signatures/permit2.ts +120 -0
  43. package/src/signatures/types.ts +18 -0
  44. package/src/signatures/utils.ts +83 -0
  45. package/src/tests/mocks/markets.ts +110 -0
  46. package/src/token/ERC20Metadata.ts +124 -0
  47. package/src/token/Token.ts +83 -0
  48. package/src/token/TokenNamespace.ts +76 -0
  49. package/src/token/WrappedToken.ts +142 -0
  50. package/src/token/index.ts +2 -0
  51. package/src/types.ts +37 -0
  52. package/src/user/User.ts +32 -0
  53. package/src/user/index.ts +2 -0
  54. package/src/user/user.types.ts +23 -0
  55. package/src/vault/Vault.ts +370 -0
  56. package/src/vault/VaultAllocation.ts +58 -0
  57. package/src/vault/VaultConfig.ts +55 -0
  58. package/src/vault/VaultUtils.ts +47 -0
  59. package/src/vault/index.ts +4 -0
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @morpho-org/blue-sdk
2
+
3
+ [![npm package][npm-img]][npm-url]
4
+ [![Downloads][downloads-img]][downloads-url]
5
+
6
+ > Ethers-based SDK foundational to Morpho Blue's offchain ecosystem, useful to fetch and interact with the protocol and MetaMorpho.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @morpho-org/blue-sdk
12
+ ```
13
+
14
+ ```bash
15
+ yarn add @morpho-org/blue-sdk
16
+ ```
17
+
18
+ ---
19
+
20
+ ## Getting Started
21
+
22
+ ### Fetch the config of a specific market
23
+
24
+ Leverage the [`MarketConfig`](./src/market/MarketConfig.ts) class to fetch and query minimal information on a given market's immutable configuration:
25
+
26
+ ```typescript
27
+ import { MarketConfig } from "@morpho-org/blue-sdk";
28
+
29
+ const config = MarketConfig.fetch(
30
+ "0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc",
31
+ provider // Ethers provider.
32
+ );
33
+
34
+ market.collateralToken; // e.g. 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0.
35
+ ```
36
+
37
+ ### Fetch data of a specific market
38
+
39
+ Leverage the [`Market`](./src/market/Market.ts) class to fetch and query useful information on a specific market:
40
+
41
+ ```typescript
42
+ import { Market } from "@morpho-org/blue-sdk";
43
+ import { Time } from "@morpho-org/morpho-ts";
44
+
45
+ const market = Market.fetchFromId(
46
+ "0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc",
47
+ provider // Ethers provider.
48
+ );
49
+
50
+ // Or from a config, to fetch faster:
51
+ // const market = Market.fetchFromConfig(
52
+ // config,
53
+ // provider // Ethers provider.
54
+ // );
55
+
56
+ market.utilization; // e.g. 92% (scaled by WAD).
57
+ market.liquidity; // e.g. 23_000000n (in loan assets).
58
+ market.apyAtTarget; // e.g. 3% (scaled by WAD).
59
+
60
+ const accruedMarket = market.accrueInterest(Time.timestamp()); // Accrue interest to the latest's timestamp.
61
+
62
+ accruedMarket.toSupplyAssets(shares); // Convert supply shares to assets.
63
+ ```
64
+
65
+ ### Fetch data on the position of a specific user on a specific market
66
+
67
+ Leverage the [`Position`](./src/position/Position.ts) class to fetch and query useful information about the position of a user on a given market:
68
+
69
+ ```typescript
70
+ import { Position } from "@morpho-org/blue-sdk";
71
+ import { Time } from "@morpho-org/morpho-ts";
72
+
73
+ const position = AccrualPosition.fetchFromId(
74
+ "0x7f65e7326F22963e2039734dDfF61958D5d284Ca",
75
+ "0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc",
76
+ provider // Ethers provider.
77
+ );
78
+
79
+ // Or from a config, to fetch faster:
80
+ // const position = AccrualPosition.fetchFromConfig(
81
+ // "0x7f65e7326F22963e2039734dDfF61958D5d284Ca",
82
+ // config,
83
+ // provider // Ethers provider.
84
+ // );
85
+
86
+ position.borrowAssets; // e.g. 23_000000n (in loan assets).
87
+ position.isHealthy; // e.g. true.
88
+ position.maxBorrowableAssets; // e.g. 2100_000000n (in loan assets).
89
+
90
+ const accruedPosition = position.accrueInterest(Time.timestamp()); // Accrue interest to the latest's timestamp.
91
+
92
+ position.borrowAssets; // e.g. 23_500000n (in loan assets).
93
+ ```
94
+
95
+ [downloads-img]: https://img.shields.io/npm/dt/@morpho-org/blue-sdk
96
+ [downloads-url]: https://www.npmtrends.com/@morpho-org/blue-sdk
97
+ [npm-img]: https://img.shields.io/npm/v/@morpho-org/blue-sdk
98
+ [npm-url]: https://www.npmjs.com/package/@morpho-org/blue-sdk
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@morpho-org/blue-sdk",
3
+ "version": "1.0.0",
4
+ "author": "Morpho Association <contact@morpho.org>",
5
+ "license": "MIT",
6
+ "main": "src/index.ts",
7
+ "files": [
8
+ "src"
9
+ ],
10
+ "scripts": {
11
+ "prepublish": "yarn build",
12
+ "build": "tsc --build tsconfig.build.json",
13
+ "build:blue-sdk": "yarn build",
14
+ "test": "jest",
15
+ "test:blue-sdk": "yarn test"
16
+ },
17
+ "dependencies": {
18
+ "@morpho-org/morpho-ts": "1.0.0",
19
+ "ethers": "^6.12.1",
20
+ "ethers-multicall-provider": "^6.3.0",
21
+ "ethers-types": "^3.15.1",
22
+ "rxjs": "^7.8.1"
23
+ },
24
+ "devDependencies": {
25
+ "@morpho-org/morpho-test": "1.0.0",
26
+ "@types/jest": "^29.5.12",
27
+ "jest": "^29.6.2",
28
+ "ts-jest": "^29.1.1",
29
+ "typescript": "^5.4.5"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "jest": {
35
+ "verbose": true,
36
+ "testTimeout": 15000,
37
+ "maxWorkers": 1,
38
+ "transform": {
39
+ "^.+\\.tsx?$": [
40
+ "ts-jest",
41
+ {
42
+ "tsconfig": "tsconfig.json"
43
+ }
44
+ ]
45
+ },
46
+ "testRegex": "(/src/.*|(\\.|/)(test|spec)+)\\.test\\.(jsx?|tsx?)$",
47
+ "moduleFileExtensions": [
48
+ "js",
49
+ "ts"
50
+ ],
51
+ "preset": "ts-jest"
52
+ },
53
+ "gitHead": "ba4bc39fbf7d9e2fe2282b451940fb90305544fa"
54
+ }
@@ -0,0 +1,261 @@
1
+ import { ChainId } from "./chain";
2
+ import { UnsupportedChainIdError } from "./errors";
3
+ import { Address } from "./types";
4
+
5
+ /** Address used to replicate an erc20-behaviour for native token.
6
+ *
7
+ * NB: data might differ from expected onchain native token data
8
+ */
9
+ export const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
10
+
11
+ export const addresses = {
12
+ [ChainId.EthGoerliTestnet]: {
13
+ morpho: "0x64c7044050Ba0431252df24fEd4d9635a275CB41",
14
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
15
+ bundler: "0xCFFbEEAFCD79Fd68FD56Dbc31A419f290A2Fe9e0",
16
+ urd: "0x820755E757a590683dc43115290eb1Cb20a60405",
17
+ wNative: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
18
+ stEth: "0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F",
19
+ wstEth: "0x6320cD32aA674d2898A68ec82e869385Fc5f7E2f",
20
+ rEth: "0x178E141a0E3b34152f73Ff610437A7bf9B83267A",
21
+ sDai: "0xD8134205b0328F5676aaeFb3B2a0DC15f4029d8C",
22
+ dai: "0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844",
23
+ usdc: "0x62bD2A599664D421132d7C54AB4DbE3233f4f0Ae",
24
+ usdt: "0x576e379FA7B899b4De1E251e935B31543Df3e954",
25
+ },
26
+ [ChainId.EthMainnet]: {
27
+ morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
28
+ adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
29
+ publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D",
30
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
31
+ bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077",
32
+ aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c",
33
+ aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76",
34
+ aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC",
35
+ morphoToken: "0x9994E35Db50125E0DF82e4c2dde62496CE330999",
36
+ rEth: "0xae78736Cd615f374D3085123A210448E74Fc6393",
37
+ sDai: "0x83F20F44975D03b1b09e64809B757c47f942BEeA",
38
+ dai: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
39
+ mkr: "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2",
40
+ wstEth: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
41
+ wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
42
+ stEth: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
43
+ USDe: "0x4c9EDD5852cd905f086C759E8383e09bff1E68B3",
44
+ sUSDe: "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497",
45
+ bIB01: "0xCA30c93B02514f86d5C86a6e375E3A330B435Fb5",
46
+ // If we want to change the wbIB01 address, we have to check if the new one has simple permit or not.
47
+ // Currently, wbIB01 is considered to have simple permit.
48
+ wbIB01: "0xcA2A7068e551d5C4482eb34880b194E4b945712F",
49
+ bC3M: "0x2F123cF3F37CE3328CC9B5b8415f9EC5109b45e7",
50
+ // If we want to change the wbC3M address, we have to check if the new one has simple permit or not.
51
+ // Currently, wbC3M is considered to have simple permit.
52
+ wbC3M: "0x95D7337d43340E2721960Dc402D9b9117f0d81a2",
53
+ usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
54
+ usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
55
+ wbtc: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
56
+ sWise: "0x48C3399719B582dD63eB5AADf12A40B4C3f52FA2",
57
+ osEth: "0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38",
58
+ weEth: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
59
+ ezEth: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
60
+ pyUsd: "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8",
61
+ crvUsd: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
62
+ morphoOperator: "0x640428D38189B11B844dAEBDBAAbbdfbd8aE0143",
63
+ butterfly: "0xc55126051B22eBb829D00368f4B12Bde432de5Da",
64
+ marketRewardsProgramRegistry: "0x5148bF15bb722E1854F66430Bc9FeD0E9FDaCE7D",
65
+ timeBoundedUrd: "0x330eefa8a787552DC5cAd3C3cA644844B1E61Ddb",
66
+ rsEth: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
67
+
68
+ /* Curve tokens */
69
+ "stkcvxcrvUSDTWBTCWETH-morpho":
70
+ "0xb0Ce26C88e4e7DCa51968b6047f44646f5064278",
71
+ crvUSDTWBTCWETH: "0xf5f5B97624542D72A9E06f04804Bf81baA15e2B4",
72
+
73
+ "stkcvxcrvUSDCWBTCWETH-morpho":
74
+ "0x0ea1a65A2c255f24Ee8D81eA6AaC54Decd9d269e",
75
+ crvUSDCWBTCWETH: "0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B",
76
+
77
+ "stkcvxcrvCRVUSDTBTCWSTETH-morpho":
78
+ "0x3ce8Ec9f3d89aD0A2DdbCC3FDB8991BD241Fc82E",
79
+ crvCRVUSDTBTCWSTETH: "0x2889302a794dA87fBF1D6Db415C1492194663D13",
80
+
81
+ "stkcvxTryLSD-morpho": "0x6BA072F0d22806F2C52e9792AF47f2D59103BEBE",
82
+ tryLSD: "0x2570f1bD5D2735314FC102eb12Fc1aFe9e6E7193",
83
+
84
+ "stkcvxcrvUSDETHCRV-morpho": "0xAc904BAfBb5FB04Deb2b6198FdCEedE75a78Ce5a",
85
+ crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14",
86
+ },
87
+ [ChainId.BaseMainnet]: {
88
+ morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
89
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
90
+ bundler: "0xb5D342521EB5b983aE6a6324A4D9eac87C9D1987",
91
+ wNative: "0x4200000000000000000000000000000000000006",
92
+ adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687",
93
+ publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
94
+
95
+ /* Tokens */
96
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
97
+ cbEth: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22",
98
+ },
99
+ } as const;
100
+
101
+ interface ChainAddresses {
102
+ morpho: Address;
103
+ permit2: Address;
104
+ bundler: Address;
105
+ wNative: Address;
106
+ adaptiveCurveIrm?: Address;
107
+ publicAllocator?: Address;
108
+ morphoToken?: Address;
109
+ wstEth?: Address;
110
+ stEth?: Address;
111
+ dai?: Address;
112
+ mkr?: Address;
113
+ rEth?: Address;
114
+ sDai?: Address;
115
+ usdc?: Address;
116
+ usdt?: Address;
117
+ bIB01?: Address;
118
+ wbIB01?: Address;
119
+ bC3M?: Address;
120
+ wbC3M?: Address;
121
+ wbtc?: Address;
122
+ sWise?: Address;
123
+ osEth?: Address;
124
+ weEth?: Address;
125
+ ezEth?: Address;
126
+ pyUsd?: Address;
127
+ sUSDe?: Address;
128
+ USDe?: Address;
129
+ marketRewardsProgramRegistry?: Address;
130
+ timeBoundedUrd?: Address;
131
+ rsEth?: Address;
132
+ crvUsd?: Address;
133
+ morphoOperator?: Address;
134
+ butterfly?: Address;
135
+ aaveV3OptimizerBundler?: Address;
136
+ aaveV2Bundler?: Address;
137
+ aaveV3Bundler?: Address;
138
+
139
+ /* Curve tokens */
140
+ "stkcvxcrvUSDTWBTCWETH-morpho"?: Address;
141
+ crvUSDTWBTCWETH?: Address;
142
+ "stkcvxcrvUSDCWBTCWETH-morpho"?: Address;
143
+ crvUSDCWBTCWETH?: Address;
144
+ "stkcvxcrvCRVUSDTBTCWSTETH-morpho"?: Address;
145
+ crvCRVUSDTBTCWSTETH?: Address;
146
+ "stkcvxTryLSD-morpho"?: Address;
147
+ tryLSD?: Address;
148
+ "stkcvxcrvUSDETHCRV-morpho"?: Address;
149
+ crvUSDETHCRV?: Address;
150
+ }
151
+
152
+ export type AddressLabel = keyof (typeof addresses)[ChainId];
153
+
154
+ export default addresses as {
155
+ [n in ChainId]: ChainAddresses;
156
+ };
157
+
158
+ export const getChainAddresses = (chainId: number): ChainAddresses => {
159
+ const chainAddresses = addresses[chainId as ChainId];
160
+
161
+ if (!chainAddresses) throw new UnsupportedChainIdError(chainId);
162
+
163
+ return chainAddresses;
164
+ };
165
+
166
+ export const wrapping: {
167
+ [n in ChainId]: {
168
+ [unwrapped: string]: string;
169
+ };
170
+ } = {
171
+ [ChainId.EthGoerliTestnet]: {
172
+ [NATIVE_ADDRESS]: addresses[ChainId.EthGoerliTestnet].wNative,
173
+ [addresses[ChainId.EthGoerliTestnet].stEth]:
174
+ addresses[ChainId.EthGoerliTestnet].wstEth,
175
+ },
176
+ [ChainId.EthMainnet]: {
177
+ [addresses[ChainId.EthMainnet].bIB01]: addresses[ChainId.EthMainnet].wbIB01,
178
+ [addresses[ChainId.EthMainnet].bC3M]: addresses[ChainId.EthMainnet].wbC3M,
179
+ [NATIVE_ADDRESS]: addresses[ChainId.EthMainnet].wNative,
180
+ [addresses[ChainId.EthMainnet].stEth]: addresses[ChainId.EthMainnet].wstEth,
181
+ [addresses[ChainId.EthMainnet].crvUSDTWBTCWETH]:
182
+ addresses[ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"],
183
+ [addresses[ChainId.EthMainnet].crvUSDCWBTCWETH]:
184
+ addresses[ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"],
185
+ [addresses[ChainId.EthMainnet].crvCRVUSDTBTCWSTETH]:
186
+ addresses[ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"],
187
+ [addresses[ChainId.EthMainnet].tryLSD]:
188
+ addresses[ChainId.EthMainnet]["stkcvxTryLSD-morpho"],
189
+ [addresses[ChainId.EthMainnet].crvUSDETHCRV]:
190
+ addresses[ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"],
191
+ },
192
+ [ChainId.BaseMainnet]: {
193
+ [NATIVE_ADDRESS]: addresses[ChainId.BaseMainnet].wNative,
194
+ },
195
+ };
196
+
197
+ export const reverseWrapping = Object.fromEntries(
198
+ Object.entries(wrapping).map(([n, chainWrapping]) => [
199
+ n,
200
+ Object.fromEntries(
201
+ Object.entries(chainWrapping)
202
+ .map((w) => [...w].reverse())
203
+ .filter(([add, wAdd]) => !!add && !!wAdd)
204
+ ),
205
+ ])
206
+ ) as typeof wrapping;
207
+
208
+ export function getUnwrappedToken(wrappedToken: Address, chainId: ChainId) {
209
+ return reverseWrapping[chainId][wrappedToken];
210
+ }
211
+
212
+ export function getWrappedToken(unWrappedToken: Address, chainId: ChainId) {
213
+ return wrapping[chainId][unWrappedToken];
214
+ }
215
+
216
+ export const erc20WrapperTokens: {
217
+ [id in ChainId]: Set<Address>;
218
+ } = {
219
+ [ChainId.EthMainnet]: new Set([
220
+ addresses[ChainId.EthMainnet].wbIB01,
221
+ addresses[ChainId.EthMainnet].wbC3M,
222
+ ]),
223
+ [ChainId.EthGoerliTestnet]: new Set(),
224
+ [ChainId.BaseMainnet]: new Set(),
225
+ };
226
+
227
+ export const wrappedBackedTokens: {
228
+ [id in ChainId]: Set<Address>;
229
+ } = {
230
+ [ChainId.EthMainnet]: new Set([
231
+ addresses[ChainId.EthMainnet].wbIB01,
232
+ addresses[ChainId.EthMainnet].wbC3M,
233
+ ]),
234
+ [ChainId.EthGoerliTestnet]: new Set(),
235
+ [ChainId.BaseMainnet]: new Set(),
236
+ };
237
+
238
+ export const getWrappedBackedTokens = (chainId: number) => {
239
+ const tokens = wrappedBackedTokens[chainId as ChainId];
240
+
241
+ if (!tokens) throw new UnsupportedChainIdError(chainId);
242
+
243
+ return tokens;
244
+ };
245
+
246
+ /** /!\ These tokens can not be listed in `erc20WrapperTokens` because the following specs are different:
247
+ * - calling `depositFor` supplies on blue instead of minting wrapped token to the user
248
+ */
249
+ export const convexWrapperTokens: {
250
+ [id in ChainId]: Set<Address>;
251
+ } = {
252
+ [ChainId.EthMainnet]: new Set([
253
+ addresses[ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"],
254
+ addresses[ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"],
255
+ addresses[ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"],
256
+ addresses[ChainId.EthMainnet]["stkcvxTryLSD-morpho"],
257
+ addresses[ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"],
258
+ ]),
259
+ [ChainId.EthGoerliTestnet]: new Set(),
260
+ [ChainId.BaseMainnet]: new Set(),
261
+ };
@@ -0,0 +1,235 @@
1
+ import { ChainMetadata, ChainId } from "./chain.types";
2
+
3
+ export const BLUE_AVAILABLE_CHAINS = [ChainId.EthMainnet, ChainId.BaseMainnet];
4
+
5
+ export const CHAIN_METADATA: Record<ChainId, ChainMetadata> = {
6
+ [ChainId.EthMainnet]: {
7
+ name: "Ethereum",
8
+ id: ChainId.EthMainnet,
9
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
10
+ defaultRpcUrl:
11
+ "https://mainnet.infura.io/V3/84842078b09946638c03157f83405213",
12
+ explorerUrl: "https://etherscan.io",
13
+ isTestnet: false,
14
+ shortName: "ETH",
15
+ logoSrc: "https://cdn.morpho.org/assets/chains/eth.svg",
16
+ identifier: "mainnet",
17
+ },
18
+ [ChainId.EthGoerliTestnet]: {
19
+ name: "Ethereum Goerli Testnet",
20
+ id: ChainId.EthGoerliTestnet,
21
+ nativeCurrency: { name: "Goerli Ether", symbol: "ETH", decimals: 18 },
22
+ defaultRpcUrl:
23
+ "https://goerli.infura.io/V3/84842078b09946638c03157f83405213",
24
+ explorerUrl: "https://goerli.etherscan.io",
25
+ isTestnet: true,
26
+ shortName: "Goerli",
27
+ logoSrc: "https://cdn.morpho.org/assets/chains/eth.svg",
28
+ identifier: "goerli",
29
+ },
30
+ [ChainId.BaseMainnet]: {
31
+ name: "Base",
32
+ id: ChainId.BaseMainnet,
33
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
34
+ defaultRpcUrl: "https://rpc.baseprotocol.org",
35
+ explorerUrl: "https://basescan.org",
36
+ isTestnet: false,
37
+ shortName: "Base",
38
+ logoSrc: "https://cdn.morpho.org/assets/chains/base.png",
39
+ identifier: "base",
40
+ },
41
+ // [ChainId.PolygonMainnet]: {
42
+ // name: "Polygon Mainnet",
43
+ // id: ChainId.PolygonMainnet,
44
+ // nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18n },
45
+ // defaultRpcUrl: "https://rpc-mainnet.maticvigil.com",
46
+ // explorerUrl: "https://polygonscan.com",
47
+ // isTestnet: false,
48
+ // shortName: "Polygon",
49
+ // },
50
+ // [ChainId.MumbaiTestnet]: {
51
+ // name: "Mumbai Testnet",
52
+ // id: ChainId.MumbaiTestnet,
53
+ // nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18n },
54
+ // defaultRpcUrl: "https://rpc-mumbai.maticvigil.com",
55
+ // explorerUrl: "https://mumbai.polygonscan.com",
56
+ // isTestnet: true,
57
+ // shortName: "Mumbai",
58
+ // },
59
+
60
+ /* see https://chainid.network/chains.json */
61
+
62
+ // [ChainId.PolygonMainnet]: {
63
+ // name: "Polygon Mainnet",
64
+ // id: ChainId.PolygonMainnet,
65
+ // nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18n },
66
+ // defaultRpcUrl: "https://rpc-mainnet.maticvigil.com",
67
+ // explorerUrl: "https://polygonscan.com",
68
+ // isTestnet: false,
69
+ // shortName: "Polygon",
70
+ // },
71
+ // [ChainId.MumbaiTestnet]: {
72
+ // name: "Mumbai Testnet",
73
+ // id: ChainId.MumbaiTestnet,
74
+ // nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18n },
75
+ // defaultRpcUrl: "https://rpc-mumbai.maticvigil.com",
76
+ // explorerUrl: "https://mumbai.polygonscan.com",
77
+ // isTestnet: true,
78
+ // shortName: "Mumbai",
79
+ // },
80
+ // [ChainId.OptimismMainnet]: {
81
+ // name: "Optimism Mainnet",
82
+ // id: ChainId.OptimismMainnet,
83
+ // baseCurrency: "ETH",
84
+ // defaultRpcUrl: "https://mainnet.optimism.io",
85
+ // explorerUrl: "https://optimistic.etherscan.io",
86
+ // isTestnet: false,
87
+ // },
88
+ // [ChainId.BscMainnet]: {
89
+ // name: "Binance Smart Chain Mainnet",
90
+ // id: ChainId.BscMainnet,
91
+ // baseCurrency: "BNB",
92
+ // defaultRpcUrl: "https://bsc-dataseed.binance.org",
93
+ // explorerUrl: "https://bscscan.com",
94
+ // isTestnet: false,
95
+ // },
96
+ // [ChainId.ArbitrumMainnet]: {
97
+ // name: "Arbitrum Mainnet",
98
+ // id: ChainId.ArbitrumMainnet,
99
+ // baseCurrency: "ETH",
100
+ // defaultRpcUrl: "https://arb1.arbitrum.io/rpc",
101
+ // explorerUrl: "https://arbiscan.io",
102
+ // isTestnet: false,
103
+ // },
104
+ // [ChainId.ArbitrumTestnet]: {
105
+ // name: "Arbitrum Testnet",
106
+ // id: ChainId.ArbitrumTestnet,
107
+ // baseCurrency: "ETH",
108
+ // defaultRpcUrl: "https://rinkeby.arbitrum.io/rpc",
109
+ // explorerUrl: "https://rinkeby-explorer.arbitrum.io",
110
+ // isTestnet: true,
111
+ // },
112
+ // [ChainId.GnosisChain]: {
113
+ // name: "Gnosis Chain",
114
+ // id: ChainId.GnosisChain,
115
+ // baseCurrency: "XDAI",
116
+ // defaultRpcUrl: "https://rpc.xdaichain.com",
117
+ // explorerUrl: "https://gnosis.blockscout.com",
118
+ // isTestnet: false,
119
+ // },
120
+ // [ChainId.FantomMainnet]: {
121
+ // name: "Fantom Mainnet",
122
+ // id: ChainId.FantomMainnet,
123
+ // baseCurrency: "FTM",
124
+ // defaultRpcUrl: "https://rpcapi.fantom.network",
125
+ // explorerUrl: "https://ftmscan.com",
126
+ // isTestnet: false,
127
+ // },
128
+ // [ChainId.FantomTestnet]: {
129
+ // name: "Fantom Testnet",
130
+ // id: ChainId.FantomTestnet,
131
+ // baseCurrency: "FTM",
132
+ // defaultRpcUrl: "https://rpc.testnet.fantom.network",
133
+ // explorerUrl: "https://explorer.testnet.fantom.network",
134
+ // isTestnet: true,
135
+ // },
136
+ // [ChainId.HarmonyMainnet]: {
137
+ // name: "Harmony Mainnet",
138
+ // id: ChainId.HarmonyMainnet,
139
+ // baseCurrency: "ONE",
140
+ // defaultRpcUrl: "https://api.harmony.one",
141
+ // explorerUrl: "https://explorer.harmony.one",
142
+ // isTestnet: false,
143
+ // },
144
+ // [ChainId.HarmonyTestnet]: {
145
+ // name: "Harmony Testnet",
146
+ // id: ChainId.HarmonyTestnet,
147
+ // baseCurrency: "ONE",
148
+ // defaultRpcUrl: "https://api.s0.b.hmny.io",
149
+ // explorerUrl: "https://explorer.testnet.harmony.one",
150
+ // isTestnet: true,
151
+ // },
152
+ // [ChainId.BscTestnet]: {
153
+ // name: "Binance Smart Chain Testnet",
154
+ // id: ChainId.BscTestnet,
155
+ // baseCurrency: "BNB",
156
+ // defaultRpcUrl: "https://data-seed-prebsc-1-s1.binance.org:8545",
157
+ // explorerUrl: "https://testnet.bscscan.com",
158
+ // isTestnet: true,
159
+ // },
160
+ // [ChainId.OptimismTestnet]: {
161
+ // name: "Optimism Testnet",
162
+ // id: ChainId.OptimismTestnet,
163
+ // baseCurrency: "ETH",
164
+ // defaultRpcUrl: "https://kovan.optimism.io",
165
+ // explorerUrl: "https://kovan-optimistic.etherscan.io",
166
+ // isTestnet: true,
167
+ // },
168
+ // [ChainId.EthRopstenTestnet]: {
169
+ // name: "Ethereum Ropsten Testnet",
170
+ // id: ChainId.EthRopstenTestnet,
171
+ // baseCurrency: "ETH",
172
+ // defaultRpcUrl:
173
+ // "https://ropsten.infura.io/V4/84842078b09946638c03157f83405213",
174
+ // explorerUrl: "https://ropsten.etherscan.io",
175
+ // isTestnet: true,
176
+ // },
177
+ // [ChainId.EthRinkebyTestnet]: {
178
+ // name: "Ethereum Rinkeby Testnet",
179
+ // id: ChainId.EthRinkebyTestnet,
180
+ // baseCurrency: "ETH",
181
+ // defaultRpcUrl:
182
+ // "https://rinkeby.infura.io/V4/84842078b09946638c03157f83405213",
183
+ // explorerUrl: "https://rinkeby.etherscan.io",
184
+ // isTestnet: true,
185
+ // },
186
+ // [ChainId.EthKovanTestnet]: {
187
+ // name: "Ethereum Kovan Testnet",
188
+ // id: ChainId.EthKovanTestnet,
189
+ // baseCurrency: "ETH",
190
+ // defaultRpcUrl:
191
+ // "https://kovan.infura.io/V4/84842078b09946638c03157f83405213",
192
+ // explorerUrl: "https://kovan.etherscan.io",
193
+ // isTestnet: true,
194
+ // },
195
+ // [ChainId.BaseGoerliTestnet]: {
196
+ // name: "Base Goerli Testnet",
197
+ // id: ChainId.BaseGoerliTestnet,
198
+ // baseCurrency: "ETH",
199
+ // defaultRpcUrl: "https://rpc-goerli.baseprotocol.org",
200
+ // explorerUrl: "https://goerli.basescan.org",
201
+ // isTestnet: true,
202
+ // },
203
+ // [ChainId.GnosisChainTestnet]: {
204
+ // name: "Gnosis Chain Testnet",
205
+ // id: ChainId.GnosisChainTestnet,
206
+ // baseCurrency: "XDAI",
207
+ // defaultRpcUrl: "https://rpc.chiado.gnosis.gateway.fm",
208
+ // explorerUrl: "https://gnosis-chiado.blockscout.com/",
209
+ // isTestnet: true,
210
+ // },
211
+ // [ChainId.AvalancheMainnet]: {
212
+ // name: "Avalanche Mainnet",
213
+ // id: ChainId.AvalancheMainnet,
214
+ // baseCurrency: "AVAX",
215
+ // defaultRpcUrl: "https://api.avax.network/ext/bc/C/rpc",
216
+ // explorerUrl: "https://cchain.explorer.avax.network",
217
+ // isTestnet: false,
218
+ // },
219
+ // [ChainId.AvalancheFujiTestnet]: {
220
+ // name: "Avalanche Fuji Testnet",
221
+ // id: ChainId.AvalancheFujiTestnet,
222
+ // baseCurrency: "AVAX",
223
+ // defaultRpcUrl: "https://api.avax-test.network/ext/bc/C/rpc",
224
+ // explorerUrl: "https://cchain.explorer.avax-test.network",
225
+ // isTestnet: true,
226
+ // },
227
+ // [ChainId.MoonbaseAlphaTestnet]: {
228
+ // name: "Moonbase Alpha Testnet",
229
+ // id: ChainId.MoonbaseAlphaTestnet,
230
+ // baseCurrency: "DEV",
231
+ // defaultRpcUrl: "https://rpc.testnet.moonbeam.network",
232
+ // explorerUrl: "https://moonbase-blockscout.testnet.moonbeam.network",
233
+ // isTestnet: true,
234
+ // },
235
+ };