@morpho-org/blue-sdk 5.3.0-next.1 → 5.3.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.
@@ -437,6 +437,19 @@ declare const _addressesRegistry: {
437
437
  readonly wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7";
438
438
  readonly usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392";
439
439
  };
440
+ readonly 16661: {
441
+ readonly morpho: "0x9CDD13a2212D94C4f12190cA30783B743E83C89e";
442
+ readonly bundler3: {
443
+ readonly bundler3: "0xbDaFC7ceF85C5fF69164330F521089C9E15DDDae";
444
+ readonly generalAdapter1: "0xFaD987d0EedfbAC709EC27ee4a94f36A1300a054";
445
+ };
446
+ readonly adaptiveCurveIrm: "0xf52e20C42FEc624819D4184226C4777D7cbd767e";
447
+ readonly publicAllocator: "0x28a80F3713735CAD44bD9d7E1da9Fa16b0244497";
448
+ readonly metaMorphoFactory: "0x41528AadC7314658b07Ca6e7213B9b77289B477f";
449
+ readonly chainlinkOracleFactory: "0x5115c1a74ABf096150593EecF3e20F016fc9dB43";
450
+ readonly preLiquidationFactory: "0x534858821653467c2ae231dc027aa1F2c8D91802";
451
+ readonly wNative: "0x1Cd0690fF9a693f5EF2dD976660a8dAFc81A109c";
452
+ };
440
453
  };
441
454
  export type ChainDeployments<Addresses = ChainAddresses> = {
442
455
  [key in keyof Addresses]: Address extends Addresses[key] ? bigint : ChainDeployments<Addresses[key]>;
@@ -773,6 +786,18 @@ declare const _deployments: {
773
786
  readonly preLiquidationFactory: 168897284n;
774
787
  readonly usdc: 154131168n;
775
788
  };
789
+ readonly 16661: {
790
+ readonly morpho: 7526486n;
791
+ readonly bundler3: {
792
+ readonly bundler3: 7527649n;
793
+ readonly generalAdapter1: 7527649n;
794
+ };
795
+ readonly adaptiveCurveIrm: 7526486n;
796
+ readonly publicAllocator: 7526486n;
797
+ readonly metaMorphoFactory: 7526768n;
798
+ readonly chainlinkOracleFactory: 7526768n;
799
+ readonly preLiquidationFactory: 7527649n;
800
+ };
776
801
  };
777
802
  export type AddressLabel = DottedKeys<(typeof _addressesRegistry)[ChainId]>;
778
803
  export declare const getChainAddresses: (chainId: number) => ChainAddresses;
@@ -1194,6 +1219,19 @@ export declare let addressesRegistry: {
1194
1219
  readonly wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7";
1195
1220
  readonly usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392";
1196
1221
  };
1222
+ readonly 16661: {
1223
+ readonly morpho: "0x9CDD13a2212D94C4f12190cA30783B743E83C89e";
1224
+ readonly bundler3: {
1225
+ readonly bundler3: "0xbDaFC7ceF85C5fF69164330F521089C9E15DDDae";
1226
+ readonly generalAdapter1: "0xFaD987d0EedfbAC709EC27ee4a94f36A1300a054";
1227
+ };
1228
+ readonly adaptiveCurveIrm: "0xf52e20C42FEc624819D4184226C4777D7cbd767e";
1229
+ readonly publicAllocator: "0x28a80F3713735CAD44bD9d7E1da9Fa16b0244497";
1230
+ readonly metaMorphoFactory: "0x41528AadC7314658b07Ca6e7213B9b77289B477f";
1231
+ readonly chainlinkOracleFactory: "0x5115c1a74ABf096150593EecF3e20F016fc9dB43";
1232
+ readonly preLiquidationFactory: "0x534858821653467c2ae231dc027aa1F2c8D91802";
1233
+ readonly wNative: "0x1Cd0690fF9a693f5EF2dD976660a8dAFc81A109c";
1234
+ };
1197
1235
  };
