@morpho-org/blue-sdk 6.3.0 → 6.4.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.
@@ -33,6 +33,10 @@ export interface IVaultV2 extends IToken {
33
33
  managementFee: bigint;
34
34
  performanceFeeRecipient: Address;
35
35
  managementFeeRecipient: Address;
36
+ /** Whether the performance fee recipient can receive vault shares. Defaults to `true`. */
37
+ performanceFeeRecipientCanReceiveShares?: boolean;
38
+ /** Whether the management fee recipient can receive vault shares. Defaults to `true`. */
39
+ managementFeeRecipientCanReceiveShares?: boolean;
36
40
  }
37
41
  /** Represents a Morpho Vault V2 and its fee, adapter, and accounting state. */
38
42
  export declare class VaultV2 extends WrappedToken implements IVaultV2 {
@@ -50,7 +54,11 @@ export declare class VaultV2 extends WrappedToken implements IVaultV2 {
50
54
  managementFee: bigint;
51
55
  performanceFeeRecipient: `0x${string}`;
52
56
  managementFeeRecipient: `0x${string}`;
53
- constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
57
+ /** Whether the performance fee recipient can receive vault shares. */
58
+ performanceFeeRecipientCanReceiveShares: boolean;
59
+ /** Whether the management fee recipient can receive vault shares. */
60
+ managementFeeRecipientCanReceiveShares: boolean;
61
+ constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, performanceFeeRecipientCanReceiveShares, managementFeeRecipientCanReceiveShares, ...config }: IVaultV2);
54
62
  toAssets(shares: BigIntish): bigint;
55
63
  toShares(assets: BigIntish): bigint;
56
64
  protected _wrap(amount: BigIntish, rounding: RoundingDirection): bigint;
