@morpho-org/blue-sdk 3.0.6 → 4.0.0-next.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/README.md +74 -0
- package/lib/addresses.d.ts +322 -10
- package/lib/addresses.js +111 -43
- package/lib/token/WrappedToken.js +2 -2
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -124,3 +124,77 @@ const accruedPosition = position.accrueInterest(Time.timestamp()); // Accrue int
|
|
|
124
124
|
|
|
125
125
|
position.borrowAssets; // e.g. 20_400000000000000000n (in loan assets).
|
|
126
126
|
```
|
|
127
|
+
|
|
128
|
+
### Addresses customization
|
|
129
|
+
#### `registerCustomAddresses`
|
|
130
|
+
|
|
131
|
+
Extends the default address registry and unwrapped token mapping for known or custom chains. Useful for testing or adding support for new networks.
|
|
132
|
+
|
|
133
|
+
> [!Note]
|
|
134
|
+
> - Custom addresses should be registered statically, at the root level.
|
|
135
|
+
> - Custom addresses can't be removed nor changed.
|
|
136
|
+
|
|
137
|
+
##### ✅ Use Cases
|
|
138
|
+
|
|
139
|
+
- Injecting additional or missing contract addresses on known chains.
|
|
140
|
+
- Providing a full set of addresses for an unknown (custom) chain.
|
|
141
|
+
- Registering mappings of wrapped → unwrapped tokens per chain (e.g., WETH → ETH).
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
##### **Function Signature**
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
registerCustomAddresses(options?: {
|
|
149
|
+
addresses?: Record<number, ChainAddresses>; // Can be a subset of ChainAddresses if chain is known
|
|
150
|
+
unwrappedTokens?: Record<number, Record<Address, Address>>;
|
|
151
|
+
}): void
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
##### **Parameters**
|
|
157
|
+
|
|
158
|
+
- `addresses` *(optional)*
|
|
159
|
+
A map of `chainId → ChainAddresses`.
|
|
160
|
+
- For **known chains**, partial overrides are allowed (e.g., add a missing adapter).
|
|
161
|
+
- For **unknown chains**, a complete `ChainAddresses` object with required addresses must be provided.
|
|
162
|
+
- Throws an error if you attempt to override an existing address.
|
|
163
|
+
|
|
164
|
+
- `unwrappedTokens` *(optional)*
|
|
165
|
+
A map of `chainId → { wrapped → unwrapped }`.
|
|
166
|
+
- Throws an error if you attempt to override an existing mapping.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
##### **Behavior**
|
|
171
|
+
|
|
172
|
+
- Merges user-provided addresses and unwrapped tokens into the internal registries.
|
|
173
|
+
- Uses a deep merge with custom logic to **prevent overwriting existing values**.
|
|
174
|
+
- Updates internal constants: `addressesRegistry`, `addresses`, and `unwrappedTokensMapping`.
|
|
175
|
+
- Applies `Object.freeze()` to ensure immutability.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
##### **Example**
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
registerCustomAddresses({
|
|
183
|
+
addresses: {
|
|
184
|
+
8453: { stEth: "0xabc..." }, // provide stEth address on base
|
|
185
|
+
31337: {
|
|
186
|
+
morpho: "0x123...",
|
|
187
|
+
bundler3: {
|
|
188
|
+
bundler3: "0x456...",
|
|
189
|
+
...
|
|
190
|
+
},
|
|
191
|
+
...
|
|
192
|
+
}, // registers a new local test chain
|
|
193
|
+
},
|
|
194
|
+
unwrappedTokens: {
|
|
195
|
+
31337: {
|
|
196
|
+
"0xWrapped": "0xUnwrapped" // e.g., WETH → ETH
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
```
|
package/lib/addresses.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DottedKeys } from "@morpho-org/morpho-ts";
|
|
1
|
+
import { type DeepPartial, type DottedKeys } from "@morpho-org/morpho-ts";
|
|
2
2
|
import { ChainId } from "./chain.js";
|
|
3
3
|
import type { Address } from "./types.js";
|
|
4
4
|
/** Address used to replicate an erc20-behaviour for native token.
|
|
@@ -49,7 +49,7 @@ export interface ChainAddresses {
|
|
|
49
49
|
stEth?: Address;
|
|
50
50
|
wstEth?: Address;
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
declare const _addressesRegistry: {
|
|
53
53
|
readonly 1: {
|
|
54
54
|
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
55
55
|
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
@@ -335,15 +335,9 @@ export declare const addressesRegistry: {
|
|
|
335
335
|
readonly wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b";
|
|
336
336
|
};
|
|
337
337
|
};
|
|
338
|
-
export
|
|
339
|
-
export type AddressLabel = DottedKeys<(typeof addressesRegistry)[ChainId]>;
|
|
338
|
+
export type AddressLabel = DottedKeys<(typeof _addressesRegistry)[ChainId]>;
|
|
340
339
|
export declare const getChainAddresses: (chainId: number) => ChainAddresses;
|
|
341
|
-
|
|
342
|
-
* Assumptions:
|
|
343
|
-
* - unwrapped token has same number of decimals than wrapped tokens.
|
|
344
|
-
*/
|
|
345
|
-
export declare const unwrappedTokensMapping: Record<ChainId, Record<Address, Address>>;
|
|
346
|
-
export declare function getUnwrappedToken(wrappedToken: Address, chainId: ChainId): `0x${string}` | undefined;
|
|
340
|
+
export declare function getUnwrappedToken(wrappedToken: Address, chainId: number): `0x${string}` | undefined;
|
|
347
341
|
/**
|
|
348
342
|
* The registry of all known ERC20Wrapper tokens.
|
|
349
343
|
*/
|
|
@@ -368,3 +362,321 @@ export declare const getPermissionedCoinbaseTokens: (chainId: number) => Set<`0x
|
|
|
368
362
|
* - calling `depositFor` supplies on blue instead of minting wrapped token to the user
|
|
369
363
|
*/
|
|
370
364
|
export declare const convexWrapperTokens: Record<number, Set<Address>>;
|
|
365
|
+
export declare let addressesRegistry: {
|
|
366
|
+
readonly 1: {
|
|
367
|
+
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
368
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
369
|
+
/**
|
|
370
|
+
* @deprecated All bundles should use Bundler3 instead.
|
|
371
|
+
*/
|
|
372
|
+
readonly bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077";
|
|
373
|
+
readonly bundler3: {
|
|
374
|
+
readonly bundler3: "0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245";
|
|
375
|
+
readonly generalAdapter1: "0x4A6c312ec70E8747a587EE860a0353cd42Be0aE0";
|
|
376
|
+
readonly paraswapAdapter: "0x03b5259Bd204BfD4A616E5B79b0B786d90c6C38f";
|
|
377
|
+
readonly erc20WrapperAdapter: "0xf83D17dFE160597b19e4FdD8ea61A23e9a87F962";
|
|
378
|
+
readonly compoundV2MigrationAdapter: "0x9B89c07f480Df1945279031b5fC6fF241b8f1101";
|
|
379
|
+
readonly compoundV3MigrationAdapter: "0xdBa5bdE29eA030Bfa6A608592dFcA1D02CB26773";
|
|
380
|
+
readonly aaveV2MigrationAdapter: "0x40288815C399709dFC0875A384B637fFe387961B";
|
|
381
|
+
readonly aaveV3CoreMigrationAdapter: "0xb09e40EbE31b738fbf20289270a397118707D475";
|
|
382
|
+
readonly aaveV3PrimeMigrationAdapter: "0x2CC8d502a65824B4cF9A58DB03490bA024BDB806";
|
|
383
|
+
readonly aaveV3EtherFiMigrationAdapter: "0x4011dc6581fA05F9B0c7A12AdCd676e2b1a59ca3";
|
|
384
|
+
readonly aaveV3OptimizerMigrationAdapter: "0x9e2ea2d5785598a163D569D795f286F5C55ad972";
|
|
385
|
+
};
|
|
386
|
+
readonly aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c";
|
|
387
|
+
readonly aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76";
|
|
388
|
+
readonly aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC";
|
|
389
|
+
readonly compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558";
|
|
390
|
+
readonly compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647";
|
|
391
|
+
readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
|
|
392
|
+
readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
|
|
393
|
+
readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
|
|
394
|
+
readonly chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766";
|
|
395
|
+
readonly preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476";
|
|
396
|
+
readonly wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
397
|
+
readonly morphoToken: "0x9994E35Db50125E0DF82e4c2dde62496CE330999";
|
|
398
|
+
readonly dai: "0x6B175474E89094C44Da98b954EedeAC495271d0F";
|
|
399
|
+
readonly sDai: "0x83F20F44975D03b1b09e64809B757c47f942BEeA";
|
|
400
|
+
readonly mkr: "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2";
|
|
401
|
+
readonly stEth: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
|
|
402
|
+
readonly wstEth: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0";
|
|
403
|
+
readonly osEth: "0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38";
|
|
404
|
+
readonly bIB01: "0xCA30c93B02514f86d5C86a6e375E3A330B435Fb5";
|
|
405
|
+
readonly wbIB01: "0xcA2A7068e551d5C4482eb34880b194E4b945712F";
|
|
406
|
+
readonly bC3M: "0x2F123cF3F37CE3328CC9B5b8415f9EC5109b45e7";
|
|
407
|
+
readonly wbC3M: "0x95D7337d43340E2721960Dc402D9b9117f0d81a2";
|
|
408
|
+
readonly usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
409
|
+
readonly usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7";
|
|
410
|
+
readonly crvUsd: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E";
|
|
411
|
+
readonly "stkcvxcrvUSDTWBTCWETH-morpho": "0xb0Ce26C88e4e7DCa51968b6047f44646f5064278";
|
|
412
|
+
readonly crvUSDTWBTCWETH: "0xf5f5B97624542D72A9E06f04804Bf81baA15e2B4";
|
|
413
|
+
readonly "stkcvxcrvUSDCWBTCWETH-morpho": "0x0ea1a65A2c255f24Ee8D81eA6AaC54Decd9d269e";
|
|
414
|
+
readonly crvUSDCWBTCWETH: "0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B";
|
|
415
|
+
readonly "stkcvxcrvCRVUSDTBTCWSTETH-morpho": "0x3ce8Ec9f3d89aD0A2DdbCC3FDB8991BD241Fc82E";
|
|
416
|
+
readonly crvCRVUSDTBTCWSTETH: "0x2889302a794dA87fBF1D6Db415C1492194663D13";
|
|
417
|
+
readonly "stkcvxTryLSD-morpho": "0x6BA072F0d22806F2C52e9792AF47f2D59103BEBE";
|
|
418
|
+
readonly tryLSD: "0x2570f1bD5D2735314FC102eb12Fc1aFe9e6E7193";
|
|
419
|
+
readonly "stkcvxcrvUSDETHCRV-morpho": "0xAc904BAfBb5FB04Deb2b6198FdCEedE75a78Ce5a";
|
|
420
|
+
readonly crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14";
|
|
421
|
+
readonly "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e";
|
|
422
|
+
readonly "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726";
|
|
423
|
+
};
|
|
424
|
+
readonly 8453: {
|
|
425
|
+
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
426
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
427
|
+
/**
|
|
428
|
+
* @deprecated All bundles should use Bundler3 instead.
|
|
429
|
+
*/
|
|
430
|
+
readonly bundler: "0x23055618898e202386e6c13955a58D3C68200BFB";
|
|
431
|
+
readonly bundler3: {
|
|
432
|
+
readonly bundler3: "0x6BFd8137e702540E7A42B74178A4a49Ba43920C4";
|
|
433
|
+
readonly generalAdapter1: "0xb98c948CFA24072e58935BC004a8A7b376AE746A";
|
|
434
|
+
readonly paraswapAdapter: "0x6abE8ABd0275E5564ed1336F0243A52C32562F71";
|
|
435
|
+
readonly erc20WrapperAdapter: "0xdeEf55F0A7366cC3Baf5E04313269389Fe17E9AE";
|
|
436
|
+
readonly compoundV3MigrationAdapter: "0x85D4812Ef92c040d4270eD8547b6835e41FbbB70";
|
|
437
|
+
readonly aaveV3CoreMigrationAdapter: "0xb27Aa2a964eAd5ed661D86974b37e4fB995b36f5";
|
|
438
|
+
};
|
|
439
|
+
readonly compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223";
|
|
440
|
+
readonly aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108";
|
|
441
|
+
readonly compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA";
|
|
442
|
+
readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
|
|
443
|
+
readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
|
|
444
|
+
readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
|
|
445
|
+
readonly chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d";
|
|
446
|
+
readonly preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef";
|
|
447
|
+
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
448
|
+
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
449
|
+
readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
|
|
450
|
+
readonly testUsdc: "0xBC77067f829979812d795d516E523C4033b66409";
|
|
451
|
+
};
|
|
452
|
+
readonly 137: {
|
|
453
|
+
readonly morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67";
|
|
454
|
+
readonly bundler3: {
|
|
455
|
+
readonly bundler3: "0x2d9C3A9E67c966C711208cc78b34fB9E9f8db589";
|
|
456
|
+
readonly generalAdapter1: "0xB261B51938A9767406ef83bbFbaAFE16691b7047";
|
|
457
|
+
readonly paraswapAdapter: "0x5F2617F12D1fDd1e43e72Cb80C92dFcE8124Db8d";
|
|
458
|
+
readonly compoundV3MigrationAdapter: "0xB34D2f54139bA12defC315C0822aDf9A5eB9A9b7";
|
|
459
|
+
readonly aaveV2MigrationAdapter: "0x43980Ae597f12Ff64690506b2AEEFFb4D8BeAF2a";
|
|
460
|
+
readonly aaveV3CoreMigrationAdapter: "0xEcB1662a1dff5C20650CF98c3334d2fddcD50742";
|
|
461
|
+
};
|
|
462
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
463
|
+
readonly adaptiveCurveIrm: "0xe675A2161D4a6E2de2eeD70ac98EEBf257FBF0B0";
|
|
464
|
+
readonly publicAllocator: "0xfac15aff53ADd2ff80C2962127C434E8615Df0d3";
|
|
465
|
+
readonly metaMorphoFactory: "0xa9c87daB340631C34BB738625C70499e29ddDC98";
|
|
466
|
+
readonly chainlinkOracleFactory: "0x1ff7895Eb842794c5d07C4c547b6730e61295215";
|
|
467
|
+
readonly preLiquidationFactory: "0xeDadDe37D76c72b98725614d0b41C20Fe612d304";
|
|
468
|
+
readonly wNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270";
|
|
469
|
+
};
|
|
470
|
+
readonly 42161: {
|
|
471
|
+
readonly morpho: "0x6c247b1F6182318877311737BaC0844bAa518F5e";
|
|
472
|
+
readonly bundler3: {
|
|
473
|
+
readonly bundler3: "0x1FA4431bC113D308beE1d46B0e98Cb805FB48C13";
|
|
474
|
+
readonly generalAdapter1: "0x9954aFB60BB5A222714c478ac86990F221788B88";
|
|
475
|
+
readonly paraswapAdapter: "0xAA5c30C1482c189cA0d56057D3ac4dD7Af1e4726";
|
|
476
|
+
};
|
|
477
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
478
|
+
readonly adaptiveCurveIrm: "0x66F30587FB8D4206918deb78ecA7d5eBbafD06DA";
|
|
479
|
+
readonly publicAllocator: "0x769583Af5e9D03589F159EbEC31Cc2c23E8C355E";
|
|
480
|
+
readonly metaMorphoFactory: "0x878988f5f561081deEa117717052164ea1Ef0c82";
|
|
481
|
+
readonly chainlinkOracleFactory: "0x98Ce5D183DC0c176f54D37162F87e7eD7f2E41b5";
|
|
482
|
+
readonly preLiquidationFactory: "0x635c31B5DF1F7EFbCbC07E302335Ef4230758e3d";
|
|
483
|
+
readonly wNative: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
|
484
|
+
readonly usdc: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
485
|
+
};
|
|
486
|
+
readonly 10: {
|
|
487
|
+
readonly morpho: "0xce95AfbB8EA029495c66020883F87aaE8864AF92";
|
|
488
|
+
readonly bundler3: {
|
|
489
|
+
readonly bundler3: "0xFBCd3C258feB131D8E038F2A3a670A7bE0507C05";
|
|
490
|
+
readonly generalAdapter1: "0x79481C87f24A3C4332442A2E9faaf675e5F141f0";
|
|
491
|
+
readonly paraswapAdapter: "0x31F539f4Ed14fA1fd18781e93f6739249692aDC5";
|
|
492
|
+
};
|
|
493
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
494
|
+
readonly adaptiveCurveIrm: "0x8cD70A8F399428456b29546BC5dBe10ab6a06ef6";
|
|
495
|
+
readonly publicAllocator: "0x0d68a97324E602E02799CD83B42D337207B40658";
|
|
496
|
+
readonly metaMorphoFactory: "0x3Bb6A6A0Bc85b367EFE0A5bAc81c5E52C892839a";
|
|
497
|
+
readonly chainlinkOracleFactory: "0x1ec408D4131686f727F3Fd6245CF85Bc5c9DAD70";
|
|
498
|
+
readonly preLiquidationFactory: "0x3d05C01EE8e97361b9E19D172128255eaE5F98B9";
|
|
499
|
+
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
500
|
+
readonly usdc: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85";
|
|
501
|
+
};
|
|
502
|
+
readonly 480: {
|
|
503
|
+
readonly morpho: "0xE741BC7c34758b4caE05062794E8Ae24978AF432";
|
|
504
|
+
readonly bundler3: {
|
|
505
|
+
readonly bundler3: "0x3D07BF2FFb23248034bF704F3a4786F1ffE2a448";
|
|
506
|
+
readonly generalAdapter1: "0x30fa9A3cF56931ACEea42E28D35519a97D90aA67";
|
|
507
|
+
};
|
|
508
|
+
readonly adaptiveCurveIrm: "0x34E99D604751a72cF8d0CFDf87069292d82De472";
|
|
509
|
+
readonly publicAllocator: "0xef9889B4e443DEd35FA0Bd060f2104Cca94e6A43";
|
|
510
|
+
readonly metaMorphoFactory: "0x4DBB3a642a2146d5413750Cca3647086D9ba5F12";
|
|
511
|
+
readonly chainlinkOracleFactory: "0xd706690BA1Fe26b70c4AD89e60ff62cEB3A2eD02";
|
|
512
|
+
readonly preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695";
|
|
513
|
+
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
514
|
+
};
|
|
515
|
+
readonly 252: {
|
|
516
|
+
readonly morpho: "0xa6030627d724bA78a59aCf43Be7550b4C5a0653b";
|
|
517
|
+
readonly bundler3: {
|
|
518
|
+
readonly bundler3: "0xA7a414823Ef0F8CFb2c4f67f2F445DA940641d91";
|
|
519
|
+
readonly generalAdapter1: "0x228dDF333DDf6D1895dA1dE8a846EDD27F1284eD";
|
|
520
|
+
};
|
|
521
|
+
readonly adaptiveCurveIrm: "0xA0D4D77b5D9933073572E19C172BFE866312673b";
|
|
522
|
+
readonly publicAllocator: "0x37a888192165fC39884f87c64E2476BfD2C09675";
|
|
523
|
+
readonly metaMorphoFactory: "0x27D4Af0AC9E7FDfA6D0853236f249CC27AE79488";
|
|
524
|
+
readonly chainlinkOracleFactory: "0x39d8622C607A691D7705E8842fbB12E3c38dCD41";
|
|
525
|
+
readonly preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695";
|
|
526
|
+
readonly wNative: "0xfc00000000000000000000000000000000000006";
|
|
527
|
+
};
|
|
528
|
+
readonly 534352: {
|
|
529
|
+
readonly morpho: "0x2d012EdbAdc37eDc2BC62791B666f9193FDF5a55";
|
|
530
|
+
readonly bundler3: {
|
|
531
|
+
readonly bundler3: "0x60F9159d4dCd724e743212416FD57d8aC0B60768";
|
|
532
|
+
readonly generalAdapter1: "0xD2780fae0869cDc06EE202152304A39653361525";
|
|
533
|
+
};
|
|
534
|
+
readonly adaptiveCurveIrm: "0xa5EA7500A27C0079961D93366A6e93aafF18CB90";
|
|
535
|
+
readonly publicAllocator: "0x8a7f671E45E51dE245649Cf916cA0256FB8a9927";
|
|
536
|
+
readonly metaMorphoFactory: "0x56b65742ade55015e6480959808229Ad6dbc9295";
|
|
537
|
+
readonly chainlinkOracleFactory: "0xb5961902E60b188b1c665B7b72Ef616656A9e24E";
|
|
538
|
+
readonly preLiquidationFactory: "0xeD960178e4aDA0296786Fa79D84e8FDF7bd44B25";
|
|
539
|
+
readonly wNative: "0x5300000000000000000000000000000000000004";
|
|
540
|
+
readonly usdc: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4";
|
|
541
|
+
};
|
|
542
|
+
readonly 57073: {
|
|
543
|
+
readonly morpho: "0x857f3EefE8cbda3Bc49367C996cd664A880d3042";
|
|
544
|
+
readonly bundler3: {
|
|
545
|
+
readonly bundler3: "0x7db0F1E2bf1f47ec82220090F388d75D8B9BB6BC";
|
|
546
|
+
readonly generalAdapter1: "0xB8B2aDdCDe1cdC94AaE18a0F8A19df03D8683610";
|
|
547
|
+
};
|
|
548
|
+
readonly adaptiveCurveIrm: "0x9515407b1512F53388ffE699524100e7270Ee57B";
|
|
549
|
+
readonly publicAllocator: "0x85416891752a6B81106c1C2999AE1AF5d8Cd3357";
|
|
550
|
+
readonly metaMorphoFactory: "0xd3f39505d0c48AFED3549D625982FdC38Ea9904b";
|
|
551
|
+
readonly chainlinkOracleFactory: "0x3FFFE273ee348b9E1ef89533025C7f165B17B439";
|
|
552
|
+
readonly preLiquidationFactory: "0x30607fEa77168d2c0401B6f60F0B40E32F9339E3";
|
|
553
|
+
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
554
|
+
readonly usdc: "0xF1815bd50389c46847f0Bda824eC8da914045D14";
|
|
555
|
+
};
|
|
556
|
+
readonly 130: {
|
|
557
|
+
readonly morpho: "0x8f5ae9CddB9f68de460C77730b018Ae7E04a140A";
|
|
558
|
+
readonly bundler3: {
|
|
559
|
+
readonly bundler3: "0x7DD85759182495AF7F6757DA75036d24A9B58bc3";
|
|
560
|
+
readonly generalAdapter1: "0xC11329d19C2275c9E759867e879ECFcEeD7e30A0";
|
|
561
|
+
};
|
|
562
|
+
readonly adaptiveCurveIrm: "0x9a6061d51743B31D2c3Be75D83781Fa423f53F0E";
|
|
563
|
+
readonly publicAllocator: "0xB0c9a107fA17c779B3378210A7a593e88938C7C9";
|
|
564
|
+
readonly metaMorphoFactory: "0xe9EdE3929F43a7062a007C3e8652e4ACa610Bdc0";
|
|
565
|
+
readonly chainlinkOracleFactory: "0x43269546e1D586a1f7200a0AC07e26f9631f7539";
|
|
566
|
+
readonly preLiquidationFactory: "0xb04e4D3D59Ee47Ca9BA192707AF13A7D02969911";
|
|
567
|
+
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
568
|
+
readonly usdc: "0x078D782b760474a361dDA0AF3839290b0EF57AD6";
|
|
569
|
+
};
|
|
570
|
+
readonly 146: {
|
|
571
|
+
readonly morpho: "0xd6c916eB7542D0Ad3f18AEd0FCBD50C582cfa95f";
|
|
572
|
+
readonly bundler3: {
|
|
573
|
+
readonly bundler3: "0xB06F1Ad8c908b958E596c42973f67F2f1d9a9afF";
|
|
574
|
+
readonly generalAdapter1: "0x31D5aee8D75EEab548cfA0d11C4f9843a5201eaf";
|
|
575
|
+
};
|
|
576
|
+
readonly adaptiveCurveIrm: "0xDEfCf242226425f93d8DD0e314735C28517C473F";
|
|
577
|
+
readonly publicAllocator: "0x6Cef2EDC70D87E8f1623f3096efF05d066E59B36";
|
|
578
|
+
readonly metaMorphoFactory: "0x0cE9e3512CB4df8ae7e265e62Fb9258dc14f12e8";
|
|
579
|
+
readonly chainlinkOracleFactory: "0x7DA59Fa482F1F49fADc486d8e47BADc506fEb86d";
|
|
580
|
+
readonly preLiquidationFactory: "0xc72129DA4CC808e955699111b8c22B22Ca8A10b8";
|
|
581
|
+
readonly wNative: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38";
|
|
582
|
+
};
|
|
583
|
+
readonly 43111: {
|
|
584
|
+
readonly morpho: "0xa4Ca2c2e25b97DA19879201bA49422bc6f181f42";
|
|
585
|
+
readonly bundler3: {
|
|
586
|
+
readonly bundler3: "0x8eDa6E01a20E3Cd90B3B2AF6F790cB8FADEf3Ea8";
|
|
587
|
+
readonly generalAdapter1: "0x9623090C3943ad63F7d794378273610Dd0deeFD4";
|
|
588
|
+
};
|
|
589
|
+
readonly adaptiveCurveIrm: "0xdEbdEa31624552DF904A065221cD14088ABDeD70";
|
|
590
|
+
readonly publicAllocator: "0x4107Ea1746909028d6212B315dE5fE9538F9eb39";
|
|
591
|
+
readonly metaMorphoFactory: "0x8e52179BeB18E882040b01632440d8Ca0f01da82";
|
|
592
|
+
readonly chainlinkOracleFactory: "0xB3cb32E6185446a6Bc7A047E4FfA138fA939e133";
|
|
593
|
+
readonly preLiquidationFactory: "0x40F2896C551194e364F7C846046C34d8a9FE97e4";
|
|
594
|
+
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
595
|
+
readonly usdc: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA";
|
|
596
|
+
};
|
|
597
|
+
readonly 34443: {
|
|
598
|
+
readonly morpho: "0xd85cE6BD68487E0AaFb0858FDE1Cd18c76840564";
|
|
599
|
+
readonly bundler3: {
|
|
600
|
+
readonly bundler3: "0xFEA0edFa081C8D5960Ec9Bf6684981dB1834305d";
|
|
601
|
+
readonly generalAdapter1: "0xF53925b95Cc409447066cd5c1A7756084b2Ee0a4";
|
|
602
|
+
};
|
|
603
|
+
readonly adaptiveCurveIrm: "0xE3d46Ae190Cb39ccA3655E966DcEF96b4eAe1d1c";
|
|
604
|
+
readonly publicAllocator: "0xEE868Bf3359DA30c10ea472EAEBFC0a06E8F0120";
|
|
605
|
+
readonly metaMorphoFactory: "0xae5b0884bfff430493D6C844B9fd052Af7d79278";
|
|
606
|
+
readonly chainlinkOracleFactory: "0xf9380f7898423Bd7FDe3C9fDD1b2671A2471f39D";
|
|
607
|
+
readonly preLiquidationFactory: "0x249E4808264c545861e43728186a731dE7c7D745";
|
|
608
|
+
readonly wNative: "0x4200000000000000000000000000000000000006";
|
|
609
|
+
};
|
|
610
|
+
readonly 21000000: {
|
|
611
|
+
readonly morpho: "0xc2B1E031540e3F3271C5F3819F0cC7479a8DdD90";
|
|
612
|
+
readonly bundler3: {
|
|
613
|
+
readonly bundler3: "0x086889F9bdE8349512dD77088A7114E6C1c42Af7";
|
|
614
|
+
readonly generalAdapter1: "0x464a402244bCDdc0c2091D5193E8ffdb2be54Ca9";
|
|
615
|
+
};
|
|
616
|
+
readonly adaptiveCurveIrm: "0x58a42117d753a0e69694545DfA19d64c2fB759fB";
|
|
617
|
+
readonly publicAllocator: "0xDFde06e2B2A2D718eE5560b73dA4F830E56A2f10";
|
|
618
|
+
readonly metaMorphoFactory: "0xe430821595602eA5DD0cD350f86987437c7362fA";
|
|
619
|
+
readonly chainlinkOracleFactory: "0x16278156D366fC91536b6b81482ffaC47EEa06D6";
|
|
620
|
+
readonly preLiquidationFactory: "0xb9065AC18d3EBdb3263B77B587f9c5CD570545D1";
|
|
621
|
+
readonly wNative: "0xda5dDd7270381A7C2717aD10D1c0ecB19e3CDFb2";
|
|
622
|
+
readonly usdc: "0xDF0B24095e15044538866576754F3C964e902Ee6";
|
|
623
|
+
};
|
|
624
|
+
readonly 98866: {
|
|
625
|
+
readonly morpho: "0x42b18785CE0Aed7BF7Ca43a39471ED4C0A3e0bB5";
|
|
626
|
+
readonly bundler3: {
|
|
627
|
+
readonly bundler3: "0x5437C8788f4CFbaA55be6FBf30379bc7dd7f69C3";
|
|
628
|
+
readonly generalAdapter1: "0x65ff368930Cb7eB4CA5C5eBC58bb69E6Ed198BA5";
|
|
629
|
+
};
|
|
630
|
+
readonly adaptiveCurveIrm: "0x7420302Ddd469031Cd2282cd64225cCd46F581eA";
|
|
631
|
+
readonly publicAllocator: "0x58485338D93F4e3b4Bf2Af1C9f9C0aDF087AEf1C";
|
|
632
|
+
readonly metaMorphoFactory: "0x2525D453D9BA13921D5aB5D8c12F9202b0e19456";
|
|
633
|
+
readonly chainlinkOracleFactory: "0x133F742c0D36864F37e15C33a18bA6fdc950ED0f";
|
|
634
|
+
readonly preLiquidationFactory: "0xF184156Cf6Ad4D3dA7F6449D40755A0f9de97ef3";
|
|
635
|
+
readonly wNative: "0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1";
|
|
636
|
+
};
|
|
637
|
+
readonly 123420001114: {
|
|
638
|
+
readonly morpho: "0xc7CAd9B1377Eb8103397Cb07Cb5c4f03eb2eBEa8";
|
|
639
|
+
readonly bundler3: {
|
|
640
|
+
readonly bundler3: "0xc1A86b3a552C5a34e1ecc910341A64Cc89b2CB01";
|
|
641
|
+
readonly generalAdapter1: "0x86eaf48Fd73c1Aa30E801D01d0efFd731c3E5E85";
|
|
642
|
+
};
|
|
643
|
+
readonly adaptiveCurveIrm: "0xeEccdD33c0C06d7DDa31E3C4a1Cdb35a2A756246";
|
|
644
|
+
readonly publicAllocator: "0x1e145648DA9aC9d831B4F7931C06e9828083BD40";
|
|
645
|
+
readonly metaMorphoFactory: "0xa8CD521d42b716821D7ddD2Ca6a237087aA5b487";
|
|
646
|
+
readonly chainlinkOracleFactory: "0x24Bc64f44B429EEA86c8B1f9C03F54Ab0C6c0C15";
|
|
647
|
+
readonly preLiquidationFactory: "0x6C0155CC30f760DC49138B389F5B69F56eD08841";
|
|
648
|
+
readonly wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b";
|
|
649
|
+
};
|
|
650
|
+
};
|
|
651
|
+
export declare let addresses: Record<number, ChainAddresses>;
|
|
652
|
+
export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`, `0x${string}`>>;
|
|
653
|
+
/**
|
|
654
|
+
* Registers custom addresses and unwrapped token mappings to extend
|
|
655
|
+
* the default address registry (on ewisting or unknown chains).
|
|
656
|
+
*
|
|
657
|
+
* @param options - Optional configuration object
|
|
658
|
+
* @param options.unwrappedTokens - A mapping of chain IDs to token address maps,
|
|
659
|
+
* where each entry maps wrapped tokens to their unwrapped equivalents.
|
|
660
|
+
* @param options.addresses - Custom address entries to merge into the default registry.
|
|
661
|
+
* Can be a subset of `ChainAddresses` if chain is already known.
|
|
662
|
+
* Must provide all required addresses if chain is unknown.
|
|
663
|
+
*
|
|
664
|
+
* @throws {Error} If attempting to override an existing address.
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* ```ts
|
|
668
|
+
* registerCustomAddresses({
|
|
669
|
+
* addresses: {
|
|
670
|
+
* 1: { contract: "0xabc..." }
|
|
671
|
+
* },
|
|
672
|
+
* unwrappedTokens: {
|
|
673
|
+
* 1: { "0xWrapped": "0xUnwrapped" }
|
|
674
|
+
* }
|
|
675
|
+
* });
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
export declare function registerCustomAddresses({ unwrappedTokens, addresses: customAddresses, }?: {
|
|
679
|
+
unwrappedTokens?: Record<number, Record<Address, Address>>;
|
|
680
|
+
addresses?: DeepPartial<Record<keyof typeof _addressesRegistry, ChainAddresses>> | Record<number, ChainAddresses>;
|
|
681
|
+
}): void;
|
|
682
|
+
export {};
|
package/lib/addresses.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
6
|
+
exports.unwrappedTokensMapping = exports.addresses = exports.addressesRegistry = exports.convexWrapperTokens = exports.getPermissionedCoinbaseTokens = exports.permissionedCoinbaseTokens = exports.permissionedBackedTokens = exports.permissionedWrapperTokens = exports.erc20WrapperTokens = exports.getChainAddresses = exports.NATIVE_ADDRESS = void 0;
|
|
4
7
|
exports.getUnwrappedToken = getUnwrappedToken;
|
|
8
|
+
exports.registerCustomAddresses = registerCustomAddresses;
|
|
5
9
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
10
|
+
const lodash_isplainobject_1 = __importDefault(require("lodash.isplainobject"));
|
|
11
|
+
const lodash_mergewith_1 = __importDefault(require("lodash.mergewith"));
|
|
6
12
|
const chain_js_1 = require("./chain.js");
|
|
7
13
|
const errors_js_1 = require("./errors.js");
|
|
8
14
|
/** Address used to replicate an erc20-behaviour for native token.
|
|
@@ -10,7 +16,7 @@ const errors_js_1 = require("./errors.js");
|
|
|
10
16
|
* NB: data might differ from expected onchain native token data
|
|
11
17
|
*/
|
|
12
18
|
exports.NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
13
|
-
|
|
19
|
+
const _addressesRegistry = {
|
|
14
20
|
[chain_js_1.ChainId.EthMainnet]: {
|
|
15
21
|
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
16
22
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
@@ -310,7 +316,6 @@ exports.addressesRegistry = {
|
|
|
310
316
|
wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b",
|
|
311
317
|
},
|
|
312
318
|
};
|
|
313
|
-
exports.addresses = exports.addressesRegistry;
|
|
314
319
|
const getChainAddresses = (chainId) => {
|
|
315
320
|
const chainAddresses = exports.addresses[chainId];
|
|
316
321
|
if (chainAddresses == null)
|
|
@@ -322,42 +327,64 @@ exports.getChainAddresses = getChainAddresses;
|
|
|
322
327
|
* Assumptions:
|
|
323
328
|
* - unwrapped token has same number of decimals than wrapped tokens.
|
|
324
329
|
*/
|
|
325
|
-
|
|
330
|
+
const _unwrappedTokensMapping = {
|
|
326
331
|
[chain_js_1.ChainId.EthMainnet]: {
|
|
327
|
-
[
|
|
328
|
-
[
|
|
329
|
-
[
|
|
330
|
-
[
|
|
331
|
-
[
|
|
332
|
-
[
|
|
333
|
-
[
|
|
334
|
-
[
|
|
335
|
-
[
|
|
336
|
-
[
|
|
337
|
-
[
|
|
332
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet].wbIB01]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].bIB01,
|
|
333
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet].wbC3M]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].bC3M,
|
|
334
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
335
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet].stEth]: exports.NATIVE_ADDRESS,
|
|
336
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet].wstEth]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].stEth,
|
|
337
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].crvUSDTWBTCWETH,
|
|
338
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].crvUSDCWBTCWETH,
|
|
339
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].crvCRVUSDTBTCWSTETH,
|
|
340
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxTryLSD-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].tryLSD,
|
|
341
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].crvUSDETHCRV,
|
|
342
|
+
[_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvx2BTC-f-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet]["2BTC-f"],
|
|
338
343
|
},
|
|
339
344
|
[chain_js_1.ChainId.BaseMainnet]: {
|
|
340
|
-
[
|
|
341
|
-
[
|
|
342
|
-
[
|
|
345
|
+
[_addressesRegistry[chain_js_1.ChainId.BaseMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
346
|
+
[_addressesRegistry[chain_js_1.ChainId.BaseMainnet].verUsdc]: _addressesRegistry[chain_js_1.ChainId.BaseMainnet].usdc,
|
|
347
|
+
[_addressesRegistry[chain_js_1.ChainId.BaseMainnet].testUsdc]: _addressesRegistry[chain_js_1.ChainId.BaseMainnet].usdc,
|
|
348
|
+
},
|
|
349
|
+
[chain_js_1.ChainId.PolygonMainnet]: {
|
|
350
|
+
[_addressesRegistry[chain_js_1.ChainId.PolygonMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
351
|
+
},
|
|
352
|
+
[chain_js_1.ChainId.OptimismMainnet]: {
|
|
353
|
+
[_addressesRegistry[chain_js_1.ChainId.OptimismMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
354
|
+
},
|
|
355
|
+
[chain_js_1.ChainId.WorldChainMainnet]: {
|
|
356
|
+
[_addressesRegistry[chain_js_1.ChainId.WorldChainMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
357
|
+
},
|
|
358
|
+
[chain_js_1.ChainId.ScrollMainnet]: {
|
|
359
|
+
[_addressesRegistry[chain_js_1.ChainId.ScrollMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
360
|
+
},
|
|
361
|
+
[chain_js_1.ChainId.InkMainnet]: {
|
|
362
|
+
[_addressesRegistry[chain_js_1.ChainId.InkMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
363
|
+
},
|
|
364
|
+
[chain_js_1.ChainId.Unichain]: {
|
|
365
|
+
[_addressesRegistry[chain_js_1.ChainId.Unichain].wNative]: exports.NATIVE_ADDRESS,
|
|
366
|
+
},
|
|
367
|
+
[chain_js_1.ChainId.SonicMainnet]: {
|
|
368
|
+
[_addressesRegistry[chain_js_1.ChainId.SonicMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
369
|
+
},
|
|
370
|
+
[chain_js_1.ChainId.HemiMainnet]: {
|
|
371
|
+
[_addressesRegistry[chain_js_1.ChainId.HemiMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
372
|
+
},
|
|
373
|
+
[chain_js_1.ChainId.ModeMainnet]: {
|
|
374
|
+
[_addressesRegistry[chain_js_1.ChainId.ModeMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
375
|
+
},
|
|
376
|
+
[chain_js_1.ChainId.CornMainnet]: {
|
|
377
|
+
[_addressesRegistry[chain_js_1.ChainId.CornMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
378
|
+
},
|
|
379
|
+
[chain_js_1.ChainId.PlumeMainnet]: {
|
|
380
|
+
[_addressesRegistry[chain_js_1.ChainId.PlumeMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
381
|
+
},
|
|
382
|
+
[chain_js_1.ChainId.CampMainnet]: {
|
|
383
|
+
[_addressesRegistry[chain_js_1.ChainId.CampMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
343
384
|
},
|
|
344
|
-
[chain_js_1.ChainId.PolygonMainnet]: {},
|
|
345
|
-
[chain_js_1.ChainId.ArbitrumMainnet]: {},
|
|
346
|
-
[chain_js_1.ChainId.OptimismMainnet]: {},
|
|
347
|
-
[chain_js_1.ChainId.WorldChainMainnet]: {},
|
|
348
|
-
[chain_js_1.ChainId.FraxtalMainnet]: {},
|
|
349
|
-
[chain_js_1.ChainId.ScrollMainnet]: {},
|
|
350
|
-
[chain_js_1.ChainId.InkMainnet]: {},
|
|
351
|
-
[chain_js_1.ChainId.Unichain]: {},
|
|
352
|
-
[chain_js_1.ChainId.SonicMainnet]: {},
|
|
353
|
-
[chain_js_1.ChainId.HemiMainnet]: {},
|
|
354
|
-
[chain_js_1.ChainId.ModeMainnet]: {},
|
|
355
|
-
[chain_js_1.ChainId.CornMainnet]: {},
|
|
356
|
-
[chain_js_1.ChainId.PlumeMainnet]: {},
|
|
357
|
-
[chain_js_1.ChainId.CampMainnet]: {},
|
|
358
385
|
};
|
|
359
386
|
function getUnwrappedToken(wrappedToken, chainId) {
|
|
360
|
-
return exports.unwrappedTokensMapping[chainId][wrappedToken];
|
|
387
|
+
return exports.unwrappedTokensMapping[chainId]?.[wrappedToken];
|
|
361
388
|
}
|
|
362
389
|
/**
|
|
363
390
|
* The registry of all known ERC20Wrapper tokens.
|
|
@@ -369,7 +396,7 @@ exports.erc20WrapperTokens = {};
|
|
|
369
396
|
*/
|
|
370
397
|
exports.permissionedWrapperTokens = {
|
|
371
398
|
[chain_js_1.ChainId.BaseMainnet]: new Set([
|
|
372
|
-
|
|
399
|
+
_addressesRegistry[chain_js_1.ChainId.BaseMainnet].testUsdc,
|
|
373
400
|
]),
|
|
374
401
|
};
|
|
375
402
|
/**
|
|
@@ -378,8 +405,8 @@ exports.permissionedWrapperTokens = {
|
|
|
378
405
|
*/
|
|
379
406
|
exports.permissionedBackedTokens = {
|
|
380
407
|
[chain_js_1.ChainId.EthMainnet]: new Set([
|
|
381
|
-
|
|
382
|
-
|
|
408
|
+
_addressesRegistry[chain_js_1.ChainId.EthMainnet].wbIB01,
|
|
409
|
+
_addressesRegistry[chain_js_1.ChainId.EthMainnet].wbC3M,
|
|
383
410
|
]),
|
|
384
411
|
};
|
|
385
412
|
/**
|
|
@@ -388,7 +415,7 @@ exports.permissionedBackedTokens = {
|
|
|
388
415
|
*/
|
|
389
416
|
exports.permissionedCoinbaseTokens = {
|
|
390
417
|
[chain_js_1.ChainId.BaseMainnet]: new Set([
|
|
391
|
-
|
|
418
|
+
_addressesRegistry[chain_js_1.ChainId.BaseMainnet].verUsdc,
|
|
392
419
|
]),
|
|
393
420
|
};
|
|
394
421
|
const getPermissionedCoinbaseTokens = (chainId) => exports.permissionedCoinbaseTokens[chainId] ?? new Set();
|
|
@@ -407,11 +434,52 @@ exports.getPermissionedCoinbaseTokens = getPermissionedCoinbaseTokens;
|
|
|
407
434
|
*/
|
|
408
435
|
exports.convexWrapperTokens = {
|
|
409
436
|
[chain_js_1.ChainId.EthMainnet]: new Set([
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
437
|
+
_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"],
|
|
438
|
+
_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"],
|
|
439
|
+
_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"],
|
|
440
|
+
_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxTryLSD-morpho"],
|
|
441
|
+
_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"],
|
|
442
|
+
_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvx2BTC-f-morpho"],
|
|
416
443
|
]),
|
|
417
444
|
};
|
|
445
|
+
exports.addressesRegistry = (0, morpho_ts_1.deepFreeze)(_addressesRegistry);
|
|
446
|
+
exports.addresses = exports.addressesRegistry;
|
|
447
|
+
exports.unwrappedTokensMapping = (0, morpho_ts_1.deepFreeze)(_unwrappedTokensMapping);
|
|
448
|
+
/**
|
|
449
|
+
* Registers custom addresses and unwrapped token mappings to extend
|
|
450
|
+
* the default address registry (on ewisting or unknown chains).
|
|
451
|
+
*
|
|
452
|
+
* @param options - Optional configuration object
|
|
453
|
+
* @param options.unwrappedTokens - A mapping of chain IDs to token address maps,
|
|
454
|
+
* where each entry maps wrapped tokens to their unwrapped equivalents.
|
|
455
|
+
* @param options.addresses - Custom address entries to merge into the default registry.
|
|
456
|
+
* Can be a subset of `ChainAddresses` if chain is already known.
|
|
457
|
+
* Must provide all required addresses if chain is unknown.
|
|
458
|
+
*
|
|
459
|
+
* @throws {Error} If attempting to override an existing address.
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```ts
|
|
463
|
+
* registerCustomAddresses({
|
|
464
|
+
* addresses: {
|
|
465
|
+
* 1: { contract: "0xabc..." }
|
|
466
|
+
* },
|
|
467
|
+
* unwrappedTokens: {
|
|
468
|
+
* 1: { "0xWrapped": "0xUnwrapped" }
|
|
469
|
+
* }
|
|
470
|
+
* });
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
function registerCustomAddresses({ unwrappedTokens, addresses: customAddresses, } = {}) {
|
|
474
|
+
// biome-ignore lint/suspicious/noExplicitAny: type is not trivial and not important here
|
|
475
|
+
const customizer = (objValue, srcValue, key) => {
|
|
476
|
+
if (objValue !== undefined &&
|
|
477
|
+
!(0, lodash_isplainobject_1.default)(objValue) &&
|
|
478
|
+
objValue !== srcValue)
|
|
479
|
+
throw new Error(`Cannot override existing address: ${key}`);
|
|
480
|
+
};
|
|
481
|
+
if (customAddresses)
|
|
482
|
+
exports.addresses = exports.addressesRegistry = (0, morpho_ts_1.deepFreeze)((0, lodash_mergewith_1.default)({}, exports.addressesRegistry, customAddresses, customizer));
|
|
483
|
+
if (unwrappedTokens)
|
|
484
|
+
exports.unwrappedTokensMapping = (0, morpho_ts_1.deepFreeze)((0, lodash_mergewith_1.default)({}, exports.unwrappedTokensMapping, unwrappedTokens, customizer));
|
|
485
|
+
}
|
|
@@ -12,7 +12,7 @@ class WrappedToken extends Token_js_1.Token {
|
|
|
12
12
|
/** The expected amount when wrapping `unwrappedAmount` */
|
|
13
13
|
toWrappedExactAmountIn(unwrappedAmount, slippage = 0n, rounding = "Down") {
|
|
14
14
|
const wrappedAmount = this._wrap(unwrappedAmount, rounding);
|
|
15
|
-
return index_js_1.MathLib.
|
|
15
|
+
return index_js_1.MathLib.wMulDown(wrappedAmount, index_js_1.MathLib.WAD - slippage);
|
|
16
16
|
}
|
|
17
17
|
/** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
|
|
18
18
|
toWrappedExactAmountOut(wrappedAmount, slippage = 0n, rounding = "Up") {
|
|
@@ -22,7 +22,7 @@ class WrappedToken extends Token_js_1.Token {
|
|
|
22
22
|
/** The expected amount when unwrapping `wrappedAmount` */
|
|
23
23
|
toUnwrappedExactAmountIn(wrappedAmount, slippage = 0n, rounding = "Down") {
|
|
24
24
|
const unwrappedAmount = this._unwrap(wrappedAmount, rounding);
|
|
25
|
-
return index_js_1.MathLib.
|
|
25
|
+
return index_js_1.MathLib.wMulUp(unwrappedAmount, index_js_1.MathLib.WAD - slippage);
|
|
26
26
|
}
|
|
27
27
|
/** The amount of wrappedTokens that should be unwrapped to receive `unwrappedAmount` */
|
|
28
28
|
toUnwrappedExactAmountOut(unwrappedAmount, slippage = 0n, rounding = "Up") {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/blue-sdk",
|
|
3
3
|
"description": "Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-next.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|
|
@@ -18,17 +18,21 @@
|
|
|
18
18
|
"lib"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@noble/hashes": "^1.6.1"
|
|
21
|
+
"@noble/hashes": "^1.6.1",
|
|
22
|
+
"@types/lodash.isplainobject": "^4.0.9",
|
|
23
|
+
"@types/lodash.mergewith": "^4.6.9",
|
|
24
|
+
"lodash.isplainobject": "^4.0.6",
|
|
25
|
+
"lodash.mergewith": "^4.6.2"
|
|
22
26
|
},
|
|
23
27
|
"peerDependencies": {
|
|
24
|
-
"@morpho-org/morpho-ts": "^2.
|
|
28
|
+
"@morpho-org/morpho-ts": "^2.4.0-next.0"
|
|
25
29
|
},
|
|
26
30
|
"devDependencies": {
|
|
27
31
|
"typescript": "^5.7.2",
|
|
28
32
|
"viem": "^2.23.0",
|
|
29
33
|
"vitest": "^3.0.5",
|
|
30
|
-
"@morpho-org/
|
|
31
|
-
"@morpho-org/
|
|
34
|
+
"@morpho-org/test": "^2.1.4-next.0",
|
|
35
|
+
"@morpho-org/morpho-ts": "^2.4.0-next.0"
|
|
32
36
|
},
|
|
33
37
|
"scripts": {
|
|
34
38
|
"prepublish": "$npm_execpath build",
|