1198
1236
  export declare let addresses: Record<number, ChainAddresses>;
1199
1237
  export declare let deployments: {
@@ -1528,6 +1566,18 @@ export declare let deployments: {
1528
1566
  readonly preLiquidationFactory: 168897284n;
1529
1567
  readonly usdc: 154131168n;
1530
1568
  };
1569
+ readonly 16661: {
1570
+ readonly morpho: 7526486n;
1571
+ readonly bundler3: {
1572
+ readonly bundler3: 7527649n;
1573
+ readonly generalAdapter1: 7527649n;
1574
+ };
1575
+ readonly adaptiveCurveIrm: 7526486n;
1576
+ readonly publicAllocator: 7526486n;
1577
+ readonly metaMorphoFactory: 7526768n;
1578
+ readonly chainlinkOracleFactory: 7526768n;
1579
+ readonly preLiquidationFactory: 7527649n;
1580
+ };
1531
1581
  };
1532
1582
  export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`, `0x${string}`>>;
1533
1583
  /**
package/lib/addresses.js CHANGED
@@ -426,6 +426,19 @@ const _addressesRegistry = {
426
426
  wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7",
427
427
  usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392",
428
428
  },
429
+ [chain_js_1.ChainId.ZeroGMainnet]: {
430
+ morpho: "0x9CDD13a2212D94C4f12190cA30783B743E83C89e",
431
+ bundler3: {
432
+ bundler3: "0xbDaFC7ceF85C5fF69164330F521089C9E15DDDae",
433
+ generalAdapter1: "0xFaD987d0EedfbAC709EC27ee4a94f36A1300a054",
434
+ },
435
+ adaptiveCurveIrm: "0xf52e20C42FEc624819D4184226C4777D7cbd767e",
436
+ publicAllocator: "0x28a80F3713735CAD44bD9d7E1da9Fa16b0244497",
437
+ metaMorphoFactory: "0x41528AadC7314658b07Ca6e7213B9b77289B477f",
438
+ chainlinkOracleFactory: "0x5115c1a74ABf096150593EecF3e20F016fc9dB43",
439
+ preLiquidationFactory: "0x534858821653467c2ae231dc027aa1F2c8D91802",
440
+ wNative: "0x1Cd0690fF9a693f5EF2dD976660a8dAFc81A109c",
441
+ },
429
442
  };
430
443
  const _deployments = {
431
444
  [chain_js_1.ChainId.EthMainnet]: {
@@ -759,6 +772,18 @@ const _deployments = {
759
772
  preLiquidationFactory: 168897284n,
760
773
  usdc: 154131168n,
761
774
  },
775
+ [chain_js_1.ChainId.ZeroGMainnet]: {
776
+ morpho: 7526486n,
777
+ bundler3: {
778
+ bundler3: 7527649n,
779
+ generalAdapter1: 7527649n,
780
+ },
781
+ adaptiveCurveIrm: 7526486n,
782
+ publicAllocator: 7526486n,
783
+ metaMorphoFactory: 7526768n,
784
+ chainlinkOracleFactory: 7526768n,
785
+ preLiquidationFactory: 7527649n,
786
+ },
762
787
  };
763
788
  const getChainAddresses = (chainId) => {
764
789
  const chainAddresses = exports.addresses[chainId];
@@ -847,6 +872,9 @@ const _unwrappedTokensMapping = {
847
872
  [chain_js_1.ChainId.SeiMainnet]: {
848
873
  [_addressesRegistry[chain_js_1.ChainId.SeiMainnet].wNative]: exports.NATIVE_ADDRESS,
849
874
  },
875
+ [chain_js_1.ChainId.ZeroGMainnet]: {
876
+ [_addressesRegistry[chain_js_1.ChainId.ZeroGMainnet].wNative]: exports.NATIVE_ADDRESS,
877
+ },
850
878
  };
851
879
  function getUnwrappedToken(wrappedToken, chainId) {
852
880
  return exports.unwrappedTokensMapping[chainId]?.[wrappedToken];
package/lib/chain.d.ts CHANGED
@@ -20,7 +20,8 @@ export declare enum ChainId {
20
20
  TacMainnet = 239,
21
21
  LiskMainnet = 1135,
22
22
  HyperliquidMainnet = 999,
23
- SeiMainnet = 1329
23
+ SeiMainnet = 1329,
24
+ ZeroGMainnet = 16661
24
25
  }
25
26
  export interface ChainMetadata {
26
27
  readonly name: string;
@@ -281,5 +282,16 @@ export declare namespace ChainUtils {
281
282
  explorerUrl: string;
282
283
  identifier: string;
283
284
  };
285
+ 16661: {
286
+ name: string;
287
+ id: ChainId.ZeroGMainnet;
288
+ nativeCurrency: {
289
+ name: string;
290
+ symbol: string;
291
+ decimals: number;
292
+ };
293
+ explorerUrl: string;
294
+ identifier: string;
295
+ };
284
296
  };
285
297
  }
package/lib/chain.js CHANGED
@@ -25,6 +25,7 @@ var ChainId;
25
25
  ChainId[ChainId["LiskMainnet"] = 1135] = "LiskMainnet";
26
26
  ChainId[ChainId["HyperliquidMainnet"] = 999] = "HyperliquidMainnet";
27
27
  ChainId[ChainId["SeiMainnet"] = 1329] = "SeiMainnet";
28
+ ChainId[ChainId["ZeroGMainnet"] = 16661] = "ZeroGMainnet";
28
29
  })(ChainId || (exports.ChainId = ChainId = {}));
29
30
  var ChainUtils;
30
31
  (function (ChainUtils) {
@@ -195,5 +196,12 @@ var ChainUtils;
195
196
  explorerUrl: "https://seitrace.com",
196
197
  identifier: "sei",
197
198
  },
199
+ [ChainId.ZeroGMainnet]: {
200
+ name: "0G",
201
+ id: ChainId.ZeroGMainnet,
202
+ nativeCurrency: { name: "0G", symbol: "0G", decimals: 18 },
203
+ explorerUrl: "https://chainscan.0g.ai",
204
+ identifier: "0G",
205
+ },
198
206
  };
199
207
  })(ChainUtils || (exports.ChainUtils = ChainUtils = {}));
package/lib/errors.d.ts CHANGED
@@ -25,10 +25,6 @@ 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
- }
32
28
  export declare namespace BlueErrors {
33
29
  class AlreadySet extends Error {
34
30
  readonly name: string;
@@ -69,18 +65,6 @@ export declare namespace BlueErrors {
69
65
  constructor(deadline: bigint);
70
66
  }
71
67
  }
72
- export declare namespace VaultV2Errors {
73
- class InvalidInterestAccrual extends Error {
74
- readonly vault: Address;
75
- readonly timestamp: bigint;
76
- readonly lastUpdate: bigint;
77
- constructor(vault: Address, timestamp: bigint, lastUpdate: bigint);
78
- }
79
- class UnsupportedLiquidityAdapter extends Error {
80
- readonly address: Address;
81
- constructor(address: Address);
82
- }
83
- }
84
68
  export interface ErrorClass<E extends Error> {
85
69
  new (...args: any[]): E;
86
70
  }
package/lib/errors.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VaultV2Errors = exports.BlueErrors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
3
+ exports.BlueErrors = 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,14 +54,6 @@ 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;
65
57
  var BlueErrors;
66
58
  (function (BlueErrors) {
67
59
  class AlreadySet extends Error {
@@ -141,29 +133,6 @@ var BlueErrors;
141
133
  }
142
134
  BlueErrors.ExpiredSignature = ExpiredSignature;
143
135
  })(BlueErrors || (exports.BlueErrors = BlueErrors = {}));
144
- var VaultV2Errors;
145
- (function (VaultV2Errors) {
146
- class InvalidInterestAccrual extends Error {
147
- vault;
148
- timestamp;
149
- lastUpdate;
150
- constructor(vault, timestamp, lastUpdate) {
151
- super(`invalid interest accrual on vault ${vault}: accrual timestamp ${timestamp} can't be prior to last update ${lastUpdate}`);
152
- this.vault = vault;
153
- this.timestamp = timestamp;
154
- this.lastUpdate = lastUpdate;
155
- }
156
- }
157
- VaultV2Errors.InvalidInterestAccrual = InvalidInterestAccrual;
158
- class UnsupportedLiquidityAdapter extends Error {
159
- address;
160
- constructor(address) {
161
- super(`unsupported liquidity adapter "${address}"`);
162
- this.address = address;
163
- }
164
- }
165
- VaultV2Errors.UnsupportedLiquidityAdapter = UnsupportedLiquidityAdapter;
166
- })(VaultV2Errors || (exports.VaultV2Errors = VaultV2Errors = {}));
167
136
  function _try(accessor, ...errorClasses) {
168
137
  const maybeCatchError = (error) => {
169
138
  if (errorClasses.length === 0 ||
package/lib/index.d.ts CHANGED
@@ -11,4 +11,3 @@ 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 "./utils.js";
package/lib/index.js CHANGED
@@ -27,4 +27,3 @@ __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("./utils.js"), exports);
@@ -1,7 +1,17 @@
1
1
  import { type RoundingDirection } from "../math/index.js";
2
2
  import type { BigIntish } from "../types.js";
3
- import { type CapacityLimit } from "../utils.js";
4
3
  import { type IMarketParams, MarketParams } from "./MarketParams.js";
4
+ export declare enum CapacityLimitReason {
5
+ liquidity = "Liquidity",
6
+ balance = "Balance",
7
+ position = "Position",
8
+ collateral = "Collateral",
9
+ cap = "Cap"
10
+ }
11
+ export interface CapacityLimit {
12
+ value: bigint;
13
+ limiter: CapacityLimitReason;
14
+ }
5
15
  export interface MaxBorrowOptions {
6
16
  maxLtv?: bigint;
7
17
  }
@@ -1,12 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Market = void 0;
3
+ exports.Market = exports.CapacityLimitReason = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
5
  const errors_js_1 = require("../errors.js");
6
6
  const index_js_1 = require("../math/index.js");
7
- const utils_js_1 = require("../utils.js");
8
7
  const MarketParams_js_1 = require("./MarketParams.js");
9
8
  const MarketUtils_js_1 = require("./MarketUtils.js");
9
+ var CapacityLimitReason;
10
+ (function (CapacityLimitReason) {
11
+ CapacityLimitReason["liquidity"] = "Liquidity";
12
+ CapacityLimitReason["balance"] = "Balance";
13
+ CapacityLimitReason["position"] = "Position";
14
+ CapacityLimitReason["collateral"] = "Collateral";
15
+ CapacityLimitReason["cap"] = "Cap";
16
+ })(CapacityLimitReason || (exports.CapacityLimitReason = CapacityLimitReason = {}));
10
17
  /**
11
18
  * Represents a lending market on Morpho Blue.
12
19
  */
@@ -50,7 +57,8 @@ class Market {
50
57
  */
51
58
  rateAtTarget;
52
59
  constructor({ params, totalSupplyAssets, totalBorrowAssets, totalSupplyShares, totalBorrowShares, lastUpdate, fee, price, rateAtTarget, }) {
53
- this.params = new MarketParams_js_1.MarketParams(params);
60
+ this.params =
61
+ params instanceof MarketParams_js_1.MarketParams ? params : new MarketParams_js_1.MarketParams(params);
54
62
  this.totalSupplyAssets = totalSupplyAssets;
55
63
  this.totalBorrowAssets = totalBorrowAssets;
56
64
  this.totalSupplyShares = totalSupplyShares;
@@ -490,11 +498,11 @@ class Market {
490
498
  if (maxBorrowableAssets > liquidity)
491
499
  return {
492
500
  value: liquidity,
493
- limiter: utils_js_1.CapacityLimitReason.liquidity,
501
+ limiter: CapacityLimitReason.liquidity,
494
502
  };
495
503
  return {
496
504
  value: maxBorrowableAssets,
497
- limiter: utils_js_1.CapacityLimitReason.collateral,
505
+ limiter: CapacityLimitReason.collateral,
498
506
  };
499
507
  }
500
508
  /**
@@ -507,11 +515,11 @@ class Market {
507
515
  if (borrowAssets > loanTokenBalance)
508
516
  return {
509
517
  value: loanTokenBalance,
510
- limiter: utils_js_1.CapacityLimitReason.balance,
518
+ limiter: CapacityLimitReason.balance,
511
519
  };
512
520
  return {
513
521
  value: borrowAssets,
514
- limiter: utils_js_1.CapacityLimitReason.position,
522
+ limiter: CapacityLimitReason.position,
515
523
  };
516
524
  }
517
525
  /**
@@ -525,11 +533,11 @@ class Market {
525
533
  if (supplyAssets > liquidity)
526
534
  return {
527
535
  value: liquidity,
528
- limiter: utils_js_1.CapacityLimitReason.liquidity,
536
+ limiter: CapacityLimitReason.liquidity,
529
537
  };
530
538
  return {
531
539
  value: supplyAssets,
532
- limiter: utils_js_1.CapacityLimitReason.position,
540
+ limiter: CapacityLimitReason.position,
533
541
  };
534
542
  }
535
543
  /**
@@ -545,11 +553,11 @@ class Market {
545
553
  if (position.collateral > withdrawableCollateral)
546
554
  return {
547
555
  value: withdrawableCollateral,
548
- limiter: utils_js_1.CapacityLimitReason.collateral,
556
+ limiter: CapacityLimitReason.collateral,
549
557
  };
550
558
  return {
551
559
  value: position.collateral,
552
- limiter: utils_js_1.CapacityLimitReason.position,
560
+ limiter: CapacityLimitReason.position,
553
561
  };
554
562
  }
555
563
  /**
@@ -563,14 +571,14 @@ class Market {
563
571
  return {
564
572
  supply: {
565
573
  value: loanTokenBalance,
566
- limiter: utils_js_1.CapacityLimitReason.balance,
574
+ limiter: CapacityLimitReason.balance,
567
575
  },
568
576
  withdraw: this.getWithdrawCapacityLimit(position),
569
577
  borrow: this.getBorrowCapacityLimit(position, options?.borrow),
570
578
  repay: this.getRepayCapacityLimit(position.borrowShares, loanTokenBalance),
571
579
  supplyCollateral: {
572
580
  value: collateralTokenBalance,
573
- limiter: utils_js_1.CapacityLimitReason.balance,
581
+ limiter: CapacityLimitReason.balance,
574
582
  },
575
583
  withdrawCollateral: this.getWithdrawCollateralCapacityLimit(position, options?.withdrawCollateral),
576
584
  };
@@ -109,7 +109,7 @@ export declare class AccrualPosition extends Position implements IAccrualPositio
109
109
  * Returns the maximum amount of loan assets that can be withdrawn given a certain supply position
110
110
  * and a balance of loan assets, and the reason for the limit.
111
111
  */
112
- get withdrawCapacityLimit(): import("../utils.js").CapacityLimit;
112
+ get withdrawCapacityLimit(): import("../market/Market.js").CapacityLimit;
113
113
  /**
114
114
  * Returns a new position derived from this position, whose interest has been accrued up to the given timestamp.
115
115
  * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the market's `lastUpdate`.
@@ -137,9 +137,9 @@ export declare class AccrualPosition extends Position implements IAccrualPositio
137
137
  assets: bigint;
138
138
  shares: bigint;
139
139
  };
140
- getBorrowCapacityLimit(options?: MaxBorrowOptions): import("../utils.js").CapacityLimit | undefined;
141
- getWithdrawCollateralCapacityLimit(options?: MaxWithdrawCollateralOptions): import("../utils.js").CapacityLimit | undefined;
142
- getRepayCapacityLimit(loanTokenBalance: bigint): import("../utils.js").CapacityLimit;
140
+ getBorrowCapacityLimit(options?: MaxBorrowOptions): import("../market/Market.js").CapacityLimit | undefined;
141
+ getWithdrawCollateralCapacityLimit(options?: MaxWithdrawCollateralOptions): import("../market/Market.js").CapacityLimit | undefined;
142
+ getRepayCapacityLimit(loanTokenBalance: bigint): import("../market/Market.js").CapacityLimit;
143
143
  getMaxCapacities(loanTokenBalance: bigint, collateralTokenBalance: bigint, options?: {
144
144
  borrow?: MaxBorrowOptions;
145
145
  withdrawCollateral?: MaxWithdrawCollateralOptions;
@@ -4,7 +4,6 @@ exports.AccrualPosition = exports.Position = void 0;
4
4
  const errors_js_1 = require("../errors.js");
5
5
  const index_js_1 = require("../market/index.js");
6
6
  const MathLib_js_1 = require("../math/MathLib.js");
7
- const utils_js_1 = require("../utils.js");
8
7
  class Position {
9
8
  /**
10
9
  * The user holding this position.
@@ -226,14 +225,14 @@ class AccrualPosition extends Position {
226
225
  return {
227
226
  supply: {
228
227
  value: loanTokenBalance,
229
- limiter: utils_js_1.CapacityLimitReason.balance,
228
+ limiter: index_js_1.CapacityLimitReason.balance,
230
229
  },
231
230
  withdraw: this.withdrawCapacityLimit,
232
231
  borrow: this.getBorrowCapacityLimit(options?.borrow),
233
232
  repay: this.getRepayCapacityLimit(loanTokenBalance),
234
233
  supplyCollateral: {
235
234
  value: collateralTokenBalance,
236
- limiter: utils_js_1.CapacityLimitReason.balance,
235
+ limiter: index_js_1.CapacityLimitReason.balance,
237
236
  },
238
237
  withdrawCollateral: this.getWithdrawCollateralCapacityLimit(options?.withdrawCollateral),
239
238
  };
@@ -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.1",
4
+ "version": "5.3.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -29,10 +29,10 @@
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/test": "^2.6.0",
35
- "@morpho-org/morpho-ts": "^2.4.3"
34
+ "@morpho-org/morpho-ts": "^2.4.3",
35
+ "@morpho-org/test": "^2.6.0"
36
36
  },
37
37
  "scripts": {
38
38
  "prepublish": "$npm_execpath build",
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,70 +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
- const marketParamsAbi = {
9
- type: "tuple",
10
- components: [
11
- { type: "address", name: "loanToken" },
12
- { type: "address", name: "collateralToken" },
13
- { type: "address", name: "oracle" },
14
- { type: "address", name: "irm" },
15
- { type: "uint256", name: "lltv" },
16
- ],
17
- };
18
- class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter_1.VaultV2Adapter {
19
- static adapterId(address) {
20
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["this", address]));
21
- }
22
- static collateralId(address) {
23
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["collateralToken", address]));
24
- }
25
- static marketParamsId(address, params) {
26
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }, marketParamsAbi], ["this/marketParams", address, params]));
27
- }
28
- marketParamsList;
29
- constructor({ marketParamsList, ...vaultV2Adapter }) {
30
- super({
31
- ...vaultV2Adapter,
32
- adapterId: VaultV2MorphoMarketV1Adapter.adapterId(vaultV2Adapter.address),
33
- });
34
- this.marketParamsList = marketParamsList.map((params) => new market_1.MarketParams(params));
35
- }
36
- ids(params) {
37
- return [
38
- this.adapterId,
39
- VaultV2MorphoMarketV1Adapter.collateralId(params.collateralToken),
40
- VaultV2MorphoMarketV1Adapter.marketParamsId(this.address, params),
41
- ];
42
- }
43
- }
44
- exports.VaultV2MorphoMarketV1Adapter = VaultV2MorphoMarketV1Adapter;
45
- class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMarketV1Adapter {
46
- positions;
47
- constructor(adapter, positions) {
48
- super(adapter);
49
- this.positions = positions;
50
- }
51
- realAssets(timestamp) {
52
- return this.positions.reduce((total, position) => total + position.accrueInterest(timestamp).supplyAssets, 0n);
53
- }
54
- maxDeposit(_data, assets) {
55
- return {
56
- value: BigInt(assets),
57
- limiter: utils_1.CapacityLimitReason.balance,
58
- };
59
- }
60
- maxWithdraw(_data) {
61
- const [marketParams] = (0, viem_1.decodeAbiParameters)([marketParamsAbi], _data);
62
- const marketId = new market_1.MarketParams(marketParams).id;
63
- const position = this.positions.find((position) => position.marketId === marketId);
64
- return (position?.market?.getWithdrawCapacityLimit(position) ?? {
65
- value: 0n,
66
- limiter: utils_1.CapacityLimitReason.position,
67
- });
68
- }
69
- }
70
- 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
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccrualVaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoVaultV1Adapter = void 0;
4
- const viem_1 = require("viem");
5
- const VaultV2Adapter_1 = require("./VaultV2Adapter");
6
- class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter_1.VaultV2Adapter {
7
- static adapterId(address) {
8
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["this", address]));
9
- }
10
- morphoVaultV1;
11
- constructor({ morphoVaultV1, ...vaultV2Adapter }) {
12
- super({
13
- ...vaultV2Adapter,
14
- adapterId: VaultV2MorphoVaultV1Adapter.adapterId(vaultV2Adapter.address),
15
- });
16
- this.morphoVaultV1 = morphoVaultV1;
17
- }
18
- ids() {
19
- return [this.adapterId];
20
- }
21
- }
22
- exports.VaultV2MorphoVaultV1Adapter = VaultV2MorphoVaultV1Adapter;
23
- class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter {
24
- accrualVaultV1;
25
- shares;
26
- constructor(adapter, accrualVaultV1, shares) {
27
- super(adapter);
28
- this.accrualVaultV1 = accrualVaultV1;
29
- this.shares = shares;
30
- }
31
- realAssets(timestamp) {
32
- return this.accrualVaultV1.accrueInterest(timestamp).toAssets(this.shares);
33
- }
34
- maxDeposit(_data, assets) {
35
- return this.accrualVaultV1.maxDeposit(assets);
36
- }
37
- maxWithdraw(_data) {
38
- return this.accrualVaultV1.maxWithdraw(this.shares);
39
- }
40
- }
41
- exports.AccrualVaultV2MorphoVaultV1Adapter = AccrualVaultV2MorphoVaultV1Adapter;
@@ -1,4 +0,0 @@
1
- export * from "./VaultV2.js";
2
- export * from "./VaultV2Adapter.js";
3
- export * from "./VaultV2MorphoMarketV1Adapter.js";
4
- export * from "./VaultV2MorphoVaultV1Adapter.js";
@@ -1,20 +0,0 @@
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("./VaultV2MorphoMarketV1Adapter.js"), exports);
20
- __exportStar(require("./VaultV2MorphoVaultV1Adapter.js"), exports);