@morpho-org/blue-sdk 3.0.8 → 4.0.0-next.1

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 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
+ ```
@@ -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
- export declare const addressesRegistry: {
52
+ declare const _addressesRegistry: {
53
53
  readonly 1: {
54
54
  readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
55
55
  readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
@@ -336,15 +336,9 @@ export declare const addressesRegistry: {
336
336
  readonly wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b";
337
337
  };
338
338
  };
339
- export declare const addresses: Record<number, ChainAddresses>;
340
- export type AddressLabel = DottedKeys<(typeof addressesRegistry)[ChainId]>;
339
+ export type AddressLabel = DottedKeys<(typeof _addressesRegistry)[ChainId]>;
341
340
  export declare const getChainAddresses: (chainId: number) => ChainAddresses;
342
- /**
343
- * Assumptions:
344
- * - unwrapped token has same number of decimals than wrapped tokens.
345
- */
346
- export declare const unwrappedTokensMapping: Record<ChainId, Record<Address, Address>>;
347
- export declare function getUnwrappedToken(wrappedToken: Address, chainId: ChainId): `0x${string}` | undefined;
341
+ export declare function getUnwrappedToken(wrappedToken: Address, chainId: number): `0x${string}` | undefined;
348
342
  /**
349
343
  * The registry of all known ERC20Wrapper tokens.
350
344
  */
@@ -369,3 +363,322 @@ export declare const getPermissionedCoinbaseTokens: (chainId: number) => Set<`0x
369
363
  * - calling `depositFor` supplies on blue instead of minting wrapped token to the user
370
364
  */
371
365
  export declare const convexWrapperTokens: Record<number, Set<Address>>;
