@morpho-org/blue-sdk 1.0.2 → 1.0.4

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 (159) hide show
  1. package/lib/addresses.d.ts +156 -0
  2. package/lib/addresses.js +160 -0
  3. package/lib/chain/chain.constants.d.ts +3 -0
  4. package/lib/chain/chain.constants.js +232 -0
  5. package/lib/chain/chain.test.d.ts +1 -0
  6. package/lib/chain/chain.test.js +37 -0
  7. package/lib/chain/chain.types.d.ts +20 -0
  8. package/lib/chain/chain.types.js +30 -0
  9. package/lib/chain/chain.utils.d.ts +14 -0
  10. package/lib/chain/chain.utils.js +30 -0
  11. package/lib/chain/index.js +18 -0
  12. package/lib/constants.d.ts +8 -0
  13. package/lib/constants.js +13 -0
  14. package/lib/errors.d.ts +37 -0
  15. package/lib/errors.js +71 -0
  16. package/lib/ethers/ethers.test.d.ts +1 -0
  17. package/lib/ethers/ethers.test.js +11 -0
  18. package/lib/ethers/index.js +18 -0
  19. package/lib/ethers/safeGetAddress.d.ts +1 -0
  20. package/lib/ethers/safeGetAddress.js +6 -0
  21. package/lib/ethers/safeParseUnits.d.ts +2 -0
  22. package/lib/ethers/safeParseUnits.js +25 -0
  23. package/lib/evm.d.ts +36 -0
  24. package/lib/evm.js +113 -0
  25. package/lib/helpers/format/format.d.ts +98 -0
  26. package/lib/helpers/format/format.js +301 -0
  27. package/lib/helpers/format/format.test.d.ts +1 -0
  28. package/lib/helpers/format/format.test.js +257 -0
  29. package/lib/helpers/format/index.js +17 -0
  30. package/lib/helpers/getChecksumedAddress.d.ts +7 -0
  31. package/lib/helpers/getChecksumedAddress.js +17 -0
  32. package/lib/helpers/index.js +20 -0
  33. package/{src/helpers/isZeroAddressOrUnset.ts → lib/helpers/isZeroAddressOrUnset.d.ts} +1 -7
  34. package/lib/helpers/isZeroAddressOrUnset.js +14 -0
  35. package/lib/helpers/locale.d.ts +36 -0
  36. package/lib/helpers/locale.js +86 -0
  37. package/lib/holding/Holding.d.ts +60 -0
  38. package/lib/holding/Holding.js +31 -0
  39. package/lib/holding/index.js +17 -0
  40. package/{src/index.ts → lib/index.d.ts} +0 -1
  41. package/lib/index.js +62 -0
  42. package/lib/market/Market.d.ts +159 -0
  43. package/lib/market/Market.js +240 -0
  44. package/lib/market/MarketConfig.d.ts +44 -0
  45. package/lib/market/MarketConfig.js +56 -0
  46. package/lib/market/MarketUtils.d.ts +165 -0
  47. package/lib/market/MarketUtils.js +182 -0
  48. package/lib/market/MarketUtils.test.d.ts +1 -0
  49. package/lib/market/MarketUtils.test.js +19 -0
  50. package/lib/market/index.js +19 -0
  51. package/lib/maths/AdaptiveCurveIrmLib.d.ts +37 -0
  52. package/lib/maths/AdaptiveCurveIrmLib.js +116 -0
  53. package/lib/maths/MathLib.d.ts +94 -0
  54. package/lib/maths/MathLib.js +153 -0
  55. package/lib/maths/MathUtils.d.ts +15 -0
  56. package/lib/maths/MathUtils.js +33 -0
  57. package/lib/maths/SharesMath.d.ts +12 -0
  58. package/lib/maths/SharesMath.js +22 -0
  59. package/lib/maths/index.js +20 -0
  60. package/lib/notifications.d.ts +98 -0
  61. package/lib/notifications.js +52 -0
  62. package/lib/position/Position.d.ts +118 -0
  63. package/lib/position/Position.js +145 -0
  64. package/lib/position/index.js +17 -0
  65. package/lib/signatures/index.d.ts +12 -0
  66. package/lib/signatures/index.js +39 -0
  67. package/lib/signatures/manager.d.ts +10 -0
  68. package/lib/signatures/manager.js +37 -0
  69. package/lib/signatures/permit.d.ts +21 -0
  70. package/lib/signatures/permit.js +101 -0
  71. package/lib/signatures/permit2.d.ts +20 -0
  72. package/lib/signatures/permit2.js +91 -0
  73. package/lib/signatures/types.d.ts +13 -0
  74. package/lib/signatures/types.js +2 -0
  75. package/lib/signatures/utils.d.ts +6 -0
  76. package/lib/signatures/utils.js +44 -0
  77. package/lib/tests/mocks/markets.d.ts +17 -0
  78. package/lib/tests/mocks/markets.js +108 -0
  79. package/lib/token/ERC20Metadata.d.ts +249 -0
  80. package/lib/token/ERC20Metadata.js +81 -0
  81. package/lib/token/Token.d.ts +45 -0
  82. package/lib/token/Token.js +39 -0
  83. package/lib/token/TokenNamespace.d.ts +18 -0
  84. package/lib/token/TokenNamespace.js +55 -0
  85. package/lib/token/WrappedToken.d.ts +42 -0
  86. package/lib/token/WrappedToken.js +87 -0
  87. package/lib/token/index.js +18 -0
  88. package/lib/types.d.ts +29 -0
  89. package/lib/types.js +23 -0
  90. package/lib/user/User.d.ts +20 -0
  91. package/lib/user/User.js +11 -0
  92. package/lib/user/index.js +18 -0
  93. package/lib/user/user.types.d.ts +18 -0
  94. package/lib/user/user.types.js +2 -0
  95. package/lib/vault/Vault.d.ts +167 -0
  96. package/lib/vault/Vault.js +156 -0
  97. package/lib/vault/VaultAllocation.d.ts +38 -0
  98. package/lib/vault/VaultAllocation.js +18 -0
  99. package/lib/vault/VaultConfig.d.ts +23 -0
  100. package/lib/vault/VaultConfig.js +26 -0
  101. package/lib/vault/VaultUtils.d.ts +17 -0
  102. package/lib/vault/VaultUtils.js +17 -0
  103. package/lib/vault/index.js +20 -0
  104. package/package.json +7 -11
  105. package/src/addresses.ts +0 -261
  106. package/src/chain/chain.constants.ts +0 -235
  107. package/src/chain/chain.test.ts +0 -51
  108. package/src/chain/chain.types.ts +0 -42
  109. package/src/chain/chain.utils.ts +0 -44
  110. package/src/constants.ts +0 -18
  111. package/src/errors.ts +0 -75
  112. package/src/ethers/ethers.test.ts +0 -17
  113. package/src/ethers/safeGetAddress.ts +0 -4
  114. package/src/ethers/safeParseUnits.ts +0 -29
  115. package/src/evm.ts +0 -172
  116. package/src/helpers/format/format.test.ts +0 -340
  117. package/src/helpers/format/format.ts +0 -416
  118. package/src/helpers/getChecksumedAddress.ts +0 -15
  119. package/src/helpers/locale.ts +0 -108
  120. package/src/holding/Holding.ts +0 -109
  121. package/src/market/Market.ts +0 -479
  122. package/src/market/MarketConfig.ts +0 -108
  123. package/src/market/MarketUtils.test.ts +0 -25
  124. package/src/market/MarketUtils.ts +0 -467
  125. package/src/maths/AdaptiveCurveIrmLib.ts +0 -143
  126. package/src/maths/MathLib.ts +0 -208
  127. package/src/maths/MathUtils.ts +0 -31
  128. package/src/maths/SharesMath.ts +0 -40
  129. package/src/notifications.ts +0 -167
  130. package/src/position/Position.ts +0 -251
  131. package/src/signatures/index.ts +0 -18
  132. package/src/signatures/manager.ts +0 -50
  133. package/src/signatures/permit.ts +0 -126
  134. package/src/signatures/permit2.ts +0 -120
  135. package/src/signatures/types.ts +0 -18
  136. package/src/signatures/utils.ts +0 -83
  137. package/src/tests/mocks/markets.ts +0 -110
  138. package/src/token/ERC20Metadata.ts +0 -124
  139. package/src/token/Token.ts +0 -83
  140. package/src/token/TokenNamespace.ts +0 -76
  141. package/src/token/WrappedToken.ts +0 -142
  142. package/src/types.ts +0 -37
  143. package/src/user/User.ts +0 -32
  144. package/src/user/user.types.ts +0 -23
  145. package/src/vault/Vault.ts +0 -370
  146. package/src/vault/VaultAllocation.ts +0 -58
  147. package/src/vault/VaultConfig.ts +0 -55
  148. package/src/vault/VaultUtils.ts +0 -47
  149. /package/{src/chain/index.ts → lib/chain/index.d.ts} +0 -0
  150. /package/{src/ethers/index.ts → lib/ethers/index.d.ts} +0 -0
  151. /package/{src/helpers/format/index.ts → lib/helpers/format/index.d.ts} +0 -0
  152. /package/{src/helpers/index.ts → lib/helpers/index.d.ts} +0 -0
  153. /package/{src/holding/index.ts → lib/holding/index.d.ts} +0 -0
  154. /package/{src/market/index.ts → lib/market/index.d.ts} +0 -0
  155. /package/{src/maths/index.ts → lib/maths/index.d.ts} +0 -0
  156. /package/{src/position/index.ts → lib/position/index.d.ts} +0 -0
  157. /package/{src/token/index.ts → lib/token/index.d.ts} +0 -0
  158. /package/{src/user/index.ts → lib/user/index.d.ts} +0 -0
  159. /package/{src/vault/index.ts → lib/vault/index.d.ts} +0 -0
