@morpho-org/blue-sdk 5.3.0-next.2 → 5.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.
@@ -1,5 +1,5 @@
1
1
  import type { RoundingDirection } from "../math/index.js";
2
- import type { Address, BigIntish } from "../types.js";
2
+ import type { Address } from "../types.js";
3
3
  import type { IVaultConfig } from "../vault/VaultConfig.js";
4
4
  import { WrappedToken } from "./WrappedToken.js";
5
5
  export interface IVaultToken {
@@ -18,6 +18,6 @@ export declare class VaultToken extends WrappedToken implements IVaultToken {
18
18
  */
19
19
  totalAssets: bigint;
20
20
  constructor(config: IVaultConfig, { totalAssets, totalSupply }: IVaultToken);
21
- protected _wrap(amount: BigIntish, rounding: RoundingDirection): bigint;
22
- protected _unwrap(amount: BigIntish, rounding: RoundingDirection): bigint;
21
+ protected _wrap(amount: bigint, rounding: RoundingDirection): bigint;
22
+ protected _unwrap(amount: bigint, rounding: RoundingDirection): bigint;
23
23
  }
@@ -1,7 +1,7 @@
1
+ import { type CapacityLimit } from "../market/index.js";
1
2
  import { type RoundingDirection } from "../math/index.js";
2
3
  import { VaultToken } from "../token/index.js";
3
4
  import type { Address, BigIntish, MarketId } from "../types.js";
4
- import { type CapacityLimit } from "../utils.js";
5
5
  import type { IVaultConfig } from "./VaultConfig.js";
6
6
  import { type IVaultMarketAllocation, VaultMarketAllocation } from "./VaultMarketAllocation.js";
7
7
  export interface Pending<T> {
@@ -116,8 +116,8 @@ export declare class Vault extends VaultToken implements IVault {
116
116
  * The amount of interest in assets accrued since the last interaction with the vault.
117
117
  */
118
118
  get totalInterest(): bigint;
119
- toAssets(shares: BigIntish, rounding?: RoundingDirection): bigint;
120
- toShares(assets: BigIntish, rounding?: RoundingDirection): bigint;
119
+ toAssets(shares: bigint, rounding?: RoundingDirection): bigint;
120
+ toShares(assets: bigint, rounding?: RoundingDirection): bigint;
121
121
  }
122
122
  export interface CollateralAllocation {
123
123
  address: Address;
@@ -129,6 +129,12 @@ export interface CollateralAllocation {
129
129
  export interface IAccrualVault extends Omit<IVault, "withdrawQueue" | "totalAssets"> {
130
130
  }
131
131
  export declare class AccrualVault extends Vault implements IAccrualVault {
132
+ /**
133
+ * @inheritdoc
134
+ * Reflects the sum of assets of the vault's allocations.
135
+ * Only includes virtually accrued interest if the vault's allocations include virtually accrued interest.
136
+ */
137
+ totalAssets: bigint;
132
138
  /**
133
139
  * The allocation of the vault on each market enabled.
134
140
  */
@@ -178,31 +184,11 @@ export declare class AccrualVault extends Vault implements IAccrualVault {
178
184
  */
179
185
  getNetApy(timestamp?: BigIntish): number;
180
186
  getAllocationProportion(marketId: MarketId): bigint;
181
- /**
182
- * Returns the deposit capacity limit of a given amount of assets on the vault.
183
- * @param assets The maximum amount of assets to deposit.
184
- * @deprecated Use `maxDeposit` instead.
185
- */
186
187
  getDepositCapacityLimit(assets: bigint): CapacityLimit;
187
- /**
188
- * Returns the withdraw capacity limit corresponding to a given amount of shares of the vault.
189
- * @param shares The maximum amount of shares to redeem.
190
- * @deprecated Use `maxWithdraw` instead.
191
- */
192
188
  getWithdrawCapacityLimit(shares: bigint): CapacityLimit;
193
- /**
194
- * Returns the maximum amount of assets that can be deposited to the vault.
195
- * @param assets The maximum amount of assets to deposit.
196
- */
197
- maxDeposit(assets: BigIntish): CapacityLimit;
198
- /**
199
- * Returns the maximum amount of assets that can be withdrawn from the vault.
200
- * @param shares The maximum amount of shares to redeem.
201
- */
202
- maxWithdraw(shares: BigIntish): CapacityLimit;
203
189
  /**
204
190
  * Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
205
191
  * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to each of the vault's market's `lastUpdate`.
206
192
  */
207
- accrueInterest(timestamp?: BigIntish): AccrualVault;
193
+ accrueInterest(timestamp: BigIntish): AccrualVault;
208
194
  }
@@ -5,7 +5,6 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
5
  const index_js_1 = require("../market/index.js");
6
6
  const index_js_2 = require("../math/index.js");
7
7
  const index_js_3 = require("../token/index.js");
8
- const utils_js_1 = require("../utils.js");
9
8
  const VaultMarketAllocation_js_1 = require("./VaultMarketAllocation.js");
10
9
  class Vault extends index_js_3.VaultToken {
11
10
  /**
@@ -209,28 +208,7 @@ class AccrualVault extends Vault {
209
208
  return 0n;
210
209
  return index_js_2.MathLib.wDivDown(allocation.position.supplyAssets, this.totalAssets);
211
210
  }
212
- /**
213
- * Returns the deposit capacity limit of a given amount of assets on the vault.
214
- * @param assets The maximum amount of assets to deposit.
215
- * @deprecated Use `maxDeposit` instead.
216
- */
217
211
  getDepositCapacityLimit(assets) {
218
- return this.maxDeposit(assets);
219
- }
220
- /**
221
- * Returns the withdraw capacity limit corresponding to a given amount of shares of the vault.
222
- * @param shares The maximum amount of shares to redeem.
223
- * @deprecated Use `maxWithdraw` instead.
224
- */
225
- getWithdrawCapacityLimit(shares) {
226
- return this.maxWithdraw(shares);
227
- }
228
- /**
229
- * Returns the maximum amount of assets that can be deposited to the vault.
230
- * @param assets The maximum amount of assets to deposit.
231
- */
232
- maxDeposit(assets) {
233
- assets = BigInt(assets);
234
212
  const suppliable = this.allocations
235
213
  .values()
236
214
  .reduce((total, { config: { cap }, position: { marketId, supplyAssets } }) => index_js_2.MathLib.min(total +
@@ -240,28 +218,24 @@ class AccrualVault extends Vault {
240
218
  if (assets > suppliable)
241
219
  return {
242
220
  value: suppliable,
243
- limiter: utils_js_1.CapacityLimitReason.cap,
221
+ limiter: index_js_1.CapacityLimitReason.cap,
244
222
  };
245
223
  return {
246
224
  value: assets,
247
- limiter: utils_js_1.CapacityLimitReason.balance,
225
+ limiter: index_js_1.CapacityLimitReason.balance,
248
226
  };
249
227
  }
250
- /**
251
- * Returns the maximum amount of assets that can be withdrawn from the vault.
252
- * @param shares The maximum amount of shares to redeem.
253
- */
254
- maxWithdraw(shares) {
228
+ getWithdrawCapacityLimit(shares) {
255
229
  const assets = this.toAssets(shares);
256
230
  const { liquidity } = this;
257
231
  if (assets > liquidity)
258
232
  return {
259
233
  value: liquidity,
260
- limiter: utils_js_1.CapacityLimitReason.liquidity,
234
+ limiter: index_js_1.CapacityLimitReason.liquidity,
261
235
  };
262
236
  return {
263
237
  value: assets,
264
- limiter: utils_js_1.CapacityLimitReason.balance,
238
+ limiter: index_js_1.CapacityLimitReason.balance,
265
239
  };
266
240
  }
267
241
  /**
@@ -5,4 +5,3 @@ export * from "./VaultMarketConfig.js";
5
5
  export * from "./VaultMarketPublicAllocatorConfig.js";
6
6
  export * from "./VaultUser.js";
7
7
  export * from "./Vault.js";
8
- export * from "./v2";
@@ -21,4 +21,3 @@ __exportStar(require("./VaultMarketConfig.js"), exports);
21
21
  __exportStar(require("./VaultMarketPublicAllocatorConfig.js"), exports);
22
22
  __exportStar(require("./VaultUser.js"), exports);
23
23
  __exportStar(require("./Vault.js"), exports);
24
- __exportStar(require("./v2"), 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": "5.3.0-next.2",
4
+ "version": "5.4.0",
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.3"
28
+ "@morpho-org/morpho-ts": "^2.4.4"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.7.2",
32
- "viem": "^2.33.3",
32
+ "viem": "^2.23.0",
33
33
  "vitest": "^3.0.5",
34
- "@morpho-org/morpho-ts": "^2.4.3",
34
+ "@morpho-org/morpho-ts": "^2.4.4",
35
35
  "@morpho-org/test": "^2.6.0"
36
36
  },
37
37
  "scripts": {
package/lib/utils.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export declare enum CapacityLimitReason {
2
- liquidity = "Liquidity",
3
- balance = "Balance",
4
- position = "Position",
5
- collateral = "Collateral",
6
- cap = "Cap",
7
- vaultV2_absoluteCap = "VaultV2_AbsoluteCap",
8
- vaultV2_relativeCap = "VaultV2_RelativeCap"
9
- }
10
- export interface CapacityLimit {
11
- value: bigint;
12
- limiter: CapacityLimitReason;
13
- }
package/lib/utils.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CapacityLimitReason = void 0;
4
- var CapacityLimitReason;
5
- (function (CapacityLimitReason) {
6
- CapacityLimitReason["liquidity"] = "Liquidity";
7
- CapacityLimitReason["balance"] = "Balance";
8
- CapacityLimitReason["position"] = "Position";
9
- CapacityLimitReason["collateral"] = "Collateral";
10
- CapacityLimitReason["cap"] = "Cap";
11
- CapacityLimitReason["vaultV2_absoluteCap"] = "VaultV2_AbsoluteCap";
12
- CapacityLimitReason["vaultV2_relativeCap"] = "VaultV2_RelativeCap";
13
- })(CapacityLimitReason || (exports.CapacityLimitReason = CapacityLimitReason = {}));
@@ -1,87 +0,0 @@
1
- import { type Address, type Hash, type Hex } from "viem";
2
- import { type RoundingDirection } from "../../math";
3
- import { type IToken, WrappedToken } from "../../token";
4
- import type { BigIntish } from "../../types";
5
- import { type CapacityLimit } from "../../utils";
6
- import type { IAccrualVaultV2Adapter } from "./VaultV2Adapter";
7
- export interface IVaultV2Allocation {
8
- id: Hash;
9
- absoluteCap: bigint;
10
- relativeCap: bigint;
11
- allocation: bigint;
12
- }
13
- export interface IVaultV2 extends IToken {
14
- asset: Address;
15
- /**
16
- * The total assets, *including* virtually accrued interest.
17
- */
18
- totalAssets: bigint;
19
- /**
20
- * The total assets, *excluding* virtually accrued interest.
21
- */
22
- _totalAssets: bigint;
23
- /**
24
- * The total supply of shares.
25
- */
26
- totalSupply: bigint;
27
- virtualShares: bigint;
28
- maxRate: bigint;
29
- lastUpdate: bigint;
30
- adapters: Address[];
31
- liquidityAdapter: Address;
32
- liquidityData: Hex;
33
- liquidityAllocations: IVaultV2Allocation[] | undefined;
34
- performanceFee: bigint;
35
- managementFee: bigint;
36
- performanceFeeRecipient: Address;
37
- managementFeeRecipient: Address;
38
- }
39
- export declare class VaultV2 extends WrappedToken implements IVaultV2 {
40
- readonly asset: Address;
41
- totalAssets: bigint;
42
- _totalAssets: bigint;
43
- totalSupply: bigint;
44
- virtualShares: bigint;
45
- maxRate: bigint;
46
- lastUpdate: bigint;
47
- adapters: `0x${string}`[];
48
- liquidityAdapter: `0x${string}`;
49
- liquidityData: `0x${string}`;
50
- liquidityAllocations: IVaultV2Allocation[] | undefined;
51
- performanceFee: bigint;
52
- managementFee: bigint;
53
- performanceFeeRecipient: `0x${string}`;
54
- managementFeeRecipient: `0x${string}`;
55
- constructor({ asset, totalAssets, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }: IVaultV2);
56
- toAssets(shares: BigIntish): bigint;
57
- toShares(assets: BigIntish): bigint;
58
- protected _wrap(amount: BigIntish, rounding: RoundingDirection): bigint;
59
- protected _unwrap(amount: BigIntish, rounding: RoundingDirection): bigint;
60
- }
61
- export interface IAccrualVaultV2 extends Omit<IVaultV2, "adapters"> {
62
- }
63
- export declare class AccrualVaultV2 extends VaultV2 implements IAccrualVaultV2 {
64
- accrualLiquidityAdapter: IAccrualVaultV2Adapter | undefined;
65
- accrualAdapters: IAccrualVaultV2Adapter[];
66
- assetBalance: bigint;
67
- constructor(vault: IAccrualVaultV2, accrualLiquidityAdapter: IAccrualVaultV2Adapter | undefined, accrualAdapters: IAccrualVaultV2Adapter[], assetBalance: bigint);
68
- /**
69
- * Returns the maximum amount of assets that can be deposited to the vault.
70
- * @param assets The maximum amount of assets to deposit.
71
- */
72
- maxDeposit(assets: BigIntish): CapacityLimit;
73
- /**
74
- * Returns the maximum amount of assets that can be withdrawn from the vault.
75
- * @param shares The maximum amount of shares to redeem.
76
- */
77
- maxWithdraw(shares: BigIntish): CapacityLimit;
78
- /**
79
- * Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
80
- * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the vault's `lastUpdate`.
81
- */
82
- accrueInterest(timestamp: BigIntish): {
83
- vault: AccrualVaultV2;
84
- performanceFeeShares: bigint;
85
- managementFeeShares: bigint;
86
- };
87
- }
@@ -1,159 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccrualVaultV2 = exports.VaultV2 = void 0;
4
- const viem_1 = require("viem");
5
- const errors_1 = require("../../errors");
6
- const math_1 = require("../../math");
7
- const token_1 = require("../../token");
8
- const utils_1 = require("../../utils");
9
- class VaultV2 extends token_1.WrappedToken {
10
- asset;
11
- totalAssets;
12
- _totalAssets;
13
- totalSupply;
14
- virtualShares;
15
- maxRate;
16
- lastUpdate;
17
- adapters;
18
- liquidityAdapter;
19
- liquidityData;
20
- liquidityAllocations;
21
- performanceFee;
22
- managementFee;
23
- performanceFeeRecipient;
24
- managementFeeRecipient;
25
- constructor({ asset, totalAssets, _totalAssets, totalSupply, virtualShares, maxRate, lastUpdate, adapters, liquidityAdapter, liquidityData, liquidityAllocations, performanceFee, managementFee, performanceFeeRecipient, managementFeeRecipient, ...config }) {
26
- super(config, asset);
27
- this.asset = asset;
28
- this.totalAssets = totalAssets;
29
- this._totalAssets = _totalAssets;
30
- this.totalSupply = totalSupply;
31
- this.virtualShares = virtualShares;
32
- this.maxRate = maxRate;
33
- this.lastUpdate = lastUpdate;
34
- this.adapters = adapters;
35
- this.liquidityAdapter = liquidityAdapter;
36
- this.liquidityData = liquidityData;
37
- this.liquidityAllocations = liquidityAllocations;
38
- this.performanceFee = performanceFee;
39
- this.managementFee = managementFee;
40
- this.performanceFeeRecipient = performanceFeeRecipient;
41
- this.managementFeeRecipient = managementFeeRecipient;
42
- }
43
- toAssets(shares) {
44
- return this._unwrap(shares, "Down");
45
- }
46
- toShares(assets) {
47
- return this._wrap(assets, "Down");
48
- }
49
- _wrap(amount, rounding) {
50
- return math_1.MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this.totalAssets + 1n, rounding);
51
- }
52
- _unwrap(amount, rounding) {
53
- return math_1.MathLib.mulDiv(amount, this.totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
54
- }
55
- }
56
- exports.VaultV2 = VaultV2;
57
- class AccrualVaultV2 extends VaultV2 {
58
- accrualLiquidityAdapter;
59
- accrualAdapters;
60
- assetBalance;
61
- constructor(vault, accrualLiquidityAdapter, accrualAdapters, assetBalance) {
62
- super({ ...vault, adapters: accrualAdapters.map((a) => a.address) });
63
- this.accrualLiquidityAdapter = accrualLiquidityAdapter;
64
- this.accrualAdapters = accrualAdapters;
65
- this.assetBalance = assetBalance;
66
- }
67
- /**
68
- * Returns the maximum amount of assets that can be deposited to the vault.
69
- * @param assets The maximum amount of assets to deposit.
70
- */
71
- maxDeposit(assets) {
72
- if (this.liquidityAdapter === viem_1.zeroAddress)
73
- return { value: BigInt(assets), limiter: utils_1.CapacityLimitReason.balance };
74
- let liquidityAdapterLimit;
75
- if (this.accrualLiquidityAdapter != null)
76
- liquidityAdapterLimit = this.accrualLiquidityAdapter.maxDeposit(this.liquidityData, assets);
77
- if (this.liquidityAllocations == null || liquidityAdapterLimit == null)
78
- throw new errors_1.VaultV2Errors.UnsupportedLiquidityAdapter(this.liquidityAdapter);
79
- // At this stage: `liquidityAdapterLimit.value <= assets`
80
- for (const { absoluteCap, relativeCap, allocation } of this
81
- .liquidityAllocations) {
82
- // `absoluteCap` can be set lower than `allocation`.
83
- const absoluteMaxDeposit = math_1.MathLib.zeroFloorSub(absoluteCap, allocation);
84
- if (liquidityAdapterLimit.value > absoluteMaxDeposit)
85
- return {
86
- value: absoluteMaxDeposit,
87
- limiter: utils_1.CapacityLimitReason.vaultV2_absoluteCap,
88
- };
89
- if (relativeCap !== math_1.MathLib.WAD) {
90
- // `relativeCap` can be set lower than `allocation / totalAssets`.
91
- const relativeMaxDeposit = math_1.MathLib.zeroFloorSub(math_1.MathLib.wMulDown(this.totalAssets, relativeCap), allocation);
92
- if (liquidityAdapterLimit.value > relativeMaxDeposit)
93
- return {
94
- value: relativeMaxDeposit,
95
- limiter: utils_1.CapacityLimitReason.vaultV2_relativeCap,
96
- };
97
- }
98
- }
99
- return liquidityAdapterLimit;
100
- }
101
- /**
102
- * Returns the maximum amount of assets that can be withdrawn from the vault.
103
- * @param shares The maximum amount of shares to redeem.
104
- */
105
- maxWithdraw(shares) {
106
- const assets = this.toAssets(shares);
107
- if (this.liquidityAdapter === viem_1.zeroAddress)
108
- return { value: BigInt(assets), limiter: utils_1.CapacityLimitReason.balance };
109
- let liquidity = this.assetBalance;
110
- if (this.accrualLiquidityAdapter != null)
111
- liquidity += this.accrualLiquidityAdapter.maxWithdraw(this.liquidityData).value;
112
- if (assets > liquidity)
113
- return {
114
- value: liquidity,
115
- limiter: utils_1.CapacityLimitReason.liquidity,
116
- };
117
- return {
118
- value: assets,
119
- limiter: utils_1.CapacityLimitReason.balance,
120
- };
121
- }
122
- /**
123
- * Returns a new vault derived from this vault, whose interest has been accrued up to the given timestamp.
124
- * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the vault's `lastUpdate`.
125
- */
126
- accrueInterest(timestamp) {
127
- const vault = new AccrualVaultV2(this, this.accrualLiquidityAdapter, this.accrualAdapters, this.assetBalance);
128
- timestamp = BigInt(timestamp);
129
- const elapsed = timestamp - this.lastUpdate;
130
- if (elapsed < 0n)
131
- throw new errors_1.VaultV2Errors.InvalidInterestAccrual(this.address, timestamp, this.lastUpdate);
132
- // Corresponds to the `firstTotalAssets == 0` onchain check.
133
- if (elapsed === 0n)
134
- return { vault, performanceFeeShares: 0n, managementFeeShares: 0n };
135
- const realAssets = vault.accrualAdapters.reduce((curr, adapter) => curr + adapter.realAssets(timestamp), vault.assetBalance);
136
- const maxTotalAssets = vault._totalAssets +
137
- math_1.MathLib.wMulDown(vault._totalAssets * elapsed, vault.maxRate);
138
- const newTotalAssets = math_1.MathLib.min(realAssets, maxTotalAssets);
139
- const interest = math_1.MathLib.zeroFloorSub(newTotalAssets, vault._totalAssets);
140
- const performanceFeeAssets = interest > 0n && vault.performanceFee > 0n
141
- ? math_1.MathLib.wMulDown(interest, vault.performanceFee)
142
- : 0n;
143
- const managementFeeAssets = elapsed > 0n && vault.managementFee > 0n
144
- ? math_1.MathLib.wMulDown(newTotalAssets * elapsed, vault.managementFee)
145
- : 0n;
146
- const newTotalAssetsWithoutFees = newTotalAssets - performanceFeeAssets - managementFeeAssets;
147
- const performanceFeeShares = math_1.MathLib.mulDivDown(performanceFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
148
- const managementFeeShares = math_1.MathLib.mulDivDown(managementFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
149
- vault.totalAssets = newTotalAssets;
150
- vault._totalAssets = newTotalAssets;
151
- if (performanceFeeShares)
152
- vault.totalSupply += performanceFeeShares;
153
- if (managementFeeShares)
154
- vault.totalSupply += managementFeeShares;
155
- vault.lastUpdate = BigInt(timestamp);
156
- return { vault, performanceFeeShares, managementFeeShares };
157
- }
158
- }
159
- exports.AccrualVaultV2 = AccrualVaultV2;
@@ -1,29 +0,0 @@
1
- import type { Address, Hash, Hex } from "viem";
2
- import type { BigIntish } from "../../types";
3
- import type { CapacityLimit } from "../../utils";
4
- export interface IVaultV2Adapter {
5
- address: Address;
6
- parentVault: Address;
7
- adapterId: Hash;
8
- skimRecipient: Address;
9
- }
10
- export declare abstract class VaultV2Adapter implements IVaultV2Adapter {
11
- readonly address: Address;
12
- readonly parentVault: Address;
13
- readonly adapterId: Hash;
14
- skimRecipient: Address;
15
- constructor({ address, parentVault, adapterId, skimRecipient, }: IVaultV2Adapter);
16
- }
17
- export interface IAccrualVaultV2Adapter extends IVaultV2Adapter {
18
- realAssets(timestamp: BigIntish): bigint;
19
- /**
20
- * Returns the maximum amount of assets that can be deposited to this adapter.
21
- * @param assets The maximum amount of assets to deposit.
22
- */
23
- maxDeposit(data: Hex, assets: BigIntish): CapacityLimit;
24
- /**
25
- * Returns the maximum amount of assets that can be withdrawn from this adapter.
26
- * @param shares The maximum amount of shares to redeem.
27
- */
28
- maxWithdraw(data: Hex): CapacityLimit;
29
- }
@@ -1,16 +0,0 @@
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;
@@ -1,30 +0,0 @@
1
- import { type Address, type Hex } from "viem";
2
- import { type IMarketParams, MarketParams } from "../../market";
3
- import type { AccrualPosition } from "../../position";
4
- import type { BigIntish } from "../../types";
5
- import { CapacityLimitReason } from "../../utils";
6
- import { VaultV2Adapter } from "./VaultV2Adapter";
7
- import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter";
8
- export interface IVaultV2MorphoMarketV1Adapter extends Omit<IVaultV2Adapter, "adapterId"> {
9
- marketParamsList: IMarketParams[];
10
- }
11
- export declare class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter implements IVaultV2MorphoMarketV1Adapter {
12
- static adapterId(address: Address): `0x${string}`;
13
- static collateralId(address: Address): `0x${string}`;
14
- static marketParamsId(address: Address, params: MarketParams): `0x${string}`;
15
- marketParamsList: MarketParams[];
16
- constructor({ marketParamsList, ...vaultV2Adapter }: IVaultV2MorphoMarketV1Adapter);
17
- ids(params: MarketParams): `0x${string}`[];
18
- }
19
- export interface IAccrualVaultV2MorphoMarketV1Adapter extends IVaultV2MorphoMarketV1Adapter {
20
- }
21
- export declare class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMarketV1Adapter implements IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2Adapter {
22
- positions: AccrualPosition[];
23
- constructor(adapter: IAccrualVaultV2MorphoMarketV1Adapter, positions: AccrualPosition[]);
24
- realAssets(timestamp?: BigIntish): bigint;
25
- maxDeposit(_data: Hex, assets: BigIntish): {
26
- value: bigint;
27
- limiter: CapacityLimitReason;
28
- };
29
- maxWithdraw(data: Hex): import("../../utils").CapacityLimit;
30
- }
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccrualVaultV2MorphoMarketV1Adapter = exports.VaultV2MorphoMarketV1Adapter = void 0;
4
- const viem_1 = require("viem");
5
- const market_1 = require("../../market");
6
- const utils_1 = require("../../utils");
7
- const VaultV2Adapter_1 = require("./VaultV2Adapter");
8
- class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter_1.VaultV2Adapter {
9
- static adapterId(address) {
10
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["this", address]));
11
- }
12
- static collateralId(address) {
13
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["collateralToken", address]));
14
- }
15
- static marketParamsId(address, params) {
16
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }, market_1.marketParamsAbi], ["this/marketParams", address, params]));
17
- }
18
- marketParamsList;
19
- constructor({ marketParamsList, ...vaultV2Adapter }) {
20
- super({
21
- ...vaultV2Adapter,
22
- adapterId: VaultV2MorphoMarketV1Adapter.adapterId(vaultV2Adapter.address),
23
- });
24
- this.marketParamsList = marketParamsList.map((params) => new market_1.MarketParams(params));
25
- }
26
- ids(params) {
27
- return [
28
- this.adapterId,
29
- VaultV2MorphoMarketV1Adapter.collateralId(params.collateralToken),
30
- VaultV2MorphoMarketV1Adapter.marketParamsId(this.address, params),
31
- ];
32
- }
33
- }
34
- exports.VaultV2MorphoMarketV1Adapter = VaultV2MorphoMarketV1Adapter;
35
- class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMarketV1Adapter {
36
- positions;
37
- constructor(adapter, positions) {
38
- super(adapter);
39
- this.positions = positions;
40
- }
41
- realAssets(timestamp) {
42
- return this.positions.reduce((total, position) => total + position.accrueInterest(timestamp).supplyAssets, 0n);
43
- }
44
- maxDeposit(_data, assets) {
45
- return {
46
- value: BigInt(assets),
47
- limiter: utils_1.CapacityLimitReason.balance,
48
- };
49
- }
50
- maxWithdraw(data) {
51
- const marketId = market_1.MarketParams.fromHex(data).id;
52
- const position = this.positions.find((position) => position.marketId === marketId);
53
- return (position?.market?.getWithdrawCapacityLimit(position) ?? {
54
- value: 0n,
55
- limiter: utils_1.CapacityLimitReason.position,
56
- });
57
- }
58
- }
59
- exports.AccrualVaultV2MorphoMarketV1Adapter = AccrualVaultV2MorphoMarketV1Adapter;
@@ -1,24 +0,0 @@
1
- import { type Address, type Hex } from "viem";
2
- import { VaultV2Adapter } from "./VaultV2Adapter";
3
- export interface IVaultV2MorphoVaultV1Adapter extends Omit<IVaultV2Adapter, "adapterId"> {
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
- static adapterId(address: Address): `0x${string}`;
11
- readonly morphoVaultV1: Address;
12
- constructor({ morphoVaultV1, ...vaultV2Adapter }: IVaultV2MorphoVaultV1Adapter);
13
- ids(): `0x${string}`[];
14
- }
15
- export interface IAccrualVaultV2MorphoVaultV1Adapter extends IVaultV2MorphoVaultV1Adapter {
16
- }
17
- export declare class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter implements IAccrualVaultV2MorphoVaultV1Adapter, IAccrualVaultV2Adapter {
18
- accrualVaultV1: AccrualVault;
19
- shares: bigint;
20
- constructor(adapter: IAccrualVaultV2MorphoVaultV1Adapter, accrualVaultV1: AccrualVault, shares: bigint);
21
- realAssets(timestamp?: BigIntish): bigint;
22
- maxDeposit(_data: Hex, assets: BigIntish): import("../..").CapacityLimit;
23
- maxWithdraw(_data: Hex): import("../..").CapacityLimit;
24
- }