366
+ export declare let addressesRegistry: {
367
+ readonly 1: {
368
+ readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
369
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
370
+ /**
371
+ * @deprecated All bundles should use Bundler3 instead.
372
+ */
373
+ readonly bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077";
374
+ readonly bundler3: {
375
+ readonly bundler3: "0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245";
376
+ readonly generalAdapter1: "0x4A6c312ec70E8747a587EE860a0353cd42Be0aE0";
377
+ readonly paraswapAdapter: "0x03b5259Bd204BfD4A616E5B79b0B786d90c6C38f";
378
+ readonly erc20WrapperAdapter: "0xf83D17dFE160597b19e4FdD8ea61A23e9a87F962";
379
+ readonly compoundV2MigrationAdapter: "0x9B89c07f480Df1945279031b5fC6fF241b8f1101";
380
+ readonly compoundV3MigrationAdapter: "0xdBa5bdE29eA030Bfa6A608592dFcA1D02CB26773";
381
+ readonly aaveV2MigrationAdapter: "0x40288815C399709dFC0875A384B637fFe387961B";
382
+ readonly aaveV3CoreMigrationAdapter: "0xb09e40EbE31b738fbf20289270a397118707D475";
383
+ readonly aaveV3PrimeMigrationAdapter: "0x2CC8d502a65824B4cF9A58DB03490bA024BDB806";
384
+ readonly aaveV3EtherFiMigrationAdapter: "0x4011dc6581fA05F9B0c7A12AdCd676e2b1a59ca3";
385
+ readonly aaveV3OptimizerMigrationAdapter: "0x9e2ea2d5785598a163D569D795f286F5C55ad972";
386
+ };
387
+ readonly aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c";
388
+ readonly aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76";
389
+ readonly aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC";
390
+ readonly compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558";
391
+ readonly compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647";
392
+ readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
393
+ readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
394
+ readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
395
+ readonly chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766";
396
+ readonly preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476";
397
+ readonly wNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
398
+ readonly morphoToken: "0x9994E35Db50125E0DF82e4c2dde62496CE330999";
399
+ readonly dai: "0x6B175474E89094C44Da98b954EedeAC495271d0F";
400
+ readonly sDai: "0x83F20F44975D03b1b09e64809B757c47f942BEeA";
401
+ readonly mkr: "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2";
402
+ readonly stEth: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
403
+ readonly wstEth: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0";
404
+ readonly osEth: "0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38";
405
+ readonly bIB01: "0xCA30c93B02514f86d5C86a6e375E3A330B435Fb5";
406
+ readonly wbIB01: "0xcA2A7068e551d5C4482eb34880b194E4b945712F";
407
+ readonly bC3M: "0x2F123cF3F37CE3328CC9B5b8415f9EC5109b45e7";
408
+ readonly wbC3M: "0x95D7337d43340E2721960Dc402D9b9117f0d81a2";
409
+ readonly usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
410
+ readonly usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7";
411
+ readonly crvUsd: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E";
412
+ readonly "stkcvxcrvUSDTWBTCWETH-morpho": "0xb0Ce26C88e4e7DCa51968b6047f44646f5064278";
413
+ readonly crvUSDTWBTCWETH: "0xf5f5B97624542D72A9E06f04804Bf81baA15e2B4";
414
+ readonly "stkcvxcrvUSDCWBTCWETH-morpho": "0x0ea1a65A2c255f24Ee8D81eA6AaC54Decd9d269e";
415
+ readonly crvUSDCWBTCWETH: "0x7F86Bf177Dd4F3494b841a37e810A34dD56c829B";
416
+ readonly "stkcvxcrvCRVUSDTBTCWSTETH-morpho": "0x3ce8Ec9f3d89aD0A2DdbCC3FDB8991BD241Fc82E";
417
+ readonly crvCRVUSDTBTCWSTETH: "0x2889302a794dA87fBF1D6Db415C1492194663D13";
418
+ readonly "stkcvxTryLSD-morpho": "0x6BA072F0d22806F2C52e9792AF47f2D59103BEBE";
419
+ readonly tryLSD: "0x2570f1bD5D2735314FC102eb12Fc1aFe9e6E7193";
420
+ readonly "stkcvxcrvUSDETHCRV-morpho": "0xAc904BAfBb5FB04Deb2b6198FdCEedE75a78Ce5a";
421
+ readonly crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14";
422
+ readonly "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e";
423
+ readonly "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726";
424
+ };
425
+ readonly 8453: {
426
+ readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
427
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
428
+ /**
429
+ * @deprecated All bundles should use Bundler3 instead.
430
+ */
431
+ readonly bundler: "0x23055618898e202386e6c13955a58D3C68200BFB";
432
+ readonly bundler3: {
433
+ readonly bundler3: "0x6BFd8137e702540E7A42B74178A4a49Ba43920C4";
434
+ readonly generalAdapter1: "0xb98c948CFA24072e58935BC004a8A7b376AE746A";
435
+ readonly paraswapAdapter: "0x6abE8ABd0275E5564ed1336F0243A52C32562F71";
436
+ readonly erc20WrapperAdapter: "0xdeEf55F0A7366cC3Baf5E04313269389Fe17E9AE";
437
+ readonly compoundV3MigrationAdapter: "0x85D4812Ef92c040d4270eD8547b6835e41FbbB70";
438
+ readonly aaveV3CoreMigrationAdapter: "0xb27Aa2a964eAd5ed661D86974b37e4fB995b36f5";
439
+ };
440
+ readonly compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223";
441
+ readonly aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108";
442
+ readonly compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA";
443
+ readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
444
+ readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
445
+ readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
446
+ readonly chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d";
447
+ readonly preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef";
448
+ readonly wNative: "0x4200000000000000000000000000000000000006";
449
+ readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
450
+ readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
451
+ readonly testUsdc: "0xBC77067f829979812d795d516E523C4033b66409";
452
+ };
453
+ readonly 137: {
454
+ readonly morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67";
455
+ readonly bundler3: {
456
+ readonly bundler3: "0x2d9C3A9E67c966C711208cc78b34fB9E9f8db589";
457
+ readonly generalAdapter1: "0xB261B51938A9767406ef83bbFbaAFE16691b7047";
458
+ readonly paraswapAdapter: "0x5F2617F12D1fDd1e43e72Cb80C92dFcE8124Db8d";
459
+ readonly compoundV3MigrationAdapter: "0xB34D2f54139bA12defC315C0822aDf9A5eB9A9b7";
460
+ readonly aaveV2MigrationAdapter: "0x43980Ae597f12Ff64690506b2AEEFFb4D8BeAF2a";
461
+ readonly aaveV3CoreMigrationAdapter: "0xEcB1662a1dff5C20650CF98c3334d2fddcD50742";
462
+ };
463
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
464
+ readonly adaptiveCurveIrm: "0xe675A2161D4a6E2de2eeD70ac98EEBf257FBF0B0";
465
+ readonly publicAllocator: "0xfac15aff53ADd2ff80C2962127C434E8615Df0d3";
466
+ readonly metaMorphoFactory: "0xa9c87daB340631C34BB738625C70499e29ddDC98";
467
+ readonly chainlinkOracleFactory: "0x1ff7895Eb842794c5d07C4c547b6730e61295215";
468
+ readonly preLiquidationFactory: "0xeDadDe37D76c72b98725614d0b41C20Fe612d304";
469
+ readonly wNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270";
470
+ readonly usdc: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359";
471
+ };
472
+ readonly 42161: {
473
+ readonly morpho: "0x6c247b1F6182318877311737BaC0844bAa518F5e";
474
+ readonly bundler3: {
475
+ readonly bundler3: "0x1FA4431bC113D308beE1d46B0e98Cb805FB48C13";
476
+ readonly generalAdapter1: "0x9954aFB60BB5A222714c478ac86990F221788B88";
477
+ readonly paraswapAdapter: "0xAA5c30C1482c189cA0d56057D3ac4dD7Af1e4726";
478
+ };
479
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
480
+ readonly adaptiveCurveIrm: "0x66F30587FB8D4206918deb78ecA7d5eBbafD06DA";
481
+ readonly publicAllocator: "0x769583Af5e9D03589F159EbEC31Cc2c23E8C355E";
482
+ readonly metaMorphoFactory: "0x878988f5f561081deEa117717052164ea1Ef0c82";
483
+ readonly chainlinkOracleFactory: "0x98Ce5D183DC0c176f54D37162F87e7eD7f2E41b5";
484
+ readonly preLiquidationFactory: "0x635c31B5DF1F7EFbCbC07E302335Ef4230758e3d";
485
+ readonly wNative: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
486
+ readonly usdc: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
487
+ };
488
+ readonly 10: {
489
+ readonly morpho: "0xce95AfbB8EA029495c66020883F87aaE8864AF92";
490
+ readonly bundler3: {
491
+ readonly bundler3: "0xFBCd3C258feB131D8E038F2A3a670A7bE0507C05";
492
+ readonly generalAdapter1: "0x79481C87f24A3C4332442A2E9faaf675e5F141f0";
493
+ readonly paraswapAdapter: "0x31F539f4Ed14fA1fd18781e93f6739249692aDC5";
494
+ };
495
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
496
+ readonly adaptiveCurveIrm: "0x8cD70A8F399428456b29546BC5dBe10ab6a06ef6";
497
+ readonly publicAllocator: "0x0d68a97324E602E02799CD83B42D337207B40658";
498
+ readonly metaMorphoFactory: "0x3Bb6A6A0Bc85b367EFE0A5bAc81c5E52C892839a";
499
+ readonly chainlinkOracleFactory: "0x1ec408D4131686f727F3Fd6245CF85Bc5c9DAD70";
500
+ readonly preLiquidationFactory: "0x3d05C01EE8e97361b9E19D172128255eaE5F98B9";
501
+ readonly wNative: "0x4200000000000000000000000000000000000006";
502
+ readonly usdc: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85";
503
+ };
504
+ readonly 480: {
505
+ readonly morpho: "0xE741BC7c34758b4caE05062794E8Ae24978AF432";
506
+ readonly bundler3: {
507
+ readonly bundler3: "0x3D07BF2FFb23248034bF704F3a4786F1ffE2a448";
508
+ readonly generalAdapter1: "0x30fa9A3cF56931ACEea42E28D35519a97D90aA67";
509
+ };
510
+ readonly adaptiveCurveIrm: "0x34E99D604751a72cF8d0CFDf87069292d82De472";
511
+ readonly publicAllocator: "0xef9889B4e443DEd35FA0Bd060f2104Cca94e6A43";
512
+ readonly metaMorphoFactory: "0x4DBB3a642a2146d5413750Cca3647086D9ba5F12";
513
+ readonly chainlinkOracleFactory: "0xd706690BA1Fe26b70c4AD89e60ff62cEB3A2eD02";
514
+ readonly preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695";
515
+ readonly wNative: "0x4200000000000000000000000000000000000006";
516
+ };
517
+ readonly 252: {
518
+ readonly morpho: "0xa6030627d724bA78a59aCf43Be7550b4C5a0653b";
519
+ readonly bundler3: {
520
+ readonly bundler3: "0xA7a414823Ef0F8CFb2c4f67f2F445DA940641d91";
521
+ readonly generalAdapter1: "0x228dDF333DDf6D1895dA1dE8a846EDD27F1284eD";
522
+ };
523
+ readonly adaptiveCurveIrm: "0xA0D4D77b5D9933073572E19C172BFE866312673b";
524
+ readonly publicAllocator: "0x37a888192165fC39884f87c64E2476BfD2C09675";
525
+ readonly metaMorphoFactory: "0x27D4Af0AC9E7FDfA6D0853236f249CC27AE79488";
526
+ readonly chainlinkOracleFactory: "0x39d8622C607A691D7705E8842fbB12E3c38dCD41";
527
+ readonly preLiquidationFactory: "0xe3cE2051a24e58DBFC0eFBe4c2d9e89c5eAe4695";
528
+ readonly wNative: "0xfc00000000000000000000000000000000000006";
529
+ };
530
+ readonly 534352: {
531
+ readonly morpho: "0x2d012EdbAdc37eDc2BC62791B666f9193FDF5a55";
532
+ readonly bundler3: {
533
+ readonly bundler3: "0x60F9159d4dCd724e743212416FD57d8aC0B60768";
534
+ readonly generalAdapter1: "0xD2780fae0869cDc06EE202152304A39653361525";
535
+ };
536
+ readonly adaptiveCurveIrm: "0xa5EA7500A27C0079961D93366A6e93aafF18CB90";
537
+ readonly publicAllocator: "0x8a7f671E45E51dE245649Cf916cA0256FB8a9927";
538
+ readonly metaMorphoFactory: "0x56b65742ade55015e6480959808229Ad6dbc9295";
539
+ readonly chainlinkOracleFactory: "0xb5961902E60b188b1c665B7b72Ef616656A9e24E";
540
+ readonly preLiquidationFactory: "0xeD960178e4aDA0296786Fa79D84e8FDF7bd44B25";
541
+ readonly wNative: "0x5300000000000000000000000000000000000004";
542
+ readonly usdc: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4";
543
+ };
544
+ readonly 57073: {
545
+ readonly morpho: "0x857f3EefE8cbda3Bc49367C996cd664A880d3042";
546
+ readonly bundler3: {
547
+ readonly bundler3: "0x7db0F1E2bf1f47ec82220090F388d75D8B9BB6BC";
548
+ readonly generalAdapter1: "0xB8B2aDdCDe1cdC94AaE18a0F8A19df03D8683610";
549
+ };
550
+ readonly adaptiveCurveIrm: "0x9515407b1512F53388ffE699524100e7270Ee57B";
551
+ readonly publicAllocator: "0x85416891752a6B81106c1C2999AE1AF5d8Cd3357";
552
+ readonly metaMorphoFactory: "0xd3f39505d0c48AFED3549D625982FdC38Ea9904b";
553
+ readonly chainlinkOracleFactory: "0x3FFFE273ee348b9E1ef89533025C7f165B17B439";
554
+ readonly preLiquidationFactory: "0x30607fEa77168d2c0401B6f60F0B40E32F9339E3";
555
+ readonly wNative: "0x4200000000000000000000000000000000000006";
556
+ readonly usdc: "0xF1815bd50389c46847f0Bda824eC8da914045D14";
557
+ };
558
+ readonly 130: {
559
+ readonly morpho: "0x8f5ae9CddB9f68de460C77730b018Ae7E04a140A";
560
+ readonly bundler3: {
561
+ readonly bundler3: "0x7DD85759182495AF7F6757DA75036d24A9B58bc3";
562
+ readonly generalAdapter1: "0xC11329d19C2275c9E759867e879ECFcEeD7e30A0";
563
+ };
564
+ readonly adaptiveCurveIrm: "0x9a6061d51743B31D2c3Be75D83781Fa423f53F0E";
565
+ readonly publicAllocator: "0xB0c9a107fA17c779B3378210A7a593e88938C7C9";
566
+ readonly metaMorphoFactory: "0xe9EdE3929F43a7062a007C3e8652e4ACa610Bdc0";
567
+ readonly chainlinkOracleFactory: "0x43269546e1D586a1f7200a0AC07e26f9631f7539";
568
+ readonly preLiquidationFactory: "0xb04e4D3D59Ee47Ca9BA192707AF13A7D02969911";
569
+ readonly wNative: "0x4200000000000000000000000000000000000006";
570
+ readonly usdc: "0x078D782b760474a361dDA0AF3839290b0EF57AD6";
571
+ };
572
+ readonly 146: {
573
+ readonly morpho: "0xd6c916eB7542D0Ad3f18AEd0FCBD50C582cfa95f";
574
+ readonly bundler3: {
575
+ readonly bundler3: "0xB06F1Ad8c908b958E596c42973f67F2f1d9a9afF";
576
+ readonly generalAdapter1: "0x31D5aee8D75EEab548cfA0d11C4f9843a5201eaf";
577
+ };
578
+ readonly adaptiveCurveIrm: "0xDEfCf242226425f93d8DD0e314735C28517C473F";
579
+ readonly publicAllocator: "0x6Cef2EDC70D87E8f1623f3096efF05d066E59B36";
580
+ readonly metaMorphoFactory: "0x0cE9e3512CB4df8ae7e265e62Fb9258dc14f12e8";
581
+ readonly chainlinkOracleFactory: "0x7DA59Fa482F1F49fADc486d8e47BADc506fEb86d";
582
+ readonly preLiquidationFactory: "0xc72129DA4CC808e955699111b8c22B22Ca8A10b8";
583
+ readonly wNative: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38";
584
+ };
585
+ readonly 43111: {
586
+ readonly morpho: "0xa4Ca2c2e25b97DA19879201bA49422bc6f181f42";
587
+ readonly bundler3: {
588
+ readonly bundler3: "0x8eDa6E01a20E3Cd90B3B2AF6F790cB8FADEf3Ea8";
589
+ readonly generalAdapter1: "0x9623090C3943ad63F7d794378273610Dd0deeFD4";
590
+ };
591
+ readonly adaptiveCurveIrm: "0xdEbdEa31624552DF904A065221cD14088ABDeD70";
592
+ readonly publicAllocator: "0x4107Ea1746909028d6212B315dE5fE9538F9eb39";
593
+ readonly metaMorphoFactory: "0x8e52179BeB18E882040b01632440d8Ca0f01da82";
594
+ readonly chainlinkOracleFactory: "0xB3cb32E6185446a6Bc7A047E4FfA138fA939e133";
595
+ readonly preLiquidationFactory: "0x40F2896C551194e364F7C846046C34d8a9FE97e4";
596
+ readonly wNative: "0x4200000000000000000000000000000000000006";
597
+ readonly usdc: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA";
598
+ };
599
+ readonly 34443: {
600
+ readonly morpho: "0xd85cE6BD68487E0AaFb0858FDE1Cd18c76840564";
601
+ readonly bundler3: {
602
+ readonly bundler3: "0xFEA0edFa081C8D5960Ec9Bf6684981dB1834305d";
603
+ readonly generalAdapter1: "0xF53925b95Cc409447066cd5c1A7756084b2Ee0a4";
604
+ };
605
+ readonly adaptiveCurveIrm: "0xE3d46Ae190Cb39ccA3655E966DcEF96b4eAe1d1c";
606
+ readonly publicAllocator: "0xEE868Bf3359DA30c10ea472EAEBFC0a06E8F0120";
607
+ readonly metaMorphoFactory: "0xae5b0884bfff430493D6C844B9fd052Af7d79278";
608
+ readonly chainlinkOracleFactory: "0xf9380f7898423Bd7FDe3C9fDD1b2671A2471f39D";
609
+ readonly preLiquidationFactory: "0x249E4808264c545861e43728186a731dE7c7D745";
610
+ readonly wNative: "0x4200000000000000000000000000000000000006";
611
+ };
612
+ readonly 21000000: {
613
+ readonly morpho: "0xc2B1E031540e3F3271C5F3819F0cC7479a8DdD90";
614
+ readonly bundler3: {
615
+ readonly bundler3: "0x086889F9bdE8349512dD77088A7114E6C1c42Af7";
616
+ readonly generalAdapter1: "0x464a402244bCDdc0c2091D5193E8ffdb2be54Ca9";
617
+ };
618
+ readonly adaptiveCurveIrm: "0x58a42117d753a0e69694545DfA19d64c2fB759fB";
619
+ readonly publicAllocator: "0xDFde06e2B2A2D718eE5560b73dA4F830E56A2f10";
620
+ readonly metaMorphoFactory: "0xe430821595602eA5DD0cD350f86987437c7362fA";
621
+ readonly chainlinkOracleFactory: "0x16278156D366fC91536b6b81482ffaC47EEa06D6";
622
+ readonly preLiquidationFactory: "0xb9065AC18d3EBdb3263B77B587f9c5CD570545D1";
623
+ readonly wNative: "0xda5dDd7270381A7C2717aD10D1c0ecB19e3CDFb2";
624
+ readonly usdc: "0xDF0B24095e15044538866576754F3C964e902Ee6";
625
+ };
626
+ readonly 98866: {
627
+ readonly morpho: "0x42b18785CE0Aed7BF7Ca43a39471ED4C0A3e0bB5";
628
+ readonly bundler3: {
629
+ readonly bundler3: "0x5437C8788f4CFbaA55be6FBf30379bc7dd7f69C3";
630
+ readonly generalAdapter1: "0x65ff368930Cb7eB4CA5C5eBC58bb69E6Ed198BA5";
631
+ };
632
+ readonly adaptiveCurveIrm: "0x7420302Ddd469031Cd2282cd64225cCd46F581eA";
633
+ readonly publicAllocator: "0x58485338D93F4e3b4Bf2Af1C9f9C0aDF087AEf1C";
634
+ readonly metaMorphoFactory: "0x2525D453D9BA13921D5aB5D8c12F9202b0e19456";
635
+ readonly chainlinkOracleFactory: "0x133F742c0D36864F37e15C33a18bA6fdc950ED0f";
636
+ readonly preLiquidationFactory: "0xF184156Cf6Ad4D3dA7F6449D40755A0f9de97ef3";
637
+ readonly wNative: "0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1";
638
+ };
639
+ readonly 123420001114: {
640
+ readonly morpho: "0xc7CAd9B1377Eb8103397Cb07Cb5c4f03eb2eBEa8";
641
+ readonly bundler3: {
642
+ readonly bundler3: "0xc1A86b3a552C5a34e1ecc910341A64Cc89b2CB01";
643
+ readonly generalAdapter1: "0x86eaf48Fd73c1Aa30E801D01d0efFd731c3E5E85";
644
+ };
645
+ readonly adaptiveCurveIrm: "0xeEccdD33c0C06d7DDa31E3C4a1Cdb35a2A756246";
646
+ readonly publicAllocator: "0x1e145648DA9aC9d831B4F7931C06e9828083BD40";
647
+ readonly metaMorphoFactory: "0xa8CD521d42b716821D7ddD2Ca6a237087aA5b487";
648
+ readonly chainlinkOracleFactory: "0x24Bc64f44B429EEA86c8B1f9C03F54Ab0C6c0C15";
649
+ readonly preLiquidationFactory: "0x6C0155CC30f760DC49138B389F5B69F56eD08841";
650
+ readonly wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b";
651
+ };
652
+ };
653
+ export declare let addresses: Record<number, ChainAddresses>;
654
+ export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`, `0x${string}`>>;
655
+ /**
656
+ * Registers custom addresses and unwrapped token mappings to extend
657
+ * the default address registry (on ewisting or unknown chains).
658
+ *
659
+ * @param options - Optional configuration object
660
+ * @param options.unwrappedTokens - A mapping of chain IDs to token address maps,
661
+ * where each entry maps wrapped tokens to their unwrapped equivalents.
662
+ * @param options.addresses - Custom address entries to merge into the default registry.
663
+ * Can be a subset of `ChainAddresses` if chain is already known.
664
+ * Must provide all required addresses if chain is unknown.
665
+ *
666
+ * @throws {Error} If attempting to override an existing address.
667
+ *
668
+ * @example
669
+ * ```ts
670
+ * registerCustomAddresses({
671
+ * addresses: {
672
+ * 1: { contract: "0xabc..." }
673
+ * },
674
+ * unwrappedTokens: {
675
+ * 1: { "0xWrapped": "0xUnwrapped" }
676
+ * }
677
+ * });
678
+ * ```
679
+ */
680
+ export declare function registerCustomAddresses({ unwrappedTokens, addresses: customAddresses, }?: {
681
+ unwrappedTokens?: Record<number, Record<Address, Address>>;
682
+ addresses?: DeepPartial<Record<keyof typeof _addressesRegistry, ChainAddresses>> | Record<number, ChainAddresses>;
683
+ }): void;
684
+ 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.convexWrapperTokens = exports.getPermissionedCoinbaseTokens = exports.permissionedCoinbaseTokens = exports.permissionedBackedTokens = exports.permissionedWrapperTokens = exports.erc20WrapperTokens = exports.unwrappedTokensMapping = exports.getChainAddresses = exports.addresses = exports.addressesRegistry = exports.NATIVE_ADDRESS = void 0;
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
- exports.addressesRegistry = {
19
+ const _addressesRegistry = {
14
20
  [chain_js_1.ChainId.EthMainnet]: {
15
21
  morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
16
22
  permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
@@ -312,7 +318,6 @@ exports.addressesRegistry = {
312
318
  wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b",
313
319
  },
314
320
  };
315
- exports.addresses = exports.addressesRegistry;
316
321
  const getChainAddresses = (chainId) => {
317
322
  const chainAddresses = exports.addresses[chainId];
318
323
  if (chainAddresses == null)
@@ -324,66 +329,64 @@ exports.getChainAddresses = getChainAddresses;
324
329
  * Assumptions:
325
330
  * - unwrapped token has same number of decimals than wrapped tokens.
326
331
  */
327
- exports.unwrappedTokensMapping = {
332
+ const _unwrappedTokensMapping = {
328
333
  [chain_js_1.ChainId.EthMainnet]: {
329
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].wbIB01]: exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].bIB01,
330
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].wbC3M]: exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].bC3M,
331
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].wNative]: exports.NATIVE_ADDRESS,
332
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].stEth]: exports.NATIVE_ADDRESS,
333
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].wstEth]: exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].stEth,
334
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"]]: exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].crvUSDTWBTCWETH,
335
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"]]: exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].crvUSDCWBTCWETH,
336
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"]]: exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].crvCRVUSDTBTCWSTETH,
337
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxTryLSD-morpho"]]: exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].tryLSD,
338
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"]]: exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].crvUSDETHCRV,
339
- [exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvx2BTC-f-morpho"]]: exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["2BTC-f"],
334
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet].wbIB01]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].bIB01,
335
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet].wbC3M]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].bC3M,
336
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet].wNative]: exports.NATIVE_ADDRESS,
337
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet].stEth]: exports.NATIVE_ADDRESS,
338
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet].wstEth]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].stEth,
339
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].crvUSDTWBTCWETH,
340
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].crvUSDCWBTCWETH,
341
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].crvCRVUSDTBTCWSTETH,
342
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxTryLSD-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].tryLSD,
343
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet].crvUSDETHCRV,
344
+ [_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvx2BTC-f-morpho"]]: _addressesRegistry[chain_js_1.ChainId.EthMainnet]["2BTC-f"],
340
345
  },
341
346
  [chain_js_1.ChainId.BaseMainnet]: {
342
- [exports.addressesRegistry[chain_js_1.ChainId.BaseMainnet].wNative]: exports.NATIVE_ADDRESS,
343
- [exports.addressesRegistry[chain_js_1.ChainId.BaseMainnet].verUsdc]: exports.addressesRegistry[chain_js_1.ChainId.BaseMainnet].usdc,
344
- [exports.addressesRegistry[chain_js_1.ChainId.BaseMainnet].testUsdc]: exports.addressesRegistry[chain_js_1.ChainId.BaseMainnet].usdc,
347
+ [_addressesRegistry[chain_js_1.ChainId.BaseMainnet].wNative]: exports.NATIVE_ADDRESS,
348
+ [_addressesRegistry[chain_js_1.ChainId.BaseMainnet].verUsdc]: _addressesRegistry[chain_js_1.ChainId.BaseMainnet].usdc,
349
+ [_addressesRegistry[chain_js_1.ChainId.BaseMainnet].testUsdc]: _addressesRegistry[chain_js_1.ChainId.BaseMainnet].usdc,
345
350
  },
346
351
  [chain_js_1.ChainId.PolygonMainnet]: {
347
- [exports.addressesRegistry[chain_js_1.ChainId.PolygonMainnet].wNative]: exports.NATIVE_ADDRESS,
352
+ [_addressesRegistry[chain_js_1.ChainId.PolygonMainnet].wNative]: exports.NATIVE_ADDRESS,
348
353
  },
349
- [chain_js_1.ChainId.ArbitrumMainnet]: {},
350
354
  [chain_js_1.ChainId.OptimismMainnet]: {
351
- [exports.addressesRegistry[chain_js_1.ChainId.OptimismMainnet].wNative]: exports.NATIVE_ADDRESS,
355
+ [_addressesRegistry[chain_js_1.ChainId.OptimismMainnet].wNative]: exports.NATIVE_ADDRESS,
352
356
  },
353
357
  [chain_js_1.ChainId.WorldChainMainnet]: {
354
- [exports.addressesRegistry[chain_js_1.ChainId.WorldChainMainnet].wNative]: exports.NATIVE_ADDRESS,
358
+ [_addressesRegistry[chain_js_1.ChainId.WorldChainMainnet].wNative]: exports.NATIVE_ADDRESS,
355
359
  },
356
- [chain_js_1.ChainId.FraxtalMainnet]: {},
357
360
  [chain_js_1.ChainId.ScrollMainnet]: {
358
- [exports.addressesRegistry[chain_js_1.ChainId.ScrollMainnet].wNative]: exports.NATIVE_ADDRESS,
361
+ [_addressesRegistry[chain_js_1.ChainId.ScrollMainnet].wNative]: exports.NATIVE_ADDRESS,
359
362
  },
360
363
  [chain_js_1.ChainId.InkMainnet]: {
361
- [exports.addressesRegistry[chain_js_1.ChainId.InkMainnet].wNative]: exports.NATIVE_ADDRESS,
364
+ [_addressesRegistry[chain_js_1.ChainId.InkMainnet].wNative]: exports.NATIVE_ADDRESS,
362
365
  },
363
366
  [chain_js_1.ChainId.Unichain]: {
364
- [exports.addressesRegistry[chain_js_1.ChainId.Unichain].wNative]: exports.NATIVE_ADDRESS,
367
+ [_addressesRegistry[chain_js_1.ChainId.Unichain].wNative]: exports.NATIVE_ADDRESS,
365
368
  },
366
369
  [chain_js_1.ChainId.SonicMainnet]: {
367
- [exports.addressesRegistry[chain_js_1.ChainId.SonicMainnet].wNative]: exports.NATIVE_ADDRESS,
370
+ [_addressesRegistry[chain_js_1.ChainId.SonicMainnet].wNative]: exports.NATIVE_ADDRESS,
368
371
  },
369
372
  [chain_js_1.ChainId.HemiMainnet]: {
370
- [exports.addressesRegistry[chain_js_1.ChainId.HemiMainnet].wNative]: exports.NATIVE_ADDRESS,
373
+ [_addressesRegistry[chain_js_1.ChainId.HemiMainnet].wNative]: exports.NATIVE_ADDRESS,
371
374
  },
372
375
  [chain_js_1.ChainId.ModeMainnet]: {
373
- [exports.addressesRegistry[chain_js_1.ChainId.ModeMainnet].wNative]: exports.NATIVE_ADDRESS,
376
+ [_addressesRegistry[chain_js_1.ChainId.ModeMainnet].wNative]: exports.NATIVE_ADDRESS,
374
377
  },
375
378
  [chain_js_1.ChainId.CornMainnet]: {
376
- [exports.addressesRegistry[chain_js_1.ChainId.CornMainnet].wNative]: exports.NATIVE_ADDRESS,
379
+ [_addressesRegistry[chain_js_1.ChainId.CornMainnet].wNative]: exports.NATIVE_ADDRESS,
377
380
  },
378
381
  [chain_js_1.ChainId.PlumeMainnet]: {
379
- [exports.addressesRegistry[chain_js_1.ChainId.PlumeMainnet].wNative]: exports.NATIVE_ADDRESS,
382
+ [_addressesRegistry[chain_js_1.ChainId.PlumeMainnet].wNative]: exports.NATIVE_ADDRESS,
380
383
  },
381
384
  [chain_js_1.ChainId.CampMainnet]: {
382
- [exports.addressesRegistry[chain_js_1.ChainId.CampMainnet].wNative]: exports.NATIVE_ADDRESS,
385
+ [_addressesRegistry[chain_js_1.ChainId.CampMainnet].wNative]: exports.NATIVE_ADDRESS,
383
386
  },
384
387
  };
385
388
  function getUnwrappedToken(wrappedToken, chainId) {
386
- return exports.unwrappedTokensMapping[chainId][wrappedToken];
389
+ return exports.unwrappedTokensMapping[chainId]?.[wrappedToken];
387
390
  }
388
391
  /**
389
392
  * The registry of all known ERC20Wrapper tokens.
@@ -395,7 +398,7 @@ exports.erc20WrapperTokens = {};
395
398
  */
396
399
  exports.permissionedWrapperTokens = {
397
400
  [chain_js_1.ChainId.BaseMainnet]: new Set([
398
- exports.addressesRegistry[chain_js_1.ChainId.BaseMainnet].testUsdc,
401
+ _addressesRegistry[chain_js_1.ChainId.BaseMainnet].testUsdc,
399
402
  ]),
400
403
  };
401
404
  /**
@@ -404,8 +407,8 @@ exports.permissionedWrapperTokens = {
404
407
  */
405
408
  exports.permissionedBackedTokens = {
406
409
  [chain_js_1.ChainId.EthMainnet]: new Set([
407
- exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].wbIB01,
408
- exports.addressesRegistry[chain_js_1.ChainId.EthMainnet].wbC3M,
410
+ _addressesRegistry[chain_js_1.ChainId.EthMainnet].wbIB01,
411
+ _addressesRegistry[chain_js_1.ChainId.EthMainnet].wbC3M,
409
412
  ]),
410
413
  };
411
414
  /**
@@ -414,7 +417,7 @@ exports.permissionedBackedTokens = {
414
417
  */
415
418
  exports.permissionedCoinbaseTokens = {
416
419
  [chain_js_1.ChainId.BaseMainnet]: new Set([
417
- exports.addressesRegistry[chain_js_1.ChainId.BaseMainnet].verUsdc,
420
+ _addressesRegistry[chain_js_1.ChainId.BaseMainnet].verUsdc,
418
421
  ]),
419
422
  };
420
423
  const getPermissionedCoinbaseTokens = (chainId) => exports.permissionedCoinbaseTokens[chainId] ?? new Set();
@@ -433,11 +436,52 @@ exports.getPermissionedCoinbaseTokens = getPermissionedCoinbaseTokens;
433
436
  */
434
437
  exports.convexWrapperTokens = {
435
438
  [chain_js_1.ChainId.EthMainnet]: new Set([
436
- exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"],
437
- exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"],
438
- exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"],
439
- exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxTryLSD-morpho"],
440
- exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"],
441
- exports.addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvx2BTC-f-morpho"],
439
+ _addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDTWBTCWETH-morpho"],
440
+ _addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDCWBTCWETH-morpho"],
441
+ _addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvCRVUSDTBTCWSTETH-morpho"],
442
+ _addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxTryLSD-morpho"],
443
+ _addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvxcrvUSDETHCRV-morpho"],
444
+ _addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvx2BTC-f-morpho"],
442
445
  ]),
443
446
  };
447
+ exports.addressesRegistry = (0, morpho_ts_1.deepFreeze)(_addressesRegistry);
448
+ exports.addresses = exports.addressesRegistry;
449
+ exports.unwrappedTokensMapping = (0, morpho_ts_1.deepFreeze)(_unwrappedTokensMapping);
450
+ /**
451
+ * Registers custom addresses and unwrapped token mappings to extend
452
+ * the default address registry (on ewisting or unknown chains).
453
+ *
454
+ * @param options - Optional configuration object
455
+ * @param options.unwrappedTokens - A mapping of chain IDs to token address maps,
456
+ * where each entry maps wrapped tokens to their unwrapped equivalents.
457
+ * @param options.addresses - Custom address entries to merge into the default registry.
458
+ * Can be a subset of `ChainAddresses` if chain is already known.
459
+ * Must provide all required addresses if chain is unknown.
460
+ *
461
+ * @throws {Error} If attempting to override an existing address.
462
+ *
463
+ * @example
464
+ * ```ts
465
+ * registerCustomAddresses({
466
+ * addresses: {
467
+ * 1: { contract: "0xabc..." }
468
+ * },
469
+ * unwrappedTokens: {
470
+ * 1: { "0xWrapped": "0xUnwrapped" }
471
+ * }
472
+ * });
473
+ * ```
474
+ */
475
+ function registerCustomAddresses({ unwrappedTokens, addresses: customAddresses, } = {}) {
476
+ // biome-ignore lint/suspicious/noExplicitAny: type is not trivial and not important here
477
+ const customizer = (objValue, srcValue, key) => {
478
+ if (objValue !== undefined &&
479
+ !(0, lodash_isplainobject_1.default)(objValue) &&
480
+ objValue !== srcValue)
481
+ throw new Error(`Cannot override existing address: ${key}`);
482
+ };
483
+ if (customAddresses)
484
+ exports.addresses = exports.addressesRegistry = (0, morpho_ts_1.deepFreeze)((0, lodash_mergewith_1.default)({}, exports.addressesRegistry, customAddresses, customizer));
485
+ if (unwrappedTokens)
486
+ exports.unwrappedTokensMapping = (0, morpho_ts_1.deepFreeze)((0, lodash_mergewith_1.default)({}, exports.unwrappedTokensMapping, unwrappedTokens, customizer));
487
+ }
@@ -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.wMul(wrappedAmount, index_js_1.MathLib.WAD - slippage, "Down");
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.wMul(unwrappedAmount, index_js_1.MathLib.WAD - slippage, "Up");
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": "3.0.8",
4
+ "version": "4.0.0-next.1",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -18,7 +18,11 @@
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
28
  "@morpho-org/morpho-ts": "^2.3.0"