@@ -0,0 +1,23 @@
1
+ import { ChainId } from "../chain";
2
+ import { Address } from "../types";
3
+ interface InputVaultConfig {
4
+ address: Address;
5
+ decimals: number;
6
+ decimalsOffset: bigint;
7
+ symbol: string;
8
+ name: string;
9
+ asset: Address;
10
+ }
11
+ export declare class VaultConfig implements InputVaultConfig {
12
+ readonly chainId?: number | undefined;
13
+ protected static readonly _CACHE: Record<number, Record<Address, VaultConfig>>;
14
+ static get(address: Address, chainId: ChainId): VaultConfig;
15
+ readonly address: Address;
16
+ readonly decimals: number;
17
+ readonly decimalsOffset: bigint;
18
+ readonly symbol: string;
19
+ readonly name: string;
20
+ readonly asset: Address;
21
+ constructor({ address, decimals, decimalsOffset, symbol, name, asset, }: InputVaultConfig, chainId?: number | undefined);
22
+ }
23
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultConfig = void 0;
4
+ const errors_1 = require("../errors");
5
+ class VaultConfig {
6
+ static get(address, chainId) {
7
+ const config = VaultConfig._CACHE[chainId]?.[address];
8
+ if (!config)
9
+ throw new errors_1.UnknownVaultConfigError(address);
10
+ return config;
11
+ }
12
+ constructor({ address, decimals, decimalsOffset, symbol, name, asset, }, chainId) {
13
+ var _a;
14
+ this.chainId = chainId;
15
+ this.address = address;
16
+ this.decimals = decimals;
17
+ this.decimalsOffset = decimalsOffset;
18
+ this.symbol = symbol;
19
+ this.name = name;
20
+ this.asset = asset;
21
+ if (chainId != null)
22
+ ((_a = VaultConfig._CACHE)[chainId] ?? (_a[chainId] = {}))[address] = this;
23
+ }
24
+ }
25
+ exports.VaultConfig = VaultConfig;
26
+ VaultConfig._CACHE = {};
@@ -0,0 +1,17 @@
1
+ import { BigNumberish } from "ethers";
2
+ import { RoundingDirection } from "../maths";
3
+ export declare namespace VaultUtils {
4
+ const VIRTUAL_ASSETS = 1n;
5
+ function toAssets(shares: BigNumberish, { totalAssets, totalSupply, }: {
6
+ totalAssets: BigNumberish;
7
+ totalSupply: BigNumberish;
8
+ }, { decimalsOffset }: {
9
+ decimalsOffset: BigNumberish;
10
+ }, rounding?: RoundingDirection): bigint;
11
+ function toShares(assets: BigNumberish, { totalAssets, totalSupply, }: {
12
+ totalAssets: BigNumberish;
13
+ totalSupply: BigNumberish;
14
+ }, { decimalsOffset }: {
15
+ decimalsOffset: BigNumberish;
16
+ }, rounding?: RoundingDirection): bigint;
17
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultUtils = void 0;
4
+ const ethers_1 = require("ethers");
5
+ const maths_1 = require("../maths");
6
+ var VaultUtils;
7
+ (function (VaultUtils) {
8
+ VaultUtils.VIRTUAL_ASSETS = 1n;
9
+ function toAssets(shares, { totalAssets, totalSupply, }, { decimalsOffset }, rounding = "Down") {
10
+ return maths_1.MathLib.mulDiv(shares, (0, ethers_1.toBigInt)(totalAssets) + VaultUtils.VIRTUAL_ASSETS, (0, ethers_1.toBigInt)(totalSupply) + 10n ** (0, ethers_1.toBigInt)(decimalsOffset), rounding);
11
+ }
12
+ VaultUtils.toAssets = toAssets;
13
+ function toShares(assets, { totalAssets, totalSupply, }, { decimalsOffset }, rounding = "Up") {
14
+ return maths_1.MathLib.mulDiv(assets, (0, ethers_1.toBigInt)(totalSupply) + 10n ** (0, ethers_1.toBigInt)(decimalsOffset), (0, ethers_1.toBigInt)(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
15
+ }
16
+ VaultUtils.toShares = toShares;
17
+ })(VaultUtils || (exports.VaultUtils = VaultUtils = {}));
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./VaultUtils"), exports);
18
+ __exportStar(require("./VaultConfig"), exports);
19
+ __exportStar(require("./VaultAllocation"), exports);
20
+ __exportStar(require("./Vault"), exports);
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@morpho-org/blue-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "author": "Morpho Association <contact@morpho.org>",
5
5
  "license": "MIT",
6
- "main": "src/index.ts",
6
+ "main": "lib/index.js",
7
7
  "files": [
8
- "src"
8
+ "lib"
9
9
  ],
10
10
  "scripts": {
11
11
  "prepublish": "yarn build",
@@ -15,25 +15,21 @@
15
15
  "test:blue-sdk": "yarn test"
16
16
  },
17
17
  "dependencies": {
18
- "@morpho-org/morpho-ts": "1.0.2",
18
+ "@morpho-org/morpho-ts": "1.0.4",
19
19
  "ethers": "^6.12.1",
20
20
  "ethers-multicall-provider": "^6.3.0",
21
21
  "ethers-types": "^3.15.1",
22
22
  "rxjs": "^7.8.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@morpho-org/morpho-test": "1.0.2",
25
+ "@morpho-org/morpho-test": "1.0.4",
26
26
  "@types/jest": "^29.5.12",
27
27
  "jest": "^29.6.2",
28
28
  "ts-jest": "^29.1.1",
29
29
  "typescript": "^5.4.5"
30
30
  },
31
31
  "publishConfig": {
32
- "access": "public",
33
- "main": "lib/index.js",
34
- "files": [
35
- "lib"
36
- ]
32
+ "access": "public"
37
33
  },
38
34
  "jest": {
39
35
  "verbose": true,
@@ -54,5 +50,5 @@
54
50
  ],
55
51
  "preset": "ts-jest"
56
52
  },
57
- "gitHead": "d8e67d7bf53582572306f0c11761163208129ff1"
53
+ "gitHead": "e3de20633be74fc506bd0a3a8d0115bcc0744d70"
58
54
  }
package/src/addresses.ts DELETED
@@ -1,261 +0,0 @@
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
- };
@@ -1,235 +0,0 @@
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
- };