@morpho-org/blue-sdk 5.23.2 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -680,6 +680,51 @@ declare const _addressesRegistry: {
680
680
  readonly preLiquidationFactory: "0x57C88ACAbd4Fa19257104ECCF64ccA34e5eB8961";
681
681
  readonly wNative: "0x4200000000000000000000000000000000000006";
682
682
  };
683
+ readonly 14: {
684
+ readonly morpho: "0xF4346F5132e810f80a28487a79c7559d9797E8B0";
685
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
686
+ readonly bundler3: {
687
+ readonly bundler3: "0xb371CFee69984D1F3447D49217889C7388bA2027";
688
+ readonly generalAdapter1: "0x43F4861c9E7f584cFDc9B6BA3F0c2462895BDd67";
689
+ };
690
+ readonly adaptiveCurveIrm: "0xE5B5627C5973AfAE1928a6b8e5c1D6AABFEC8a7a";
691
+ readonly vaultV2Factory: "0x6FC83ECc0e8142635D77200e5052be8A0a9D2f42";
692
+ readonly morphoMarketV1AdapterV2Factory: "0xd8237ea1b5974c83C6b0c8942dc2a16F42f789dd";
693
+ readonly registryList: "0x9730d0B30d9145B66a8e09D26295e36cb84F64a9";
694
+ readonly chainlinkOracleFactory: "0x95cB3625598F9abf6cb8B874AA1EfEEbE7822642";
695
+ readonly preLiquidationFactory: "0xf215D05a04b97f98Bb1bF4E0E5Cb97Ef38fa8895";
696
+ readonly wNative: "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d";
697
+ };
698
+ readonly 50: {
699
+ readonly morpho: "0xEa49B0fE898aF913A3826F9f462eE2cDcb854fD9";
700
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
701
+ readonly bundler3: {
702
+ readonly bundler3: "0xed9bdc3E6081db528b6D5CDDf47EcB05337c62A7";
703
+ readonly generalAdapter1: "0xAB2Ab6A8bb1082C5d8400D6206c6A13cE413e0c0";
704
+ };
705
+ readonly adaptiveCurveIrm: "0x15c7312B0f26aa0AA70B24a0D2AF87B9e7D614A0";
706
+ readonly vaultV2Factory: "0x227544d6989cD15c05AAB6dde4F29523dcfdbe2B";
707
+ readonly morphoMarketV1AdapterV2Factory: "0x5C00c99F2235439725417E9f037B7D38FfF35d31";
708
+ readonly registryList: "0x79A8C4e9E502C1867cAf2E7202f0C6b89aaCd5c1";
709
+ readonly chainlinkOracleFactory: "0x6Ad93a3aA829514473D3DF67382894A76c7283B4";
710
+ readonly preLiquidationFactory: "0xe3845262d726a827817C7196143CDa9a4404218d";
711
+ readonly wNative: "0x951857744785E80e2De051c32EE7b25f9c458C42";
712
+ };
713
+ readonly 8217: {
714
+ readonly morpho: "0xA8BEebdca34d83C697c302A0594f3c41f3994cd2";
715
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
716
+ readonly bundler3: {
717
+ readonly bundler3: "0x27880B18ae04a05F1D603B87AEb2a27491FfaBA9";
718
+ readonly generalAdapter1: "0x8e36C2c6d7771820BF14a75f725f3cf0374a7823";
719
+ };
720
+ readonly adaptiveCurveIrm: "0xA4E2bA20Fc64D721D95BD5a28FF71844C5bb5cF2";
721
+ readonly vaultV2Factory: "0xf2Aecd4a4d4C21d08770e34F392C4C271aBD9144";
722
+ readonly morphoMarketV1AdapterV2Factory: "0x4d04C39ca604b560c50F4045c558378FD9AEBCF4";
723
+ readonly registryList: "0xfCA12228DA5fba6E9c0B57a8e8322d0eBaCa03Bc";
724
+ readonly chainlinkOracleFactory: "0x3e89C1071814b2c4170c90260Fcb60B903AD4602";
725
+ readonly preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440";
726
+ readonly wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432";
727
+ };
683
728
  };
684
729
  export type ChainDeployments<Addresses = ChainAddresses> = {
685
730
  [key in keyof Addresses]: Address extends Addresses[key] ? bigint : ChainDeployments<Addresses[key]>;
@@ -1234,6 +1279,51 @@ declare const _deployments: {
1234
1279
  readonly preLiquidationFactory: 7520548n;
1235
1280
  readonly wNative: 0n;
1236
1281
  };
1282
+ readonly 14: {
1283
+ readonly morpho: 52378788n;
1284
+ readonly permit2: 58377404n;
1285
+ readonly bundler3: {
1286
+ readonly bundler3: 52378788n;
1287
+ readonly generalAdapter1: 52378788n;
1288
+ };
1289
+ readonly adaptiveCurveIrm: 52378788n;
1290
+ readonly vaultV2Factory: 52383002n;
1291
+ readonly morphoMarketV1AdapterV2Factory: 52383110n;
1292
+ readonly registryList: 52383110n;
1293
+ readonly chainlinkOracleFactory: 52378931n;
1294
+ readonly preLiquidationFactory: 52378931n;
1295
+ readonly wNative: 39n;
1296
+ };
1297
+ readonly 50: {
1298
+ readonly morpho: 101757515n;
1299
+ readonly permit2: 92945178n;
1300
+ readonly bundler3: {
1301
+ readonly bundler3: 101757515n;
1302
+ readonly generalAdapter1: 101757515n;
1303
+ };
1304
+ readonly adaptiveCurveIrm: 101757515n;
1305
+ readonly vaultV2Factory: 101757669n;
1306
+ readonly morphoMarketV1AdapterV2Factory: 101757823n;
1307
+ readonly registryList: 101757823n;
1308
+ readonly chainlinkOracleFactory: 101757578n;
1309
+ readonly preLiquidationFactory: 101757578n;
1310
+ readonly wNative: 42776215n;
1311
+ };
1312
+ readonly 8217: {
1313
+ readonly morpho: 208021118n;
1314
+ readonly permit2: 188994815n;
1315
+ readonly bundler3: {
1316
+ readonly bundler3: 208021118n;
1317
+ readonly generalAdapter1: 208021118n;
1318
+ };
1319
+ readonly adaptiveCurveIrm: 208021118n;
1320
+ readonly vaultV2Factory: 213463014n;
1321
+ readonly morphoMarketV1AdapterV2Factory: 213463079n;
1322
+ readonly registryList: 213463079n;
1323
+ readonly chainlinkOracleFactory: 213462907n;
1324
+ readonly preLiquidationFactory: 213462907n;
1325
+ readonly wNative: 104802159n;
1326
+ };
1237
1327
  };
1238
1328
  export type AddressLabel = DottedKeys<(typeof _addressesRegistry)[ChainId]>;
1239
1329
  export declare const getChainAddresses: (chainId: number) => ChainAddresses;
@@ -1893,6 +1983,51 @@ export declare let addressesRegistry: {
1893
1983
  readonly preLiquidationFactory: "0x57C88ACAbd4Fa19257104ECCF64ccA34e5eB8961";
1894
1984
  readonly wNative: "0x4200000000000000000000000000000000000006";
1895
1985
  };
1986
+ readonly 14: {
1987
+ readonly morpho: "0xF4346F5132e810f80a28487a79c7559d9797E8B0";
1988
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
1989
+ readonly bundler3: {
1990
+ readonly bundler3: "0xb371CFee69984D1F3447D49217889C7388bA2027";
1991
+ readonly generalAdapter1: "0x43F4861c9E7f584cFDc9B6BA3F0c2462895BDd67";
1992
+ };
1993
+ readonly adaptiveCurveIrm: "0xE5B5627C5973AfAE1928a6b8e5c1D6AABFEC8a7a";
1994
+ readonly vaultV2Factory: "0x6FC83ECc0e8142635D77200e5052be8A0a9D2f42";
1995
+ readonly morphoMarketV1AdapterV2Factory: "0xd8237ea1b5974c83C6b0c8942dc2a16F42f789dd";
1996
+ readonly registryList: "0x9730d0B30d9145B66a8e09D26295e36cb84F64a9";
1997
+ readonly chainlinkOracleFactory: "0x95cB3625598F9abf6cb8B874AA1EfEEbE7822642";
1998
+ readonly preLiquidationFactory: "0xf215D05a04b97f98Bb1bF4E0E5Cb97Ef38fa8895";
1999
+ readonly wNative: "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d";
2000
+ };
2001
+ readonly 50: {
2002
+ readonly morpho: "0xEa49B0fE898aF913A3826F9f462eE2cDcb854fD9";
2003
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
2004
+ readonly bundler3: {
2005
+ readonly bundler3: "0xed9bdc3E6081db528b6D5CDDf47EcB05337c62A7";
2006
+ readonly generalAdapter1: "0xAB2Ab6A8bb1082C5d8400D6206c6A13cE413e0c0";
2007
+ };
2008
+ readonly adaptiveCurveIrm: "0x15c7312B0f26aa0AA70B24a0D2AF87B9e7D614A0";
2009
+ readonly vaultV2Factory: "0x227544d6989cD15c05AAB6dde4F29523dcfdbe2B";
2010
+ readonly morphoMarketV1AdapterV2Factory: "0x5C00c99F2235439725417E9f037B7D38FfF35d31";
2011
+ readonly registryList: "0x79A8C4e9E502C1867cAf2E7202f0C6b89aaCd5c1";
2012
+ readonly chainlinkOracleFactory: "0x6Ad93a3aA829514473D3DF67382894A76c7283B4";
2013
+ readonly preLiquidationFactory: "0xe3845262d726a827817C7196143CDa9a4404218d";
2014
+ readonly wNative: "0x951857744785E80e2De051c32EE7b25f9c458C42";
2015
+ };
2016
+ readonly 8217: {
2017
+ readonly morpho: "0xA8BEebdca34d83C697c302A0594f3c41f3994cd2";
2018
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
2019
+ readonly bundler3: {
2020
+ readonly bundler3: "0x27880B18ae04a05F1D603B87AEb2a27491FfaBA9";
2021
+ readonly generalAdapter1: "0x8e36C2c6d7771820BF14a75f725f3cf0374a7823";
2022
+ };
2023
+ readonly adaptiveCurveIrm: "0xA4E2bA20Fc64D721D95BD5a28FF71844C5bb5cF2";
2024
+ readonly vaultV2Factory: "0xf2Aecd4a4d4C21d08770e34F392C4C271aBD9144";
2025
+ readonly morphoMarketV1AdapterV2Factory: "0x4d04C39ca604b560c50F4045c558378FD9AEBCF4";
2026
+ readonly registryList: "0xfCA12228DA5fba6E9c0B57a8e8322d0eBaCa03Bc";
2027
+ readonly chainlinkOracleFactory: "0x3e89C1071814b2c4170c90260Fcb60B903AD4602";
2028
+ readonly preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440";
2029
+ readonly wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432";
2030
+ };
1896
2031
  };