@@ -85,6 +93,7 @@ export declare class AccrualVaultV2 extends VaultV2 implements IAccrualVaultV2 {
85
93
  maxWithdraw(shares: BigIntish): CapacityLimit;
86
94
  /**
87
95
  * Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
96
+ * Performance and management fee shares are zero when the corresponding fee recipient cannot receive vault shares.
88
97
  * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the vault's `lastUpdate`.
89
98
  */
90
99
  accrueInterest(timestamp: BigIntish): {
@@ -22,7 +22,11 @@ class VaultV2 extends index_js_2.WrappedToken {
22
22
  managementFee;
23
23
  performanceFeeRecipient;
24
24
  managementFeeRecipient;
25
- constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }) {
25
+ /** Whether the performance fee recipient can receive vault shares. */
26
+ performanceFeeRecipientCanReceiveShares;
27
+ /** Whether the management fee recipient can receive vault shares. */
28
+ managementFeeRecipientCanReceiveShares;
29
+ constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, performanceFeeRecipientCanReceiveShares = true, managementFeeRecipientCanReceiveShares = true, ...config }) {
26
30
  super(config, asset);
27
31
  this.asset = asset;
28
32
  this._totalAssets = _totalAssets;
@@ -38,6 +42,10 @@ class VaultV2 extends index_js_2.WrappedToken {
38
42
  this.managementFee = managementFee;
39
43
  this.performanceFeeRecipient = performanceFeeRecipient;
40
44
  this.managementFeeRecipient = managementFeeRecipient;
45
+ this.performanceFeeRecipientCanReceiveShares =
46
+ performanceFeeRecipientCanReceiveShares;
47
+ this.managementFeeRecipientCanReceiveShares =
48
+ managementFeeRecipientCanReceiveShares;
41
49
  }
42
50
  toAssets(shares) {
43
51
  return this._unwrap(shares, "Down");
@@ -128,6 +136,7 @@ class AccrualVaultV2 extends VaultV2 {
128
136
  }
129
137
  /**
130
138
  * Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
139
+ * Performance and management fee shares are zero when the corresponding fee recipient cannot receive vault shares.
131
140
  * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the vault's `lastUpdate`.
132
141
  */
133
142
  accrueInterest(timestamp) {
@@ -145,10 +154,14 @@ class AccrualVaultV2 extends VaultV2 {
145
154
  index_js_1.MathLib.wMulDown(vault._totalAssets * elapsed, vault.maxRate);
146
155
  const newTotalAssets = index_js_1.MathLib.min(realAssets, maxTotalAssets);
147
156
  const interest = index_js_1.MathLib.zeroFloorSub(newTotalAssets, vault._totalAssets);
148
- const performanceFeeAssets = interest > 0n && vault.performanceFee > 0n
157
+ const performanceFeeAssets = interest > 0n &&
158
+ vault.performanceFee > 0n &&
159
+ vault.performanceFeeRecipientCanReceiveShares
149
160
  ? index_js_1.MathLib.wMulDown(interest, vault.performanceFee)
150
161
  : 0n;
151
- const managementFeeAssets = elapsed > 0n && vault.managementFee > 0n
162
+ const managementFeeAssets = elapsed > 0n &&
163
+ vault.managementFee > 0n &&
164
+ vault.managementFeeRecipientCanReceiveShares
152
165
  ? index_js_1.MathLib.wMulDown(newTotalAssets * elapsed, vault.managementFee)
153
166
  : 0n;
154
167
  const newTotalAssetsWithoutFees = newTotalAssets - performanceFeeAssets - managementFeeAssets;
@@ -33,6 +33,10 @@ export interface IVaultV2 extends IToken {
33
33
  managementFee: bigint;
34
34
  performanceFeeRecipient: Address;
35
35
  managementFeeRecipient: Address;
36
+ /** Whether the performance fee recipient can receive vault shares. Defaults to `true`. */
37
+ performanceFeeRecipientCanReceiveShares?: boolean;
38
+ /** Whether the management fee recipient can receive vault shares. Defaults to `true`. */
39
+ managementFeeRecipientCanReceiveShares?: boolean;
36
40
  }
37
41
  /** Represents a Morpho Vault V2 and its fee, adapter, and accounting state. */
38
42
  export declare class VaultV2 extends WrappedToken implements IVaultV2 {
@@ -50,7 +54,11 @@ export declare class VaultV2 extends WrappedToken implements IVaultV2 {
50
54
  managementFee: bigint;
51
55
  performanceFeeRecipient: `0x${string}`;
52
56
  managementFeeRecipient: `0x${string}`;
53
- constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
57
+ /** Whether the performance fee recipient can receive vault shares. */
58
+ performanceFeeRecipientCanReceiveShares: boolean;
59
+ /** Whether the management fee recipient can receive vault shares. */
60
+ managementFeeRecipientCanReceiveShares: boolean;
61
+ constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, performanceFeeRecipientCanReceiveShares, managementFeeRecipientCanReceiveShares, ...config }: IVaultV2);
54
62
  toAssets(shares: BigIntish): bigint;
55
63
  toShares(assets: BigIntish): bigint;
56
64
  protected _wrap(amount: BigIntish, rounding: RoundingDirection): bigint;
@@ -85,6 +93,7 @@ export declare class AccrualVaultV2 extends VaultV2 implements IAccrualVaultV2 {
85
93
  maxWithdraw(shares: BigIntish): CapacityLimit;
86
94
  /**
87
95
  * Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
96
+ * Performance and management fee shares are zero when the corresponding fee recipient cannot receive vault shares.
88
97
  * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the vault's `lastUpdate`.
89
98
  */
90
99
  accrueInterest(timestamp: BigIntish): {
@@ -19,7 +19,11 @@ export class VaultV2 extends WrappedToken {
19
19
  managementFee;
20
20
  performanceFeeRecipient;
21
21
  managementFeeRecipient;
22
- constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }) {
22
+ /** Whether the performance fee recipient can receive vault shares. */
23
+ performanceFeeRecipientCanReceiveShares;
24
+ /** Whether the management fee recipient can receive vault shares. */
25
+ managementFeeRecipientCanReceiveShares;
26
+ constructor({ asset, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, performanceFeeRecipientCanReceiveShares = true, managementFeeRecipientCanReceiveShares = true, ...config }) {
23
27
  super(config, asset);
24
28
  this.asset = asset;
25
29
  this._totalAssets = _totalAssets;
@@ -35,6 +39,10 @@ export class VaultV2 extends WrappedToken {
35
39
  this.managementFee = managementFee;
36
40
  this.performanceFeeRecipient = performanceFeeRecipient;
37
41
  this.managementFeeRecipient = managementFeeRecipient;
42
+ this.performanceFeeRecipientCanReceiveShares =
43
+ performanceFeeRecipientCanReceiveShares;
44
+ this.managementFeeRecipientCanReceiveShares =
45
+ managementFeeRecipientCanReceiveShares;
38
46
  }
39
47
  toAssets(shares) {
40
48
  return this._unwrap(shares, "Down");
@@ -124,6 +132,7 @@ export class AccrualVaultV2 extends VaultV2 {
124
132
  }
125
133
  /**
126
134
  * Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
135
+ * Performance and management fee shares are zero when the corresponding fee recipient cannot receive vault shares.
127
136
  * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the vault's `lastUpdate`.
128
137
  */
129
138
  accrueInterest(timestamp) {
@@ -141,10 +150,14 @@ export class AccrualVaultV2 extends VaultV2 {
141
150
  MathLib.wMulDown(vault._totalAssets * elapsed, vault.maxRate);
142
151
  const newTotalAssets = MathLib.min(realAssets, maxTotalAssets);
143
152
  const interest = MathLib.zeroFloorSub(newTotalAssets, vault._totalAssets);
144
- const performanceFeeAssets = interest > 0n && vault.performanceFee > 0n
153
+ const performanceFeeAssets = interest > 0n &&
154
+ vault.performanceFee > 0n &&
155
+ vault.performanceFeeRecipientCanReceiveShares
145
156
  ? MathLib.wMulDown(interest, vault.performanceFee)
146
157
  : 0n;
147
- const managementFeeAssets = elapsed > 0n && vault.managementFee > 0n
158
+ const managementFeeAssets = elapsed > 0n &&
159
+ vault.managementFee > 0n &&
160
+ vault.managementFeeRecipientCanReceiveShares
148
161
  ? MathLib.wMulDown(newTotalAssets * elapsed, vault.managementFee)
149
162
  : 0n;
150
163
  const newTotalAssetsWithoutFees = newTotalAssets - performanceFeeAssets - managementFeeAssets;
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": "6.3.0",
4
+ "version": "6.4.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "type": "module",
21
- "main": "src/index.ts",
21
+ "main": "./lib/cjs/index.js",
22
22
  "files": [
23
23
  "lib"
24
24
  ],
@@ -32,8 +32,8 @@
32
32
  "typescript": "^6.0.3",
33
33
  "viem": "2.54.2",
34
34
  "vitest": "^4.1.9",
35
- "@morpho-org/morpho-ts": "^2.7.0",
36
- "@morpho-org/test": "^2.8.1"
35
+ "@morpho-org/morpho-ts": "^2.8.0",
36
+ "@morpho-org/test": "^2.8.3"
37
37
  },
38
38
  "scripts": {
39
39
  "prepublish": "$npm_execpath build",
@@ -42,6 +42,7 @@
42
42
  "build:esm": "tsc --build tsconfig.build.esm.json && echo '{\"type\":\"module\"}' > lib/esm/package.json",
43
43
  "test": "vitest"
44
44
  },
45
+ "types": "./lib/esm/index.d.ts",
45
46
  "exports": {
46
47
  ".": {
47
48
  "types": "./lib/esm/index.d.ts",
package/src/index.ts DELETED
@@ -1,14 +0,0 @@
1
- export * from "./addresses.js";
2
- export * from "./chain.js";
3
- export * from "./constants.js";
4
- export * from "./errors.js";
5
- export * from "./holding/index.js";
6
- export * from "./market/index.js";
7
- export * from "./math/index.js";
8
- export * from "./position/index.js";
9
- export * from "./preLiquidation.js";
10
- export * from "./token/index.js";
11
- export * from "./types.js";
12
- export * from "./user/index.js";
13
- export * from "./utils.js";
14
- export * from "./vault/index.js";