@morpho-org/blue-sdk 4.13.1 → 4.14.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.
@@ -49,8 +49,6 @@ export interface ChainAddresses {
49
49
  adaptiveCurveIrm: Address;
50
50
  publicAllocator?: Address;
51
51
  metaMorphoFactory?: Address;
52
- vaultV2Factory?: Address;
53
- morphoVaultV1AdapterFactory?: Address;
54
52
  registryList?: Address;
55
53
  chainlinkOracleFactory?: Address;
56
54
  preLiquidationFactory?: Address;
@@ -66,6 +64,8 @@ export interface ChainAddresses {
66
64
  usdc?: Address;
67
65
  stEth?: Address;
68
66
  wstEth?: Address;
67
+ vaultV2Factory?: Address;
68
+ morphoVaultV1AdapterFactory?: Address;
69
69
  }
70
70
  declare const _addressesRegistry: {
71
71
  readonly 1: {
@@ -111,8 +111,6 @@ declare const _addressesRegistry: {
111
111
  readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
112
112
  readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
113
113
  readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
114
- readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
115
- readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
116
114
  readonly registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e";
117
115
  readonly chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766";
118
116
  readonly preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476";
@@ -143,6 +141,8 @@ declare const _addressesRegistry: {
143
141
  readonly crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14";
144
142
  readonly "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e";
145
143
  readonly "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726";
144
+ readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
145
+ readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
146
146
  };
147
147
  readonly 8453: {
148
148
  readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
@@ -174,8 +174,6 @@ declare const _addressesRegistry: {
174
174
  readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
175
175
  readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
176
176
  readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
177
- readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
178
- readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
179
177
  readonly registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a";
180
178
  readonly chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d";
181
179
  readonly preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef";
@@ -183,6 +181,8 @@ declare const _addressesRegistry: {
183
181
  readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
184
182
  readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
185
183
  readonly testUsdc: "0xBC77067f829979812d795d516E523C4033b66409";
184
+ readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
185
+ readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
186
186
  };
187
187
  readonly 137: {
188
188
  readonly morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67";
@@ -494,11 +494,11 @@ declare const _deployments: {
494
494
  readonly adaptiveCurveIrm: 18883124n;
495
495
  readonly publicAllocator: 19375099n;
496
496
  readonly metaMorphoFactory: 21439510n;
497
- readonly vaultV2Factory: 23375073n;
498
- readonly morphoVaultV1AdapterFactory: 23375073n;
499
497
  readonly registryList: 23375119n;
500
498
  readonly chainlinkOracleFactory: 19375066n;
501
499
  readonly preLiquidationFactory: 21414664n;
500
+ readonly vaultV2Factory: 23375073n;
501
+ readonly morphoVaultV1AdapterFactory: 23375073n;
502
502
  };
503
503
  readonly 8453: {
504
504
  readonly morpho: 13977148n;
@@ -514,11 +514,11 @@ declare const _deployments: {
514
514
  readonly adaptiveCurveIrm: 13977152n;
515
515
  readonly publicAllocator: 13979545n;
516
516
  readonly metaMorphoFactory: 23928808n;
517
- readonly vaultV2Factory: 35615206n;
518
- readonly morphoVaultV1AdapterFactory: 35615206n;
519
517
  readonly registryList: 35615358n;
520
518
  readonly chainlinkOracleFactory: 13978286n;
521
519
  readonly preLiquidationFactory: 23779056n;
520
+ readonly vaultV2Factory: 35615206n;
521
+ readonly morphoVaultV1AdapterFactory: 35615206n;
522
522
  };
523
523
  readonly 137: {
524
524
  readonly morpho: 66931042n;
@@ -849,8 +849,6 @@ export declare let addressesRegistry: {
849
849
  readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
850
850
  readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
851
851
  readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
852
- readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
853
- readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
854
852
  readonly registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e";
855
853
  readonly chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766";
856
854
  readonly preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476";
@@ -881,6 +879,8 @@ export declare let addressesRegistry: {
881
879
  readonly crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14";
882
880
  readonly "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e";
883
881
  readonly "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726";
882
+ readonly vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405";
883
+ readonly morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394";
884
884
  };
885
885
  readonly 8453: {
886
886
  readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
@@ -912,8 +912,6 @@ export declare let addressesRegistry: {
912
912
  readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
913
913
  readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
914
914
  readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
915
- readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
916
- readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
917
915
  readonly registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a";
918
916
  readonly chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d";
919
917
  readonly preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef";
@@ -921,6 +919,8 @@ export declare let addressesRegistry: {
921
919
  readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
922
920
  readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
923
921
  readonly testUsdc: "0xBC77067f829979812d795d516E523C4033b66409";
922
+ readonly vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857";
923
+ readonly morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642";
924
924
  };
925
925
  readonly 137: {
926
926
  readonly morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67";
@@ -1230,11 +1230,11 @@ export declare let deployments: {
1230
1230
  readonly adaptiveCurveIrm: 18883124n;
1231
1231
  readonly publicAllocator: 19375099n;
1232
1232
  readonly metaMorphoFactory: 21439510n;
1233
- readonly vaultV2Factory: 23375073n;
1234
- readonly morphoVaultV1AdapterFactory: 23375073n;
1235
1233
  readonly registryList: 23375119n;
1236
1234
  readonly chainlinkOracleFactory: 19375066n;
1237
1235
  readonly preLiquidationFactory: 21414664n;
1236
+ readonly vaultV2Factory: 23375073n;
1237
+ readonly morphoVaultV1AdapterFactory: 23375073n;
1238
1238
  };
1239
1239
  readonly 8453: {
1240
1240
  readonly morpho: 13977148n;
@@ -1250,11 +1250,11 @@ export declare let deployments: {
1250
1250
  readonly adaptiveCurveIrm: 13977152n;
1251
1251
  readonly publicAllocator: 13979545n;
1252
1252
  readonly metaMorphoFactory: 23928808n;
1253
- readonly vaultV2Factory: 35615206n;
1254
- readonly morphoVaultV1AdapterFactory: 35615206n;
1255
1253
  readonly registryList: 35615358n;
1256
1254
  readonly chainlinkOracleFactory: 13978286n;
1257
1255
  readonly preLiquidationFactory: 23779056n;
1256
+ readonly vaultV2Factory: 35615206n;
1257
+ readonly morphoVaultV1AdapterFactory: 35615206n;
1258
1258
  };
1259
1259
  readonly 137: {
1260
1260
  readonly morpho: 66931042n;
package/lib/addresses.js CHANGED
@@ -60,8 +60,6 @@ const _addressesRegistry = {
60
60
  adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
61
61
  publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D",
62
62
  metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24",
63
- vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405",
64
- morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394",
65
63
  registryList: "0x3696c5eAe4a7Ffd04Ea163564571E9CD8Ed9364e",
66
64
  chainlinkOracleFactory: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766",
67
65
  preLiquidationFactory: "0x6FF33615e792E35ed1026ea7cACCf42D9BF83476",
@@ -98,6 +96,8 @@ const _addressesRegistry = {
98
96
  crvUSDETHCRV: "0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14",
99
97
  "stkcvx2BTC-f-morpho": "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e",
100
98
  "2BTC-f": "0xB7ECB2AA52AA64a717180E030241bC75Cd946726",
99
+ vaultV2Factory: "0xA1D94F746dEfa1928926b84fB2596c06926C0405",
100
+ morphoVaultV1AdapterFactory: "0xD1B8E2dee25c2b89DCD2f98448a7ce87d6F63394",
101
101
  },
102
102
  [chain_js_1.ChainId.BaseMainnet]: {
103
103
  morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
@@ -129,8 +129,6 @@ const _addressesRegistry = {
129
129
  adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687",
130
130
  publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
131
131
  metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918",
132
- vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857",
133
- morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642",
134
132
  registryList: "0x5C2531Cbd2cf112Cf687da3Cd536708aDd7DB10a",
135
133
  chainlinkOracleFactory: "0x2DC205F24BCb6B311E5cdf0745B0741648Aebd3d",
136
134
  preLiquidationFactory: "0x8cd16b62E170Ee0bA83D80e1F80E6085367e2aef",
@@ -139,6 +137,8 @@ const _addressesRegistry = {
139
137
  usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
140
138
  verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b",
141
139
  testUsdc: "0xBC77067f829979812d795d516E523C4033b66409",
140
+ vaultV2Factory: "0x4501125508079A99ebBebCE205DeC9593C2b5857",
141
+ morphoVaultV1AdapterFactory: "0xF42D9c36b34c9c2CF3Bc30eD2a52a90eEB604642",
142
142
  },
143
143
  [chain_js_1.ChainId.PolygonMainnet]: {
144
144
  morpho: "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67",
@@ -456,11 +456,11 @@ const _deployments = {
456
456
  adaptiveCurveIrm: 18883124n,
457
457
  publicAllocator: 19375099n,
458
458
  metaMorphoFactory: 21439510n,
459
- vaultV2Factory: 23375073n,
460
- morphoVaultV1AdapterFactory: 23375073n,
461
459
  registryList: 23375119n,
462
460
  chainlinkOracleFactory: 19375066n,
463
461
  preLiquidationFactory: 21414664n,
462
+ vaultV2Factory: 23375073n,
463
+ morphoVaultV1AdapterFactory: 23375073n,
464
464
  },
465
465
  [chain_js_1.ChainId.BaseMainnet]: {
466
466
  morpho: 13977148n,
@@ -476,11 +476,11 @@ const _deployments = {
476
476
  adaptiveCurveIrm: 13977152n,
477
477
  publicAllocator: 13979545n,
478
478
  metaMorphoFactory: 23928808n,
479
- vaultV2Factory: 35615206n,
480
- morphoVaultV1AdapterFactory: 35615206n,
481
479
  registryList: 35615358n,
482
480
  chainlinkOracleFactory: 13978286n,
483
481
  preLiquidationFactory: 23779056n,
482
+ vaultV2Factory: 35615206n,
483
+ morphoVaultV1AdapterFactory: 35615206n,
484
484
  },
485
485
  [chain_js_1.ChainId.PolygonMainnet]: {
486
486
  morpho: 66931042n,
package/lib/errors.d.ts CHANGED
@@ -25,6 +25,10 @@ export declare class UnsupportedPreLiquidationParamsError extends Error {
25
25
  readonly lltv: bigint;
26
26
  constructor(lltv: bigint);
27
27
  }
28
+ export declare class UnsupportedVaultV2AdapterError extends Error {
29
+ readonly address: Address;
30
+ constructor(address: Address);
31
+ }
28
32
  export declare namespace BlueErrors {
29
33
  class AlreadySet extends Error {
30
34
  readonly name: string;
package/lib/errors.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlueErrors = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
3
+ exports.BlueErrors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
4
4
  exports._try = _try;
5
5
  const viem_1 = require("viem");
6
6
  class UnknownDataError extends Error {
@@ -54,6 +54,14 @@ class UnsupportedPreLiquidationParamsError extends Error {
54
54
  }
55
55
  }
56
56
  exports.UnsupportedPreLiquidationParamsError = UnsupportedPreLiquidationParamsError;
57
+ class UnsupportedVaultV2AdapterError extends Error {
58
+ address;
59
+ constructor(address) {
60
+ super(`vault v2 adapter "${address}" is not supported`);
61
+ this.address = address;
62
+ }
63
+ }
64
+ exports.UnsupportedVaultV2AdapterError = UnsupportedVaultV2AdapterError;
57
65
  var BlueErrors;
58
66
  (function (BlueErrors) {
59
67
  class AlreadySet extends Error {
package/lib/index.d.ts CHANGED
@@ -11,4 +11,5 @@ export * from "./holding/index.js";
11
11
  export * from "./position/index.js";
12
12
  export * from "./vault/index.js";
13
13
  export * from "./preLiquidation.js";
14
+ export * from "./vault-v2/index.js";
14
15
  export * from "./utils.js";
package/lib/index.js CHANGED
@@ -27,4 +27,5 @@ __exportStar(require("./holding/index.js"), exports);
27
27
  __exportStar(require("./position/index.js"), exports);
28
28
  __exportStar(require("./vault/index.js"), exports);
29
29
  __exportStar(require("./preLiquidation.js"), exports);
30
+ __exportStar(require("./vault-v2/index.js"), exports);
30
31
  __exportStar(require("./utils.js"), exports);
@@ -0,0 +1,56 @@
1
+ import type { Address } from "viem";
2
+ import { type RoundingDirection } from "../math";
3
+ import { type IToken, WrappedToken } from "../token";
4
+ import type { BigIntish } from "../types";
5
+ import type { IAccrualVaultV2Adapter } from "./VaultV2Adapter";
6
+ export interface IVaultV2 extends IToken {
7
+ asset: Address;
8
+ totalSupply: bigint;
9
+ totalAssets: bigint;
10
+ performanceFee: bigint;
11
+ managementFee: bigint;
12
+ virtualShares: bigint;
13
+ lastUpdate: bigint;
14
+ adapters: Address[];
15
+ maxRate: bigint;
16
+ liquidityAdapter: Address;
17
+ performanceFeeRecipient: Address;
18
+ managementFeeRecipient: Address;
19
+ }
20
+ export declare class VaultV2 extends WrappedToken implements IVaultV2 {
21
+ readonly asset: Address;
22
+ /**
23
+ * The ERC4626 vault's total supply of shares.
24
+ */
25
+ totalSupply: bigint;
26
+ /**
27
+ * The ERC4626 vault's total assets, without accrued interest
28
+ */
29
+ totalAssets: bigint;
30
+ virtualShares: bigint;
31
+ lastUpdate: bigint;
32
+ adapters: Address[];
33
+ maxRate: bigint;
34
+ performanceFee: bigint;
35
+ managementFee: bigint;
36
+ liquidityAdapter: Address;
37
+ performanceFeeRecipient: Address;
38
+ managementFeeRecipient: Address;
39
+ constructor({ totalSupply, asset, totalAssets, virtualShares, lastUpdate, adapters, maxRate, performanceFee, managementFee, liquidityAdapter, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
40
+ toAssets(shares: bigint): bigint;
41
+ toShares(assets: bigint): bigint;
42
+ protected _wrap(amount: bigint, rounding: RoundingDirection): bigint;
43
+ protected _unwrap(amount: bigint, rounding: RoundingDirection): bigint;
44
+ }
45
+ export interface IAccrualVaultV2 extends Omit<IVaultV2, "adapters"> {
46
+ }
47
+ export declare class AccrualVaultV2 extends VaultV2 implements IAccrualVaultV2 {
48
+ readonly accrualAdapters: IAccrualVaultV2Adapter[];
49
+ readonly assetBalance: bigint;
50
+ constructor(vault: IAccrualVaultV2, accrualAdapters: IAccrualVaultV2Adapter[], assetBalance: bigint);
51
+ accrueInterest(timestamp: BigIntish): {
52
+ vault: AccrualVaultV2;
53
+ performanceFeeShares: bigint;
54
+ managementFeeShares: bigint;
55
+ };
56
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccrualVaultV2 = exports.VaultV2 = void 0;
4
+ const math_1 = require("../math");
5
+ const token_1 = require("../token");
6
+ class VaultV2 extends token_1.WrappedToken {
7
+ asset;
8
+ /**
9
+ * The ERC4626 vault's total supply of shares.
10
+ */
11
+ totalSupply;
12
+ /**
13
+ * The ERC4626 vault's total assets, without accrued interest
14
+ */
15
+ totalAssets;
16
+ virtualShares;
17
+ lastUpdate;
18
+ adapters;
19
+ maxRate;
20
+ performanceFee;
21
+ managementFee;
22
+ liquidityAdapter;
23
+ performanceFeeRecipient;
24
+ managementFeeRecipient;
25
+ constructor({ totalSupply, asset, totalAssets, virtualShares, lastUpdate, adapters, maxRate, performanceFee, managementFee, liquidityAdapter, performanceFeeRecipient, managementFeeRecipient, ...config }) {
26
+ super(config, asset);
27
+ this.totalSupply = totalSupply;
28
+ this.totalAssets = totalAssets;
29
+ this.virtualShares = virtualShares;
30
+ this.lastUpdate = lastUpdate;
31
+ this.asset = asset;
32
+ this.maxRate = maxRate;
33
+ this.adapters = adapters;
34
+ this.performanceFee = performanceFee;
35
+ this.managementFee = managementFee;
36
+ this.liquidityAdapter = liquidityAdapter;
37
+ this.performanceFeeRecipient = performanceFeeRecipient;
38
+ this.managementFeeRecipient = managementFeeRecipient;
39
+ }
40
+ toAssets(shares) {
41
+ return this._unwrap(shares, "Down");
42
+ }
43
+ toShares(assets) {
44
+ return this._wrap(assets, "Down");
45
+ }
46
+ _wrap(amount, rounding) {
47
+ return math_1.MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this.totalAssets + 1n, rounding);
48
+ }
49
+ _unwrap(amount, rounding) {
50
+ return math_1.MathLib.mulDiv(amount, this.totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
51
+ }
52
+ }
53
+ exports.VaultV2 = VaultV2;
54
+ class AccrualVaultV2 extends VaultV2 {
55
+ accrualAdapters;
56
+ assetBalance;
57
+ constructor(vault, accrualAdapters, assetBalance) {
58
+ super({ ...vault, adapters: accrualAdapters.map((a) => a.address) });
59
+ this.accrualAdapters = accrualAdapters;
60
+ this.assetBalance = assetBalance;
61
+ }
62
+ accrueInterest(timestamp) {
63
+ const vault = new AccrualVaultV2(this, this.accrualAdapters, this.assetBalance);
64
+ const elapsed = BigInt(timestamp) - vault.lastUpdate;
65
+ if (elapsed <= 0n)
66
+ return { vault, performanceFeeShares: 0n, managementFeeShares: 0n };
67
+ const realAssets = vault.accrualAdapters.reduce((curr, adapter) => curr + adapter.realAssets(timestamp), vault.assetBalance);
68
+ const maxTotalAssets = vault.totalAssets +
69
+ math_1.MathLib.wMulDown(vault.totalAssets * elapsed, vault.maxRate);
70
+ const newTotalAssets = math_1.MathLib.min(realAssets, maxTotalAssets);
71
+ const interest = math_1.MathLib.zeroFloorSub(newTotalAssets, vault.totalAssets);
72
+ const performanceFeeAssets = interest > 0n && vault.performanceFee > 0n
73
+ ? math_1.MathLib.wMulDown(interest, vault.performanceFee)
74
+ : 0n;
75
+ const managementFeeAssets = elapsed > 0n && vault.managementFee > 0n
76
+ ? math_1.MathLib.wMulDown(newTotalAssets * elapsed, vault.managementFee)
77
+ : 0n;
78
+ const newTotalAssetsWithoutFees = newTotalAssets - performanceFeeAssets - managementFeeAssets;
79
+ const performanceFeeShares = math_1.MathLib.mulDivDown(performanceFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
80
+ const managementFeeShares = math_1.MathLib.mulDivDown(managementFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
81
+ vault.totalAssets = newTotalAssets;
82
+ if (performanceFeeShares)
83
+ vault.totalSupply += performanceFeeShares;
84
+ if (managementFeeShares)
85
+ vault.totalSupply += managementFeeShares;
86
+ vault.lastUpdate = BigInt(timestamp);
87
+ return { vault, performanceFeeShares, managementFeeShares };
88
+ }
89
+ }
90
+ exports.AccrualVaultV2 = AccrualVaultV2;
@@ -0,0 +1,18 @@
1
+ import type { Address, Hash } from "viem";
2
+ import type { BigIntish } from "../types";
3
+ export interface IVaultV2Adapter {
4
+ address: Address;
5
+ parentVault: Address;
6
+ adapterId: Hash;
7
+ skimRecipient: Address;
8
+ }
9
+ export declare abstract class VaultV2Adapter implements IVaultV2Adapter {
10
+ readonly address: Address;
11
+ readonly parentVault: Address;
12
+ readonly adapterId: Hash;
13
+ skimRecipient: Address;
14
+ constructor({ address, parentVault, adapterId, skimRecipient, }: IVaultV2Adapter);
15
+ }
16
+ export interface IAccrualVaultV2Adapter extends IVaultV2Adapter {
17
+ realAssets(timestamp: BigIntish): bigint;
18
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultV2Adapter = void 0;
4
+ class VaultV2Adapter {
5
+ address;
6
+ parentVault;
7
+ adapterId;
8
+ skimRecipient;
9
+ constructor({ address, parentVault, adapterId, skimRecipient, }) {
10
+ this.address = address;
11
+ this.parentVault = parentVault;
12
+ this.adapterId = adapterId;
13
+ this.skimRecipient = skimRecipient;
14
+ }
15
+ }
16
+ exports.VaultV2Adapter = VaultV2Adapter;
@@ -0,0 +1,21 @@
1
+ import type { Address } from "viem";
2
+ import { VaultV2Adapter } from "./VaultV2Adapter";
3
+ export interface IVaultV2MorphoVaultV1Adapter extends IVaultV2Adapter {
4
+ morphoVaultV1: Address;
5
+ }
6
+ import type { BigIntish } from "../types";
7
+ import type { AccrualVault } from "../vault";
8
+ import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter";
9
+ export declare class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter implements IVaultV2MorphoVaultV1Adapter {
10
+ readonly morphoVaultV1: Address;
11
+ constructor({ morphoVaultV1, ...vaultV2Adapter }: IVaultV2MorphoVaultV1Adapter);
12
+ ids(): `0x${string}`[];
13
+ }
14
+ export interface IAccrualVaultV2MorphoVaultV1Adapter extends IVaultV2MorphoVaultV1Adapter {
15
+ }
16
+ export declare class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter implements IAccrualVaultV2MorphoVaultV1Adapter, IAccrualVaultV2Adapter {
17
+ vaultV1: AccrualVault;
18
+ shares: bigint;
19
+ constructor(adapter: IAccrualVaultV2MorphoVaultV1Adapter, vaultV1: AccrualVault, shares: bigint);
20
+ realAssets(timestamp: BigIntish): bigint;
21
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccrualVaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoVaultV1Adapter = void 0;
4
+ const VaultV2Adapter_1 = require("./VaultV2Adapter");
5
+ class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter_1.VaultV2Adapter {
6
+ morphoVaultV1;
7
+ constructor({ morphoVaultV1, ...vaultV2Adapter }) {
8
+ super(vaultV2Adapter);
9
+ this.morphoVaultV1 = morphoVaultV1;
10
+ }
11
+ ids() {
12
+ return [this.adapterId];
13
+ }
14
+ }
15
+ exports.VaultV2MorphoVaultV1Adapter = VaultV2MorphoVaultV1Adapter;
16
+ class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter {
17
+ vaultV1;
18
+ shares;
19
+ constructor(adapter, vaultV1, shares) {
20
+ super(adapter);
21
+ this.vaultV1 = vaultV1;
22
+ this.shares = shares;
23
+ }
24
+ realAssets(timestamp) {
25
+ return this.vaultV1.accrueInterest(timestamp).toAssets(this.shares);
26
+ }
27
+ }
28
+ exports.AccrualVaultV2MorphoVaultV1Adapter = AccrualVaultV2MorphoVaultV1Adapter;
@@ -0,0 +1,3 @@
1
+ export * from "./VaultV2.js";
2
+ export * from "./VaultV2Adapter.js";
3
+ export * from "./VaultV2MorphoVaultV1Adapter.js";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./VaultV2.js"), exports);
18
+ __exportStar(require("./VaultV2Adapter.js"), exports);
19
+ __exportStar(require("./VaultV2MorphoVaultV1Adapter.js"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/blue-sdk",
3
3
  "description": "Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).",
4
- "version": "4.13.1",
4
+ "version": "4.14.0-next.1",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -25,13 +25,13 @@
25
25
  "lodash.mergewith": "^4.6.2"
26
26
  },
27
27
  "peerDependencies": {
28
- "@morpho-org/morpho-ts": "^2.4.2"
28
+ "@morpho-org/morpho-ts": "^2.4.3"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.7.2",
32
- "viem": "^2.23.0",
32
+ "viem": "^2.33.3",
33
33
  "vitest": "^3.0.5",
34
- "@morpho-org/morpho-ts": "^2.4.2",
34
+ "@morpho-org/morpho-ts": "^2.4.3",
35
35
  "@morpho-org/test": "^2.6.0"
36
36
  },
37
37
  "scripts": {