1897
2032
  export declare let addresses: Record<number, ChainAddresses>;
1898
2033
  export declare let deployments: {
@@ -2445,6 +2580,51 @@ export declare let deployments: {
2445
2580
  readonly preLiquidationFactory: 7520548n;
2446
2581
  readonly wNative: 0n;
2447
2582
  };
2583
+ readonly 14: {
2584
+ readonly morpho: 52378788n;
2585
+ readonly permit2: 58377404n;
2586
+ readonly bundler3: {
2587
+ readonly bundler3: 52378788n;
2588
+ readonly generalAdapter1: 52378788n;
2589
+ };
2590
+ readonly adaptiveCurveIrm: 52378788n;
2591
+ readonly vaultV2Factory: 52383002n;
2592
+ readonly morphoMarketV1AdapterV2Factory: 52383110n;
2593
+ readonly registryList: 52383110n;
2594
+ readonly chainlinkOracleFactory: 52378931n;
2595
+ readonly preLiquidationFactory: 52378931n;
2596
+ readonly wNative: 39n;
2597
+ };
2598
+ readonly 50: {
2599
+ readonly morpho: 101757515n;
2600
+ readonly permit2: 92945178n;
2601
+ readonly bundler3: {
2602
+ readonly bundler3: 101757515n;
2603
+ readonly generalAdapter1: 101757515n;
2604
+ };
2605
+ readonly adaptiveCurveIrm: 101757515n;
2606
+ readonly vaultV2Factory: 101757669n;
2607
+ readonly morphoMarketV1AdapterV2Factory: 101757823n;
2608
+ readonly registryList: 101757823n;
2609
+ readonly chainlinkOracleFactory: 101757578n;
2610
+ readonly preLiquidationFactory: 101757578n;
2611
+ readonly wNative: 42776215n;
2612
+ };
2613
+ readonly 8217: {
2614
+ readonly morpho: 208021118n;
2615
+ readonly permit2: 188994815n;
2616
+ readonly bundler3: {
2617
+ readonly bundler3: 208021118n;
2618
+ readonly generalAdapter1: 208021118n;
2619
+ };
2620
+ readonly adaptiveCurveIrm: 208021118n;
2621
+ readonly vaultV2Factory: 213463014n;
2622
+ readonly morphoMarketV1AdapterV2Factory: 213463079n;
2623
+ readonly registryList: 213463079n;
2624
+ readonly chainlinkOracleFactory: 213462907n;
2625
+ readonly preLiquidationFactory: 213462907n;
2626
+ readonly wNative: 104802159n;
2627
+ };
2448
2628
  };
2449
2629
  export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`, `0x${string}`>>;
2450
2630
  /**
@@ -673,6 +673,51 @@ const _addressesRegistry = {
673
673
  preLiquidationFactory: "0x57C88ACAbd4Fa19257104ECCF64ccA34e5eB8961",
674
674
  wNative: "0x4200000000000000000000000000000000000006",
675
675
  },
676
+ [chain_js_1.ChainId.FlareMainnet]: {
677
+ morpho: "0xF4346F5132e810f80a28487a79c7559d9797E8B0",
678
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
679
+ bundler3: {
680
+ bundler3: "0xb371CFee69984D1F3447D49217889C7388bA2027",
681
+ generalAdapter1: "0x43F4861c9E7f584cFDc9B6BA3F0c2462895BDd67",
682
+ },
683
+ adaptiveCurveIrm: "0xE5B5627C5973AfAE1928a6b8e5c1D6AABFEC8a7a",
684
+ vaultV2Factory: "0x6FC83ECc0e8142635D77200e5052be8A0a9D2f42",
685
+ morphoMarketV1AdapterV2Factory: "0xd8237ea1b5974c83C6b0c8942dc2a16F42f789dd",
686
+ registryList: "0x9730d0B30d9145B66a8e09D26295e36cb84F64a9",
687
+ chainlinkOracleFactory: "0x95cB3625598F9abf6cb8B874AA1EfEEbE7822642",
688
+ preLiquidationFactory: "0xf215D05a04b97f98Bb1bF4E0E5Cb97Ef38fa8895",
689
+ wNative: "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d",
690
+ },
691
+ [chain_js_1.ChainId.XdcMainnet]: {
692
+ morpho: "0xEa49B0fE898aF913A3826F9f462eE2cDcb854fD9",
693
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
694
+ bundler3: {
695
+ bundler3: "0xed9bdc3E6081db528b6D5CDDf47EcB05337c62A7",
696
+ generalAdapter1: "0xAB2Ab6A8bb1082C5d8400D6206c6A13cE413e0c0",
697
+ },
698
+ adaptiveCurveIrm: "0x15c7312B0f26aa0AA70B24a0D2AF87B9e7D614A0",
699
+ vaultV2Factory: "0x227544d6989cD15c05AAB6dde4F29523dcfdbe2B",
700
+ morphoMarketV1AdapterV2Factory: "0x5C00c99F2235439725417E9f037B7D38FfF35d31",
701
+ registryList: "0x79A8C4e9E502C1867cAf2E7202f0C6b89aaCd5c1",
702
+ chainlinkOracleFactory: "0x6Ad93a3aA829514473D3DF67382894A76c7283B4",
703
+ preLiquidationFactory: "0xe3845262d726a827817C7196143CDa9a4404218d",
704
+ wNative: "0x951857744785E80e2De051c32EE7b25f9c458C42",
705
+ },
706
+ [chain_js_1.ChainId.KaiaMainnet]: {
707
+ morpho: "0xA8BEebdca34d83C697c302A0594f3c41f3994cd2",
708
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
709
+ bundler3: {
710
+ bundler3: "0x27880B18ae04a05F1D603B87AEb2a27491FfaBA9",
711
+ generalAdapter1: "0x8e36C2c6d7771820BF14a75f725f3cf0374a7823",
712
+ },
713
+ adaptiveCurveIrm: "0xA4E2bA20Fc64D721D95BD5a28FF71844C5bb5cF2",
714
+ vaultV2Factory: "0xf2Aecd4a4d4C21d08770e34F392C4C271aBD9144",
715
+ morphoMarketV1AdapterV2Factory: "0x4d04C39ca604b560c50F4045c558378FD9AEBCF4",
716
+ registryList: "0xfCA12228DA5fba6E9c0B57a8e8322d0eBaCa03Bc",
717
+ chainlinkOracleFactory: "0x3e89C1071814b2c4170c90260Fcb60B903AD4602",
718
+ preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440",
719
+ wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432",
720
+ },
676
721
  };
677
722
  const _deployments = {
678
723
  [chain_js_1.ChainId.EthMainnet]: {
@@ -1224,6 +1269,51 @@ const _deployments = {
1224
1269
  preLiquidationFactory: 7520548n,
1225
1270
  wNative: 0n,
1226
1271
  },
1272
+ [chain_js_1.ChainId.FlareMainnet]: {
1273
+ morpho: 52378788n,
1274
+ permit2: 58377404n,
1275
+ bundler3: {
1276
+ bundler3: 52378788n,
1277
+ generalAdapter1: 52378788n,
1278
+ },
1279
+ adaptiveCurveIrm: 52378788n,
1280
+ vaultV2Factory: 52383002n,
1281
+ morphoMarketV1AdapterV2Factory: 52383110n,
1282
+ registryList: 52383110n,
1283
+ chainlinkOracleFactory: 52378931n,
1284
+ preLiquidationFactory: 52378931n,
1285
+ wNative: 39n,
1286
+ },
1287
+ [chain_js_1.ChainId.XdcMainnet]: {
1288
+ morpho: 101757515n,
1289
+ permit2: 92945178n,
1290
+ bundler3: {
1291
+ bundler3: 101757515n,
1292
+ generalAdapter1: 101757515n,
1293
+ },
1294
+ adaptiveCurveIrm: 101757515n,
1295
+ vaultV2Factory: 101757669n,
1296
+ morphoMarketV1AdapterV2Factory: 101757823n,
1297
+ registryList: 101757823n,
1298
+ chainlinkOracleFactory: 101757578n,
1299
+ preLiquidationFactory: 101757578n,
1300
+ wNative: 42776215n,
1301
+ },
1302
+ [chain_js_1.ChainId.KaiaMainnet]: {
1303
+ morpho: 208021118n,
1304
+ permit2: 188994815n,
1305
+ bundler3: {
1306
+ bundler3: 208021118n,
1307
+ generalAdapter1: 208021118n,
1308
+ },
1309
+ adaptiveCurveIrm: 208021118n,
1310
+ vaultV2Factory: 213463014n,
1311
+ morphoMarketV1AdapterV2Factory: 213463079n,
1312
+ registryList: 213463079n,
1313
+ chainlinkOracleFactory: 213462907n,
1314
+ preLiquidationFactory: 213462907n,
1315
+ wNative: 104802159n,
1316
+ },
1227
1317
  };
1228
1318
  const getChainAddresses = (chainId) => {
1229
1319
  const chainAddresses = exports.addresses[chainId];
@@ -1345,6 +1435,15 @@ const _unwrappedTokensMapping = {
1345
1435
  [chain_js_1.ChainId.GensynMainnet]: {
1346
1436
  [_addressesRegistry[chain_js_1.ChainId.GensynMainnet].wNative]: exports.NATIVE_ADDRESS,
1347
1437
  },
1438
+ [chain_js_1.ChainId.FlareMainnet]: {
1439
+ [_addressesRegistry[chain_js_1.ChainId.FlareMainnet].wNative]: exports.NATIVE_ADDRESS,
1440
+ },
1441
+ [chain_js_1.ChainId.XdcMainnet]: {
1442
+ [_addressesRegistry[chain_js_1.ChainId.XdcMainnet].wNative]: exports.NATIVE_ADDRESS,
1443
+ },
1444
+ [chain_js_1.ChainId.KaiaMainnet]: {
1445
+ [_addressesRegistry[chain_js_1.ChainId.KaiaMainnet].wNative]: exports.NATIVE_ADDRESS,
1446
+ },
1348
1447
  };
1349
1448
  function getUnwrappedToken(wrappedToken, chainId) {
1350
1449
  return exports.unwrappedTokensMapping[chainId]?.[wrappedToken];
@@ -34,7 +34,10 @@ export declare enum ChainId {
34
34
  TempoMainnet = 4217,
35
35
  EdenMainnet = 714,
36
36
  PharosMainnet = 1672,
37
- GensynMainnet = 685689
37
+ GensynMainnet = 685689,
38
+ FlareMainnet = 14,
39
+ XdcMainnet = 50,
40
+ KaiaMainnet = 8217
38
41
  }
39
42
  export interface ChainMetadata {
40
43
  readonly name: string;
@@ -453,5 +456,38 @@ export declare namespace ChainUtils {
453
456
  explorerUrl: string;
454
457
  identifier: string;
455
458
  };
459
+ 14: {
460
+ name: string;
461
+ id: ChainId.FlareMainnet;
462
+ nativeCurrency: {
463
+ name: string;
464
+ symbol: string;
465
+ decimals: number;
466
+ };
467
+ explorerUrl: string;
468
+ identifier: string;
469
+ };
470
+ 50: {
471
+ name: string;
472
+ id: ChainId.XdcMainnet;
473
+ nativeCurrency: {
474
+ name: string;
475
+ symbol: string;
476
+ decimals: number;
477
+ };
478
+ explorerUrl: string;
479
+ identifier: string;
480
+ };
481
+ 8217: {
482
+ name: string;
483
+ id: ChainId.KaiaMainnet;
484
+ nativeCurrency: {
485
+ name: string;
486
+ symbol: string;
487
+ decimals: number;
488
+ };
489
+ explorerUrl: string;
490
+ identifier: string;
491
+ };
456
492
  };
457
493
  }
package/lib/cjs/chain.js CHANGED
@@ -39,6 +39,9 @@ var ChainId;
39
39
  ChainId[ChainId["EdenMainnet"] = 714] = "EdenMainnet";
40
40
  ChainId[ChainId["PharosMainnet"] = 1672] = "PharosMainnet";
41
41
  ChainId[ChainId["GensynMainnet"] = 685689] = "GensynMainnet";
42
+ ChainId[ChainId["FlareMainnet"] = 14] = "FlareMainnet";
43
+ ChainId[ChainId["XdcMainnet"] = 50] = "XdcMainnet";
44
+ ChainId[ChainId["KaiaMainnet"] = 8217] = "KaiaMainnet";
42
45
  })(ChainId || (exports.ChainId = ChainId = {}));
43
46
  var ChainUtils;
44
47
  (function (ChainUtils) {
@@ -312,5 +315,26 @@ var ChainUtils;
312
315
  explorerUrl: "https://gensyn-mainnet.explorer.alchemy.com",
313
316
  identifier: "gensyn",
314
317
  },
318
+ [ChainId.FlareMainnet]: {
319
+ name: "Flare",
320
+ id: ChainId.FlareMainnet,
321
+ nativeCurrency: { name: "Flare", symbol: "FLR", decimals: 18 },
322
+ explorerUrl: "https://mainnet.flarescan.com",
323
+ identifier: "flare",
324
+ },
325
+ [ChainId.XdcMainnet]: {
326
+ name: "XDC",
327
+ id: ChainId.XdcMainnet,
328
+ nativeCurrency: { name: "XDC", symbol: "XDC", decimals: 18 },
329
+ explorerUrl: "https://xdcscan.com",
330
+ identifier: "xdc",
331
+ },
332
+ [ChainId.KaiaMainnet]: {
333
+ name: "Kaia",
334
+ id: ChainId.KaiaMainnet,
335
+ nativeCurrency: { name: "Kaia", symbol: "KAIA", decimals: 18 },
336
+ explorerUrl: "https://kaiascan.io",
337
+ identifier: "kaia",
338
+ },
315
339
  };
316
340
  })(ChainUtils || (exports.ChainUtils = ChainUtils = {}));
@@ -34,11 +34,35 @@ export declare namespace MarketUtils {
34
34
  /**
35
35
  * Returns the interest accrued on both sides of the given market
36
36
  * as well as the supply shares minted to the fee recipient.
37
+ *
38
+ * Fee shares are converted from the fee amount against post-interest supply assets minus the fee amount,
39
+ * matching Morpho Blue's onchain accrual.
40
+ *
37
41
  * @param borrowRate The average borrow rate since the last market update (scaled by WAD).
38
- * @param market The market state.
42
+ * @param market.totalSupplyAssets The market's total supplied assets before accrual.
43
+ * @param market.totalBorrowAssets The market's total borrowed assets before accrual.
44
+ * @param market.totalSupplyShares The market's total supply shares before fee shares are minted.
45
+ * @param market.fee The market fee percentage, scaled by WAD.
39
46
  * @param elapsed The time elapsed since the last market update (in seconds).
47
+ * @returns The accrued interest and the supply shares minted to the fee recipient.
48
+ * @example
49
+ * ```ts
50
+ * import { MarketUtils, MathLib } from "@morpho-org/blue-sdk";
51
+ *
52
+ * const { interest, feeShares } = MarketUtils.getAccruedInterest(
53
+ * 5_0000000000000000n,
54
+ * {
55
+ * totalSupplyAssets: 1_000_000n * MathLib.WAD,
56
+ * totalBorrowAssets: 800_000n * MathLib.WAD,
57
+ * totalSupplyShares: 1_100_000n * MathLib.WAD,
58
+ * fee: 10_0000000000000000n,
59
+ * },
60
+ * 1n,
61
+ * );
62
+ * // { interest, feeShares } satisfies { interest: bigint; feeShares: bigint }
63
+ * ```
40
64
  */
41
- function getAccruedInterest(borrowRate: BigIntish, { totalSupplyAssets, totalBorrowAssets, totalSupplyShares, fee, }: {
65
+ function getAccruedInterest(borrowRate: BigIntish, market: {
42
66
  totalSupplyAssets: BigIntish;
43
67
  totalBorrowAssets: BigIntish;
44
68
  totalSupplyShares: BigIntish;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MarketUtils = void 0;
4
- const sha3_1 = require("@noble/hashes/sha3");
5
- const utils_1 = require("@noble/hashes/utils");
4
+ const sha3_js_1 = require("@noble/hashes/sha3.js");
5
+ const utils_js_1 = require("@noble/hashes/utils.js");
6
6
  const viem_1 = require("viem");
7
7
  const constants_js_1 = require("../constants.js");
8
8
  const index_js_1 = require("../math/index.js");
@@ -16,7 +16,7 @@ var MarketUtils;
16
16
  * @param market The market params.
17
17
  */
18
18
  function getMarketId(market) {
19
- return `0x${(0, utils_1.bytesToHex)((0, sha3_1.keccak_256)((0, utils_1.hexToBytes)(`${market.loanToken.substring(2).toLowerCase().padStart(64, "0") +
19
+ return `0x${(0, utils_js_1.bytesToHex)((0, sha3_js_1.keccak_256)((0, utils_js_1.hexToBytes)(`${market.loanToken.substring(2).toLowerCase().padStart(64, "0") +
20
20
  market.collateralToken
21
21
  .substring(2)
22
22
  .toLowerCase()
@@ -62,16 +62,41 @@ var MarketUtils;
62
62
  /**
63
63
  * Returns the interest accrued on both sides of the given market
64
64
  * as well as the supply shares minted to the fee recipient.
65
+ *
66
+ * Fee shares are converted from the fee amount against post-interest supply assets minus the fee amount,
67
+ * matching Morpho Blue's onchain accrual.
68
+ *
65
69
  * @param borrowRate The average borrow rate since the last market update (scaled by WAD).
66
- * @param market The market state.
70
+ * @param market.totalSupplyAssets The market's total supplied assets before accrual.
71
+ * @param market.totalBorrowAssets The market's total borrowed assets before accrual.
72
+ * @param market.totalSupplyShares The market's total supply shares before fee shares are minted.
73
+ * @param market.fee The market fee percentage, scaled by WAD.
67
74
  * @param elapsed The time elapsed since the last market update (in seconds).
75
+ * @returns The accrued interest and the supply shares minted to the fee recipient.
76
+ * @example
77
+ * ```ts
78
+ * import { MarketUtils, MathLib } from "@morpho-org/blue-sdk";
79
+ *
80
+ * const { interest, feeShares } = MarketUtils.getAccruedInterest(
81
+ * 5_0000000000000000n,
82
+ * {
83
+ * totalSupplyAssets: 1_000_000n * MathLib.WAD,
84
+ * totalBorrowAssets: 800_000n * MathLib.WAD,
85
+ * totalSupplyShares: 1_100_000n * MathLib.WAD,
86
+ * fee: 10_0000000000000000n,
87
+ * },
88
+ * 1n,
89
+ * );
90
+ * // { interest, feeShares } satisfies { interest: bigint; feeShares: bigint }
91
+ * ```
68
92
  */
69
93
  // biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
70
- function getAccruedInterest(borrowRate, { totalSupplyAssets, totalBorrowAssets, totalSupplyShares, fee, }, elapsed = 0n) {
94
+ function getAccruedInterest(borrowRate, market, elapsed = 0n) {
95
+ const { totalSupplyAssets, totalBorrowAssets, totalSupplyShares, fee } = market;
71
96
  const interest = index_js_1.MathLib.wMulDown(totalBorrowAssets, index_js_1.MathLib.wTaylorCompounded(borrowRate, elapsed));
72
97
  const feeAmount = index_js_1.MathLib.wMulDown(interest, fee);
73
98
  const feeShares = toSupplyShares(feeAmount, {
74
- totalSupplyAssets: BigInt(totalSupplyAssets) - feeAmount,
99
+ totalSupplyAssets: BigInt(totalSupplyAssets) + interest - feeAmount,
75
100
  totalSupplyShares,
76
101
  }, "Down");
77
102
  return { interest, feeShares };
@@ -44,6 +44,7 @@ export declare class PreLiquidationPosition extends AccrualPosition implements I
44
44
  constructor({ preLiquidationParams, preLiquidation, preLiquidationOraclePrice, ...position }: IPreLiquidationPosition, market: IMarket);
45
45
  get market(): Market;
46
46
  protected get _lltv(): bigint;
47
+ accrueInterest(timestamp?: BigIntish): PreLiquidationPosition;
47
48
  /**
48
49
  * @inheritdoc `undefined` if the pre-liquidation's oracle reverts.
49
50
  * `undefined` if it may be liquidatable on Morpho.
@@ -56,6 +56,14 @@ class PreLiquidationPosition extends Position_js_1.AccrualPosition {
56
56
  get _lltv() {
57
57
  return this._baseMarket.params.lltv;
58
58
  }
59
+ accrueInterest(timestamp) {
60
+ return new PreLiquidationPosition({
61
+ ...this,
62
+ preLiquidationParams: this.preLiquidationParams,
63
+ preLiquidation: this.preLiquidation,
64
+ preLiquidationOraclePrice: this.preLiquidationOraclePrice,
65
+ }, this._baseMarket.accrueInterest(timestamp));
66
+ }
59
67
  /**
60
68
  * @inheritdoc `undefined` if the pre-liquidation's oracle reverts.
61
69
  * `undefined` if it may be liquidatable on Morpho.
@@ -13,11 +13,7 @@ export interface IVaultV2Allocation {
13
13
  export interface IVaultV2 extends IToken {
14
14
  asset: Address;
15
15
  /**
16
- * The total assets, *including* virtually accrued interest.
17
- */
18
- totalAssets: bigint;
19
- /**
20
- * The total assets, *excluding* virtually accrued interest.
16
+ * Stored total assets at `lastUpdate`, excluding virtually accrued interest.
21
17
  */
22
18
  _totalAssets: bigint;
23
19
  /**
@@ -38,7 +34,6 @@ export interface IVaultV2 extends IToken {
38
34
  }
39
35
  export declare class VaultV2 extends WrappedToken implements IVaultV2 {
40
36
  readonly asset: Address;
41
- totalAssets: bigint;
42
37
  _totalAssets: bigint;
43
38
  totalSupply: bigint;
44
39
  virtualShares: bigint;
@@ -52,7 +47,7 @@ export declare class VaultV2 extends WrappedToken implements IVaultV2 {
52
47
  managementFee: bigint;
53
48
  performanceFeeRecipient: `0x${string}`;
54
49
  managementFeeRecipient: `0x${string}`;
55
- constructor({ asset, totalAssets, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
50
+ constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
56
51
  toAssets(shares: BigIntish): bigint;
57
52
  toShares(assets: BigIntish): bigint;
58
53
  protected _wrap(amount: BigIntish, rounding: RoundingDirection): bigint;
@@ -8,7 +8,6 @@ const index_js_2 = require("../../token/index.js");
8
8
  const utils_js_1 = require("../../utils.js");
9
9
  class VaultV2 extends index_js_2.WrappedToken {
10
10
  asset;
11
- totalAssets;
12
11
  _totalAssets;
13
12
  totalSupply;
14
13
  virtualShares;
@@ -22,10 +21,9 @@ class VaultV2 extends index_js_2.WrappedToken {
22
21
  managementFee;
23
22
  performanceFeeRecipient;
24
23
  managementFeeRecipient;
25
- constructor({ asset, totalAssets, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }) {
24
+ constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }) {
26
25
  super(config, asset);
27
26
  this.asset = asset;
28
- this.totalAssets = totalAssets;
29
27
  this._totalAssets = _totalAssets;
30
28
  this.totalSupply = totalSupply;
31
29
  this.virtualShares = virtualShares;
@@ -47,10 +45,11 @@ class VaultV2 extends index_js_2.WrappedToken {
47
45
  return this._wrap(assets, "Down");
48
46
  }
49
47
  _wrap(amount, rounding) {
50
- return index_js_1.MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this.totalAssets + 1n, rounding);
48
+ // Pair pre-accrue `_totalAssets` with pre-accrue `totalSupply`; call `AccrualVaultV2.accrueInterest` for post-accrue math.
49
+ return index_js_1.MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this._totalAssets + 1n, rounding);
51
50
  }
52
51
  _unwrap(amount, rounding) {
53
- return index_js_1.MathLib.mulDiv(amount, this.totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
52
+ return index_js_1.MathLib.mulDiv(amount, this._totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
54
53
  }
55
54
  }
56
55
  exports.VaultV2 = VaultV2;
@@ -94,8 +93,8 @@ class AccrualVaultV2 extends VaultV2 {
94
93
  limiter: utils_js_1.CapacityLimitReason.vaultV2_absoluteCap,
95
94
  };
96
95
  if (relativeCap !== index_js_1.MathLib.WAD) {
97
- // `relativeCap` can be set lower than `allocation / totalAssets`.
98
- const relativeMaxDeposit = index_js_1.MathLib.zeroFloorSub(index_js_1.MathLib.wMulDown(this.totalAssets, relativeCap), allocation);
96
+ // `relativeCap` can be set lower than `allocation / _totalAssets`.
97
+ const relativeMaxDeposit = index_js_1.MathLib.zeroFloorSub(index_js_1.MathLib.wMulDown(this._totalAssets, relativeCap), allocation);
99
98
  if (liquidityAdapterLimit.value > relativeMaxDeposit)
100
99
  liquidityAdapterLimit = {
101
100
  value: relativeMaxDeposit,
@@ -153,7 +152,6 @@ class AccrualVaultV2 extends VaultV2 {
153
152
  const newTotalAssetsWithoutFees = newTotalAssets - performanceFeeAssets - managementFeeAssets;
154
153
  const performanceFeeShares = index_js_1.MathLib.mulDivDown(performanceFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
155
154
  const managementFeeShares = index_js_1.MathLib.mulDivDown(managementFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
156
- vault.totalAssets = newTotalAssets;
157
155
  vault._totalAssets = newTotalAssets;
158
156
  if (performanceFeeShares)
159
157
  vault.totalSupply += performanceFeeShares;
@@ -680,6 +680,51 @@ declare const _addressesRegistry: {
680
680
  readonly preLiquidationFactory: "0x57C88ACAbd4Fa19257104ECCF64ccA34e5eB8961";
681
681
  readonly wNative: "0x4200000000000000000000000000000000000006";
682
682
  };
683
+ readonly 14: {
684
+ readonly morpho: "0xF4346F5132e810f80a28487a79c7559d9797E8B0";
685
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
686
+ readonly bundler3: {
687
+ readonly bundler3: "0xb371CFee69984D1F3447D49217889C7388bA2027";
688
+ readonly generalAdapter1: "0x43F4861c9E7f584cFDc9B6BA3F0c2462895BDd67";
689
+ };
690
+ readonly adaptiveCurveIrm: "0xE5B5627C5973AfAE1928a6b8e5c1D6AABFEC8a7a";
691
+ readonly vaultV2Factory: "0x6FC83ECc0e8142635D77200e5052be8A0a9D2f42";
692
+ readonly morphoMarketV1AdapterV2Factory: "0xd8237ea1b5974c83C6b0c8942dc2a16F42f789dd";
693
+ readonly registryList: "0x9730d0B30d9145B66a8e09D26295e36cb84F64a9";
694
+ readonly chainlinkOracleFactory: "0x95cB3625598F9abf6cb8B874AA1EfEEbE7822642";
695
+ readonly preLiquidationFactory: "0xf215D05a04b97f98Bb1bF4E0E5Cb97Ef38fa8895";
696
+ readonly wNative: "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d";
697
+ };
698
+ readonly 50: {
699
+ readonly morpho: "0xEa49B0fE898aF913A3826F9f462eE2cDcb854fD9";
700
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
701
+ readonly bundler3: {
702
+ readonly bundler3: "0xed9bdc3E6081db528b6D5CDDf47EcB05337c62A7";
703
+ readonly generalAdapter1: "0xAB2Ab6A8bb1082C5d8400D6206c6A13cE413e0c0";
704
+ };
705
+ readonly adaptiveCurveIrm: "0x15c7312B0f26aa0AA70B24a0D2AF87B9e7D614A0";
706
+ readonly vaultV2Factory: "0x227544d6989cD15c05AAB6dde4F29523dcfdbe2B";
707
+ readonly morphoMarketV1AdapterV2Factory: "0x5C00c99F2235439725417E9f037B7D38FfF35d31";
708
+ readonly registryList: "0x79A8C4e9E502C1867cAf2E7202f0C6b89aaCd5c1";
709
+ readonly chainlinkOracleFactory: "0x6Ad93a3aA829514473D3DF67382894A76c7283B4";
710
+ readonly preLiquidationFactory: "0xe3845262d726a827817C7196143CDa9a4404218d";
711
+ readonly wNative: "0x951857744785E80e2De051c32EE7b25f9c458C42";
712
+ };
713
+ readonly 8217: {
714
+ readonly morpho: "0xA8BEebdca34d83C697c302A0594f3c41f3994cd2";
715
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
716
+ readonly bundler3: {
717
+ readonly bundler3: "0x27880B18ae04a05F1D603B87AEb2a27491FfaBA9";
718
+ readonly generalAdapter1: "0x8e36C2c6d7771820BF14a75f725f3cf0374a7823";
719
+ };
720
+ readonly adaptiveCurveIrm: "0xA4E2bA20Fc64D721D95BD5a28FF71844C5bb5cF2";
721
+ readonly vaultV2Factory: "0xf2Aecd4a4d4C21d08770e34F392C4C271aBD9144";
722
+ readonly morphoMarketV1AdapterV2Factory: "0x4d04C39ca604b560c50F4045c558378FD9AEBCF4";
723
+ readonly registryList: "0xfCA12228DA5fba6E9c0B57a8e8322d0eBaCa03Bc";
724
+ readonly chainlinkOracleFactory: "0x3e89C1071814b2c4170c90260Fcb60B903AD4602";
725
+ readonly preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440";
726
+ readonly wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432";
727
+ };
683
728
  };
684
729
  export type ChainDeployments<Addresses = ChainAddresses> = {
685
730
  [key in keyof Addresses]: Address extends Addresses[key] ? bigint : ChainDeployments<Addresses[key]>;
@@ -1234,6 +1279,51 @@ declare const _deployments: {
1234
1279
  readonly preLiquidationFactory: 7520548n;
1235
1280
  readonly wNative: 0n;
1236
1281
  };
1282
+ readonly 14: {
1283
+ readonly morpho: 52378788n;
1284
+ readonly permit2: 58377404n;
1285
+ readonly bundler3: {
1286
+ readonly bundler3: 52378788n;
1287
+ readonly generalAdapter1: 52378788n;
1288
+ };
1289
+ readonly adaptiveCurveIrm: 52378788n;
1290
+ readonly vaultV2Factory: 52383002n;
1291
+ readonly morphoMarketV1AdapterV2Factory: 52383110n;
1292
+ readonly registryList: 52383110n;
1293
+ readonly chainlinkOracleFactory: 52378931n;
1294
+ readonly preLiquidationFactory: 52378931n;
1295
+ readonly wNative: 39n;
1296
+ };
1297
+ readonly 50: {
1298
+ readonly morpho: 101757515n;
1299
+ readonly permit2: 92945178n;
1300
+ readonly bundler3: {
1301
+ readonly bundler3: 101757515n;
1302
+ readonly generalAdapter1: 101757515n;
1303
+ };
1304
+ readonly adaptiveCurveIrm: 101757515n;
1305
+ readonly vaultV2Factory: 101757669n;
1306
+ readonly morphoMarketV1AdapterV2Factory: 101757823n;
1307
+ readonly registryList: 101757823n;
1308
+ readonly chainlinkOracleFactory: 101757578n;
1309
+ readonly preLiquidationFactory: 101757578n;
1310
+ readonly wNative: 42776215n;
1311
+ };
1312
+ readonly 8217: {
1313
+ readonly morpho: 208021118n;
1314
+ readonly permit2: 188994815n;
1315
+ readonly bundler3: {
1316
+ readonly bundler3: 208021118n;
1317
+ readonly generalAdapter1: 208021118n;
1318
+ };
1319
+ readonly adaptiveCurveIrm: 208021118n;
1320
+ readonly vaultV2Factory: 213463014n;
1321
+ readonly morphoMarketV1AdapterV2Factory: 213463079n;
1322
+ readonly registryList: 213463079n;
1323
+ readonly chainlinkOracleFactory: 213462907n;
1324
+ readonly preLiquidationFactory: 213462907n;
1325
+ readonly wNative: 104802159n;
1326
+ };
1237
1327
  };
1238
1328
  export type AddressLabel = DottedKeys<(typeof _addressesRegistry)[ChainId]>;
1239
1329
  export declare const getChainAddresses: (chainId: number) => ChainAddresses;
@@ -1893,6 +1983,51 @@ export declare let addressesRegistry: {
1893
1983
  readonly preLiquidationFactory: "0x57C88ACAbd4Fa19257104ECCF64ccA34e5eB8961";
1894
1984
  readonly wNative: "0x4200000000000000000000000000000000000006";
1895
1985
  };
1986
+ readonly 14: {
1987
+ readonly morpho: "0xF4346F5132e810f80a28487a79c7559d9797E8B0";
1988
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
1989
+ readonly bundler3: {
1990
+ readonly bundler3: "0xb371CFee69984D1F3447D49217889C7388bA2027";
1991
+ readonly generalAdapter1: "0x43F4861c9E7f584cFDc9B6BA3F0c2462895BDd67";
1992
+ };
1993
+ readonly adaptiveCurveIrm: "0xE5B5627C5973AfAE1928a6b8e5c1D6AABFEC8a7a";
1994
+ readonly vaultV2Factory: "0x6FC83ECc0e8142635D77200e5052be8A0a9D2f42";
1995
+ readonly morphoMarketV1AdapterV2Factory: "0xd8237ea1b5974c83C6b0c8942dc2a16F42f789dd";
1996
+ readonly registryList: "0x9730d0B30d9145B66a8e09D26295e36cb84F64a9";
1997
+ readonly chainlinkOracleFactory: "0x95cB3625598F9abf6cb8B874AA1EfEEbE7822642";
1998
+ readonly preLiquidationFactory: "0xf215D05a04b97f98Bb1bF4E0E5Cb97Ef38fa8895";
1999
+ readonly wNative: "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d";
2000
+ };
2001
+ readonly 50: {
2002
+ readonly morpho: "0xEa49B0fE898aF913A3826F9f462eE2cDcb854fD9";
2003
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
2004
+ readonly bundler3: {
2005
+ readonly bundler3: "0xed9bdc3E6081db528b6D5CDDf47EcB05337c62A7";
2006
+ readonly generalAdapter1: "0xAB2Ab6A8bb1082C5d8400D6206c6A13cE413e0c0";
2007
+ };
2008
+ readonly adaptiveCurveIrm: "0x15c7312B0f26aa0AA70B24a0D2AF87B9e7D614A0";
2009
+ readonly vaultV2Factory: "0x227544d6989cD15c05AAB6dde4F29523dcfdbe2B";
2010
+ readonly morphoMarketV1AdapterV2Factory: "0x5C00c99F2235439725417E9f037B7D38FfF35d31";
2011
+ readonly registryList: "0x79A8C4e9E502C1867cAf2E7202f0C6b89aaCd5c1";
2012
+ readonly chainlinkOracleFactory: "0x6Ad93a3aA829514473D3DF67382894A76c7283B4";
2013
+ readonly preLiquidationFactory: "0xe3845262d726a827817C7196143CDa9a4404218d";
2014
+ readonly wNative: "0x951857744785E80e2De051c32EE7b25f9c458C42";
2015
+ };
2016
+ readonly 8217: {
2017
+ readonly morpho: "0xA8BEebdca34d83C697c302A0594f3c41f3994cd2";
2018
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
2019
+ readonly bundler3: {
2020
+ readonly bundler3: "0x27880B18ae04a05F1D603B87AEb2a27491FfaBA9";
2021
+ readonly generalAdapter1: "0x8e36C2c6d7771820BF14a75f725f3cf0374a7823";
2022
+ };
2023
+ readonly adaptiveCurveIrm: "0xA4E2bA20Fc64D721D95BD5a28FF71844C5bb5cF2";
2024
+ readonly vaultV2Factory: "0xf2Aecd4a4d4C21d08770e34F392C4C271aBD9144";
2025
+ readonly morphoMarketV1AdapterV2Factory: "0x4d04C39ca604b560c50F4045c558378FD9AEBCF4";
2026
+ readonly registryList: "0xfCA12228DA5fba6E9c0B57a8e8322d0eBaCa03Bc";
2027
+ readonly chainlinkOracleFactory: "0x3e89C1071814b2c4170c90260Fcb60B903AD4602";
2028
+ readonly preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440";
2029
+ readonly wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432";
2030
+ };
1896
2031
  };
1897
2032
  export declare let addresses: Record<number, ChainAddresses>;
1898
2033
  export declare let deployments: {
@@ -2445,6 +2580,51 @@ export declare let deployments: {
2445
2580
  readonly preLiquidationFactory: 7520548n;
2446
2581
  readonly wNative: 0n;
2447
2582
  };
2583
+ readonly 14: {
2584
+ readonly morpho: 52378788n;
2585
+ readonly permit2: 58377404n;
2586
+ readonly bundler3: {
2587
+ readonly bundler3: 52378788n;
2588
+ readonly generalAdapter1: 52378788n;
2589
+ };
2590
+ readonly adaptiveCurveIrm: 52378788n;
2591
+ readonly vaultV2Factory: 52383002n;
2592
+ readonly morphoMarketV1AdapterV2Factory: 52383110n;
2593
+ readonly registryList: 52383110n;
2594
+ readonly chainlinkOracleFactory: 52378931n;
2595
+ readonly preLiquidationFactory: 52378931n;
2596
+ readonly wNative: 39n;
2597
+ };
2598
+ readonly 50: {
2599
+ readonly morpho: 101757515n;
2600
+ readonly permit2: 92945178n;
2601
+ readonly bundler3: {
2602
+ readonly bundler3: 101757515n;
2603
+ readonly generalAdapter1: 101757515n;
2604
+ };
2605
+ readonly adaptiveCurveIrm: 101757515n;
2606
+ readonly vaultV2Factory: 101757669n;
2607
+ readonly morphoMarketV1AdapterV2Factory: 101757823n;
2608
+ readonly registryList: 101757823n;
2609
+ readonly chainlinkOracleFactory: 101757578n;
2610
+ readonly preLiquidationFactory: 101757578n;
2611
+ readonly wNative: 42776215n;
2612
+ };
2613
+ readonly 8217: {
2614
+ readonly morpho: 208021118n;
2615
+ readonly permit2: 188994815n;
2616
+ readonly bundler3: {
2617
+ readonly bundler3: 208021118n;
2618
+ readonly generalAdapter1: 208021118n;
2619
+ };
2620
+ readonly adaptiveCurveIrm: 208021118n;
2621
+ readonly vaultV2Factory: 213463014n;
2622
+ readonly morphoMarketV1AdapterV2Factory: 213463079n;
2623
+ readonly registryList: 213463079n;
2624
+ readonly chainlinkOracleFactory: 213462907n;
2625
+ readonly preLiquidationFactory: 213462907n;
2626
+ readonly wNative: 104802159n;
2627
+ };
2448
2628
  };
2449
2629
  export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`, `0x${string}`>>;
2450
2630
  /**
@@ -665,6 +665,51 @@ const _addressesRegistry = {
665
665
  preLiquidationFactory: "0x57C88ACAbd4Fa19257104ECCF64ccA34e5eB8961",
666
666
  wNative: "0x4200000000000000000000000000000000000006",
667
667
  },
668
+ [ChainId.FlareMainnet]: {
669
+ morpho: "0xF4346F5132e810f80a28487a79c7559d9797E8B0",
670
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
671
+ bundler3: {
672
+ bundler3: "0xb371CFee69984D1F3447D49217889C7388bA2027",
673
+ generalAdapter1: "0x43F4861c9E7f584cFDc9B6BA3F0c2462895BDd67",
674
+ },
675
+ adaptiveCurveIrm: "0xE5B5627C5973AfAE1928a6b8e5c1D6AABFEC8a7a",
676
+ vaultV2Factory: "0x6FC83ECc0e8142635D77200e5052be8A0a9D2f42",
677
+ morphoMarketV1AdapterV2Factory: "0xd8237ea1b5974c83C6b0c8942dc2a16F42f789dd",
678
+ registryList: "0x9730d0B30d9145B66a8e09D26295e36cb84F64a9",
679
+ chainlinkOracleFactory: "0x95cB3625598F9abf6cb8B874AA1EfEEbE7822642",
680
+ preLiquidationFactory: "0xf215D05a04b97f98Bb1bF4E0E5Cb97Ef38fa8895",
681
+ wNative: "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d",
682
+ },
683
+ [ChainId.XdcMainnet]: {
684
+ morpho: "0xEa49B0fE898aF913A3826F9f462eE2cDcb854fD9",
685
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
686
+ bundler3: {
687
+ bundler3: "0xed9bdc3E6081db528b6D5CDDf47EcB05337c62A7",
688
+ generalAdapter1: "0xAB2Ab6A8bb1082C5d8400D6206c6A13cE413e0c0",
689
+ },
690
+ adaptiveCurveIrm: "0x15c7312B0f26aa0AA70B24a0D2AF87B9e7D614A0",
691
+ vaultV2Factory: "0x227544d6989cD15c05AAB6dde4F29523dcfdbe2B",
692
+ morphoMarketV1AdapterV2Factory: "0x5C00c99F2235439725417E9f037B7D38FfF35d31",
693
+ registryList: "0x79A8C4e9E502C1867cAf2E7202f0C6b89aaCd5c1",
694
+ chainlinkOracleFactory: "0x6Ad93a3aA829514473D3DF67382894A76c7283B4",
695
+ preLiquidationFactory: "0xe3845262d726a827817C7196143CDa9a4404218d",
696
+ wNative: "0x951857744785E80e2De051c32EE7b25f9c458C42",
697
+ },
698
+ [ChainId.KaiaMainnet]: {
699
+ morpho: "0xA8BEebdca34d83C697c302A0594f3c41f3994cd2",
700
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
701
+ bundler3: {
702
+ bundler3: "0x27880B18ae04a05F1D603B87AEb2a27491FfaBA9",
703
+ generalAdapter1: "0x8e36C2c6d7771820BF14a75f725f3cf0374a7823",
704
+ },
705
+ adaptiveCurveIrm: "0xA4E2bA20Fc64D721D95BD5a28FF71844C5bb5cF2",
706
+ vaultV2Factory: "0xf2Aecd4a4d4C21d08770e34F392C4C271aBD9144",
707
+ morphoMarketV1AdapterV2Factory: "0x4d04C39ca604b560c50F4045c558378FD9AEBCF4",
708
+ registryList: "0xfCA12228DA5fba6E9c0B57a8e8322d0eBaCa03Bc",
709
+ chainlinkOracleFactory: "0x3e89C1071814b2c4170c90260Fcb60B903AD4602",
710
+ preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440",
711
+ wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432",
712
+ },
668
713
  };
669
714
  const _deployments = {
670
715
  [ChainId.EthMainnet]: {
@@ -1216,6 +1261,51 @@ const _deployments = {
1216
1261
  preLiquidationFactory: 7520548n,
1217
1262
  wNative: 0n,
1218
1263
  },
1264
+ [ChainId.FlareMainnet]: {
1265
+ morpho: 52378788n,
1266
+ permit2: 58377404n,
1267
+ bundler3: {
1268
+ bundler3: 52378788n,
1269
+ generalAdapter1: 52378788n,
1270
+ },
1271
+ adaptiveCurveIrm: 52378788n,
1272
+ vaultV2Factory: 52383002n,
1273
+ morphoMarketV1AdapterV2Factory: 52383110n,
1274
+ registryList: 52383110n,
1275
+ chainlinkOracleFactory: 52378931n,
1276
+ preLiquidationFactory: 52378931n,
1277
+ wNative: 39n,
1278
+ },
1279
+ [ChainId.XdcMainnet]: {
1280
+ morpho: 101757515n,
1281
+ permit2: 92945178n,
1282
+ bundler3: {
1283
+ bundler3: 101757515n,
1284
+ generalAdapter1: 101757515n,
1285
+ },
1286
+ adaptiveCurveIrm: 101757515n,
1287
+ vaultV2Factory: 101757669n,
1288
+ morphoMarketV1AdapterV2Factory: 101757823n,
1289
+ registryList: 101757823n,
1290
+ chainlinkOracleFactory: 101757578n,
1291
+ preLiquidationFactory: 101757578n,
1292
+ wNative: 42776215n,
1293
+ },
1294
+ [ChainId.KaiaMainnet]: {
1295
+ morpho: 208021118n,
1296
+ permit2: 188994815n,
1297
+ bundler3: {
1298
+ bundler3: 208021118n,
1299
+ generalAdapter1: 208021118n,
1300
+ },
1301
+ adaptiveCurveIrm: 208021118n,
1302
+ vaultV2Factory: 213463014n,
1303
+ morphoMarketV1AdapterV2Factory: 213463079n,
1304
+ registryList: 213463079n,
1305
+ chainlinkOracleFactory: 213462907n,
1306
+ preLiquidationFactory: 213462907n,
1307
+ wNative: 104802159n,
1308
+ },
1219
1309
  };
1220
1310
  export const getChainAddresses = (chainId) => {
1221
1311
  const chainAddresses = addresses[chainId];
@@ -1336,6 +1426,15 @@ const _unwrappedTokensMapping = {
1336
1426
  [ChainId.GensynMainnet]: {
1337
1427
  [_addressesRegistry[ChainId.GensynMainnet].wNative]: NATIVE_ADDRESS,
1338
1428
  },
1429
+ [ChainId.FlareMainnet]: {
1430
+ [_addressesRegistry[ChainId.FlareMainnet].wNative]: NATIVE_ADDRESS,
1431
+ },
1432
+ [ChainId.XdcMainnet]: {
1433
+ [_addressesRegistry[ChainId.XdcMainnet].wNative]: NATIVE_ADDRESS,
1434
+ },
1435
+ [ChainId.KaiaMainnet]: {
1436
+ [_addressesRegistry[ChainId.KaiaMainnet].wNative]: NATIVE_ADDRESS,
1437
+ },
1339
1438
  };
1340
1439
  export function getUnwrappedToken(wrappedToken, chainId) {
1341
1440
  return unwrappedTokensMapping[chainId]?.[wrappedToken];
@@ -34,7 +34,10 @@ export declare enum ChainId {
34
34
  TempoMainnet = 4217,
35
35
  EdenMainnet = 714,
36
36
  PharosMainnet = 1672,
37
- GensynMainnet = 685689
37
+ GensynMainnet = 685689,
38
+ FlareMainnet = 14,
39
+ XdcMainnet = 50,
40
+ KaiaMainnet = 8217
38
41
  }
39
42
  export interface ChainMetadata {
40
43
  readonly name: string;
@@ -453,5 +456,38 @@ export declare namespace ChainUtils {
453
456
  explorerUrl: string;
454
457
  identifier: string;
455
458
  };
459
+ 14: {
460
+ name: string;
461
+ id: ChainId.FlareMainnet;
462
+ nativeCurrency: {
463
+ name: string;
464
+ symbol: string;
465
+ decimals: number;
466
+ };
467
+ explorerUrl: string;
468
+ identifier: string;
469
+ };
470
+ 50: {
471
+ name: string;
472
+ id: ChainId.XdcMainnet;
473
+ nativeCurrency: {
474
+ name: string;
475
+ symbol: string;
476
+ decimals: number;
477
+ };
478
+ explorerUrl: string;
479
+ identifier: string;
480
+ };
481
+ 8217: {
482
+ name: string;
483
+ id: ChainId.KaiaMainnet;
484
+ nativeCurrency: {
485
+ name: string;
486
+ symbol: string;
487
+ decimals: number;
488
+ };
489
+ explorerUrl: string;
490
+ identifier: string;
491
+ };
456
492
  };
457
493
  }
package/lib/esm/chain.js CHANGED
@@ -36,6 +36,9 @@ export var ChainId;
36
36
  ChainId[ChainId["EdenMainnet"] = 714] = "EdenMainnet";
37
37
  ChainId[ChainId["PharosMainnet"] = 1672] = "PharosMainnet";
38
38
  ChainId[ChainId["GensynMainnet"] = 685689] = "GensynMainnet";
39
+ ChainId[ChainId["FlareMainnet"] = 14] = "FlareMainnet";
40
+ ChainId[ChainId["XdcMainnet"] = 50] = "XdcMainnet";
41
+ ChainId[ChainId["KaiaMainnet"] = 8217] = "KaiaMainnet";
39
42
  })(ChainId || (ChainId = {}));
40
43
  export var ChainUtils;
41
44
  (function (ChainUtils) {
@@ -309,5 +312,26 @@ export var ChainUtils;
309
312
  explorerUrl: "https://gensyn-mainnet.explorer.alchemy.com",
310
313
  identifier: "gensyn",
311
314
  },
315
+ [ChainId.FlareMainnet]: {
316
+ name: "Flare",
317
+ id: ChainId.FlareMainnet,
318
+ nativeCurrency: { name: "Flare", symbol: "FLR", decimals: 18 },
319
+ explorerUrl: "https://mainnet.flarescan.com",
320
+ identifier: "flare",
321
+ },
322
+ [ChainId.XdcMainnet]: {
323
+ name: "XDC",
324
+ id: ChainId.XdcMainnet,
325
+ nativeCurrency: { name: "XDC", symbol: "XDC", decimals: 18 },
326
+ explorerUrl: "https://xdcscan.com",
327
+ identifier: "xdc",
328
+ },
329
+ [ChainId.KaiaMainnet]: {
330
+ name: "Kaia",
331
+ id: ChainId.KaiaMainnet,
332
+ nativeCurrency: { name: "Kaia", symbol: "KAIA", decimals: 18 },
333
+ explorerUrl: "https://kaiascan.io",
334
+ identifier: "kaia",
335
+ },
312
336
  };
313
337
  })(ChainUtils || (ChainUtils = {}));
@@ -34,11 +34,35 @@ export declare namespace MarketUtils {
34
34
  /**
35
35
  * Returns the interest accrued on both sides of the given market
36
36
  * as well as the supply shares minted to the fee recipient.
37
+ *
38
+ * Fee shares are converted from the fee amount against post-interest supply assets minus the fee amount,
39
+ * matching Morpho Blue's onchain accrual.
40
+ *
37
41
  * @param borrowRate The average borrow rate since the last market update (scaled by WAD).
38
- * @param market The market state.
42
+ * @param market.totalSupplyAssets The market's total supplied assets before accrual.
43
+ * @param market.totalBorrowAssets The market's total borrowed assets before accrual.
44
+ * @param market.totalSupplyShares The market's total supply shares before fee shares are minted.
45
+ * @param market.fee The market fee percentage, scaled by WAD.
39
46
  * @param elapsed The time elapsed since the last market update (in seconds).
47
+ * @returns The accrued interest and the supply shares minted to the fee recipient.
48
+ * @example
49
+ * ```ts
50
+ * import { MarketUtils, MathLib } from "@morpho-org/blue-sdk";
51
+ *
52
+ * const { interest, feeShares } = MarketUtils.getAccruedInterest(
53
+ * 5_0000000000000000n,
54
+ * {
55
+ * totalSupplyAssets: 1_000_000n * MathLib.WAD,
56
+ * totalBorrowAssets: 800_000n * MathLib.WAD,
57
+ * totalSupplyShares: 1_100_000n * MathLib.WAD,
58
+ * fee: 10_0000000000000000n,
59
+ * },
60
+ * 1n,
61
+ * );
62
+ * // { interest, feeShares } satisfies { interest: bigint; feeShares: bigint }
63
+ * ```
40
64
  */
41
- function getAccruedInterest(borrowRate: BigIntish, { totalSupplyAssets, totalBorrowAssets, totalSupplyShares, fee, }: {
65
+ function getAccruedInterest(borrowRate: BigIntish, market: {
42
66
  totalSupplyAssets: BigIntish;
43
67
  totalBorrowAssets: BigIntish;
44
68
  totalSupplyShares: BigIntish;
@@ -1,5 +1,5 @@
1
- import { keccak_256 } from "@noble/hashes/sha3";
2
- import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
1
+ import { keccak_256 } from "@noble/hashes/sha3.js";
2
+ import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
3
3
  import { formatEther } from "viem";
4
4
  import { LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, } from "../constants.js";
5
5
  import { MathLib, SharesMath } from "../math/index.js";
@@ -59,16 +59,41 @@ export var MarketUtils;
59
59
  /**
60
60
  * Returns the interest accrued on both sides of the given market
61
61
  * as well as the supply shares minted to the fee recipient.
62
+ *
63
+ * Fee shares are converted from the fee amount against post-interest supply assets minus the fee amount,
64
+ * matching Morpho Blue's onchain accrual.
65
+ *
62
66
  * @param borrowRate The average borrow rate since the last market update (scaled by WAD).
63
- * @param market The market state.
67
+ * @param market.totalSupplyAssets The market's total supplied assets before accrual.
68
+ * @param market.totalBorrowAssets The market's total borrowed assets before accrual.
69
+ * @param market.totalSupplyShares The market's total supply shares before fee shares are minted.
70
+ * @param market.fee The market fee percentage, scaled by WAD.
64
71
  * @param elapsed The time elapsed since the last market update (in seconds).
72
+ * @returns The accrued interest and the supply shares minted to the fee recipient.
73
+ * @example
74
+ * ```ts
75
+ * import { MarketUtils, MathLib } from "@morpho-org/blue-sdk";
76
+ *
77
+ * const { interest, feeShares } = MarketUtils.getAccruedInterest(
78
+ * 5_0000000000000000n,
79
+ * {
80
+ * totalSupplyAssets: 1_000_000n * MathLib.WAD,
81
+ * totalBorrowAssets: 800_000n * MathLib.WAD,
82
+ * totalSupplyShares: 1_100_000n * MathLib.WAD,
83
+ * fee: 10_0000000000000000n,
84
+ * },
85
+ * 1n,
86
+ * );
87
+ * // { interest, feeShares } satisfies { interest: bigint; feeShares: bigint }
88
+ * ```
65
89
  */
66
90
  // biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
67
- function getAccruedInterest(borrowRate, { totalSupplyAssets, totalBorrowAssets, totalSupplyShares, fee, }, elapsed = 0n) {
91
+ function getAccruedInterest(borrowRate, market, elapsed = 0n) {
92
+ const { totalSupplyAssets, totalBorrowAssets, totalSupplyShares, fee } = market;
68
93
  const interest = MathLib.wMulDown(totalBorrowAssets, MathLib.wTaylorCompounded(borrowRate, elapsed));
69
94
  const feeAmount = MathLib.wMulDown(interest, fee);
70
95
  const feeShares = toSupplyShares(feeAmount, {
71
- totalSupplyAssets: BigInt(totalSupplyAssets) - feeAmount,
96
+ totalSupplyAssets: BigInt(totalSupplyAssets) + interest - feeAmount,
72
97
  totalSupplyShares,
73
98
  }, "Down");
74
99
  return { interest, feeShares };
@@ -44,6 +44,7 @@ export declare class PreLiquidationPosition extends AccrualPosition implements I
44
44
  constructor({ preLiquidationParams, preLiquidation, preLiquidationOraclePrice, ...position }: IPreLiquidationPosition, market: IMarket);
45
45
  get market(): Market;
46
46
  protected get _lltv(): bigint;
47
+ accrueInterest(timestamp?: BigIntish): PreLiquidationPosition;
47
48
  /**
48
49
  * @inheritdoc `undefined` if the pre-liquidation's oracle reverts.
49
50
  * `undefined` if it may be liquidatable on Morpho.
@@ -52,6 +52,14 @@ export class PreLiquidationPosition extends AccrualPosition {
52
52
  get _lltv() {
53
53
  return this._baseMarket.params.lltv;
54
54
  }
55
+ accrueInterest(timestamp) {
56
+ return new PreLiquidationPosition({
57
+ ...this,
58
+ preLiquidationParams: this.preLiquidationParams,
59
+ preLiquidation: this.preLiquidation,
60
+ preLiquidationOraclePrice: this.preLiquidationOraclePrice,
61
+ }, this._baseMarket.accrueInterest(timestamp));
62
+ }
55
63
  /**
56
64
  * @inheritdoc `undefined` if the pre-liquidation's oracle reverts.
57
65
  * `undefined` if it may be liquidatable on Morpho.
@@ -13,11 +13,7 @@ export interface IVaultV2Allocation {
13
13
  export interface IVaultV2 extends IToken {
14
14
  asset: Address;
15
15
  /**
16
- * The total assets, *including* virtually accrued interest.
17
- */
18
- totalAssets: bigint;
19
- /**
20
- * The total assets, *excluding* virtually accrued interest.
16
+ * Stored total assets at `lastUpdate`, excluding virtually accrued interest.
21
17
  */
22
18
  _totalAssets: bigint;
23
19
  /**
@@ -38,7 +34,6 @@ export interface IVaultV2 extends IToken {
38
34
  }
39
35
  export declare class VaultV2 extends WrappedToken implements IVaultV2 {
40
36
  readonly asset: Address;
41
- totalAssets: bigint;
42
37
  _totalAssets: bigint;
43
38
  totalSupply: bigint;
44
39
  virtualShares: bigint;
@@ -52,7 +47,7 @@ export declare class VaultV2 extends WrappedToken implements IVaultV2 {
52
47
  managementFee: bigint;
53
48
  performanceFeeRecipient: `0x${string}`;
54
49
  managementFeeRecipient: `0x${string}`;
55
- constructor({ asset, totalAssets, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
50
+ constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
56
51
  toAssets(shares: BigIntish): bigint;
57
52
  toShares(assets: BigIntish): bigint;
58
53
  protected _wrap(amount: BigIntish, rounding: RoundingDirection): bigint;
@@ -5,7 +5,6 @@ import { WrappedToken } from "../../token/index.js";
5
5
  import { CapacityLimitReason } from "../../utils.js";
6
6
  export class VaultV2 extends WrappedToken {
7
7
  asset;
8
- totalAssets;
9
8
  _totalAssets;
10
9
  totalSupply;
11
10
  virtualShares;
@@ -19,10 +18,9 @@ export class VaultV2 extends WrappedToken {
19
18
  managementFee;
20
19
  performanceFeeRecipient;
21
20
  managementFeeRecipient;
22
- constructor({ asset, totalAssets, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }) {
21
+ constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }) {
23
22
  super(config, asset);
24
23
  this.asset = asset;
25
- this.totalAssets = totalAssets;
26
24
  this._totalAssets = _totalAssets;
27
25
  this.totalSupply = totalSupply;
28
26
  this.virtualShares = virtualShares;
@@ -44,10 +42,11 @@ export class VaultV2 extends WrappedToken {
44
42
  return this._wrap(assets, "Down");
45
43
  }
46
44
  _wrap(amount, rounding) {
47
- return MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this.totalAssets + 1n, rounding);
45
+ // Pair pre-accrue `_totalAssets` with pre-accrue `totalSupply`; call `AccrualVaultV2.accrueInterest` for post-accrue math.
46
+ return MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this._totalAssets + 1n, rounding);
48
47
  }
49
48
  _unwrap(amount, rounding) {
50
- return MathLib.mulDiv(amount, this.totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
49
+ return MathLib.mulDiv(amount, this._totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
51
50
  }
52
51
  }
53
52
  export class AccrualVaultV2 extends VaultV2 {
@@ -90,8 +89,8 @@ export class AccrualVaultV2 extends VaultV2 {
90
89
  limiter: CapacityLimitReason.vaultV2_absoluteCap,
91
90
  };
92
91
  if (relativeCap !== MathLib.WAD) {
93
- // `relativeCap` can be set lower than `allocation / totalAssets`.
94
- const relativeMaxDeposit = MathLib.zeroFloorSub(MathLib.wMulDown(this.totalAssets, relativeCap), allocation);
92
+ // `relativeCap` can be set lower than `allocation / _totalAssets`.
93
+ const relativeMaxDeposit = MathLib.zeroFloorSub(MathLib.wMulDown(this._totalAssets, relativeCap), allocation);
95
94
  if (liquidityAdapterLimit.value > relativeMaxDeposit)
96
95
  liquidityAdapterLimit = {
97
96
  value: relativeMaxDeposit,
@@ -149,7 +148,6 @@ export class AccrualVaultV2 extends VaultV2 {
149
148
  const newTotalAssetsWithoutFees = newTotalAssets - performanceFeeAssets - managementFeeAssets;
150
149
  const performanceFeeShares = MathLib.mulDivDown(performanceFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
151
150
  const managementFeeShares = MathLib.mulDivDown(managementFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
152
- vault.totalAssets = newTotalAssets;
153
151
  vault._totalAssets = newTotalAssets;
154
152
  if (performanceFeeShares)
155
153
  vault.totalSupply += performanceFeeShares;
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": "5.23.2",
4
+ "version": "6.0.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -19,7 +19,7 @@
19
19
  "lib"
20
20
  ],
21
21
  "dependencies": {
22
- "@noble/hashes": "^1.6.1",
22
+ "@noble/hashes": "^2.2.0",
23
23
  "@types/lodash.isplainobject": "^4.0.9",
24
24
  "@types/lodash.mergewith": "^4.6.9",
25
25
  "lodash.isplainobject": "^4.0.6",
@@ -29,11 +29,11 @@
29
29
  "@morpho-org/morpho-ts": "^2.5.1"
30
30
  },
31
31
  "devDependencies": {
32
- "typescript": "^5.9.3",
33
- "viem": "^2.41.2",
34
- "vitest": "^4.1.4",
32
+ "typescript": "^6.0.3",
33
+ "viem": "^2.49.3",
34
+ "vitest": "^4.1.6",
35
35
  "@morpho-org/morpho-ts": "^2.5.1",
36
- "@morpho-org/test": "^2.7.2"
36
+ "@morpho-org/test": "^2.8.0"
37
37
  },
38
38
  "scripts": {
39
39
  "prepublish": "$npm_execpath build",