@morpho-org/blue-sdk 5.15.0 → 5.17.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.
Files changed (184) hide show
  1. package/lib/{errors.d.ts → cjs/errors.d.ts} +8 -0
  2. package/lib/{errors.js → cjs/errors.js} +17 -1
  3. package/lib/cjs/package.json +1 -0
  4. package/lib/{position → cjs/position}/PreLiquidationPosition.d.ts +3 -3
  5. package/lib/{position → cjs/position}/PreLiquidationPosition.js +16 -16
  6. package/lib/{preLiquidation.d.ts → cjs/preLiquidation.d.ts} +1 -1
  7. package/lib/{preLiquidation.js → cjs/preLiquidation.js} +2 -2
  8. package/lib/{vault → cjs/vault}/index.d.ts +1 -1
  9. package/lib/{vault → cjs/vault}/index.js +1 -1
  10. package/lib/{vault → cjs/vault}/v2/VaultV2.d.ts +5 -5
  11. package/lib/{vault → cjs/vault}/v2/VaultV2.js +25 -25
  12. package/lib/{vault → cjs/vault}/v2/VaultV2Adapter.d.ts +2 -2
  13. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoMarketV1Adapter.d.ts +7 -7
  14. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoMarketV1Adapter.js +9 -9
  15. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +6 -6
  16. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoMarketV1AdapterV2.js +8 -8
  17. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoVaultV1Adapter.d.ts +6 -6
  18. package/lib/{vault → cjs/vault}/v2/VaultV2MorphoVaultV1Adapter.js +2 -2
  19. package/lib/esm/addresses.d.ts +2231 -0
  20. package/lib/esm/addresses.js +1309 -0
  21. package/lib/esm/chain.d.ts +405 -0
  22. package/lib/esm/chain.js +276 -0
  23. package/lib/esm/constants.d.ts +20 -0
  24. package/lib/esm/constants.js +21 -0
  25. package/lib/esm/errors.d.ts +101 -0
  26. package/lib/esm/errors.js +192 -0
  27. package/lib/esm/holding/AssetBalances.d.ts +48 -0
  28. package/lib/esm/holding/AssetBalances.js +38 -0
  29. package/lib/esm/holding/Holding.d.ts +63 -0
  30. package/lib/esm/holding/Holding.js +63 -0
  31. package/lib/esm/holding/index.d.ts +2 -0
  32. package/lib/esm/holding/index.js +2 -0
  33. package/lib/esm/index.d.ts +14 -0
  34. package/lib/esm/index.js +14 -0
  35. package/lib/esm/market/Market.d.ts +424 -0
  36. package/lib/esm/market/Market.js +576 -0
  37. package/lib/esm/market/MarketParams.d.ts +74 -0
  38. package/lib/esm/market/MarketParams.js +91 -0
  39. package/lib/esm/market/MarketUtils.d.ts +273 -0
  40. package/lib/esm/market/MarketUtils.js +323 -0
  41. package/lib/esm/market/index.d.ts +3 -0
  42. package/lib/esm/market/index.js +3 -0
  43. package/lib/esm/math/AdaptiveCurveIrmLib.d.ts +40 -0
  44. package/lib/esm/math/AdaptiveCurveIrmLib.js +133 -0
  45. package/lib/esm/math/MathLib.d.ts +102 -0
  46. package/lib/esm/math/MathLib.js +168 -0
  47. package/lib/esm/math/SharesMath.d.ts +12 -0
  48. package/lib/esm/math/SharesMath.js +18 -0
  49. package/lib/esm/math/index.d.ts +3 -0
  50. package/lib/esm/math/index.js +3 -0
  51. package/lib/esm/package.json +1 -0
  52. package/lib/esm/position/Position.d.ts +147 -0
  53. package/lib/esm/position/Position.js +237 -0
  54. package/lib/esm/position/PreLiquidationPosition.d.ts +60 -0
  55. package/lib/esm/position/PreLiquidationPosition.js +97 -0
  56. package/lib/esm/position/index.d.ts +2 -0
  57. package/lib/esm/position/index.js +2 -0
  58. package/lib/esm/preLiquidation.d.ts +15 -0
  59. package/lib/esm/preLiquidation.js +91 -0
  60. package/lib/esm/token/ConstantWrappedToken.d.ts +17 -0
  61. package/lib/esm/token/ConstantWrappedToken.js +30 -0
  62. package/lib/esm/token/Eip5267Domain.d.ts +55 -0
  63. package/lib/esm/token/Eip5267Domain.js +66 -0
  64. package/lib/esm/token/ExchangeRateWrappedToken.d.ts +11 -0
  65. package/lib/esm/token/ExchangeRateWrappedToken.js +17 -0
  66. package/lib/esm/token/Token.d.ts +52 -0
  67. package/lib/esm/token/Token.js +62 -0
  68. package/lib/esm/token/VaultToken.d.ts +23 -0
  69. package/lib/esm/token/VaultToken.js +27 -0
  70. package/lib/esm/token/WrappedToken.d.ts +17 -0
  71. package/lib/esm/token/WrappedToken.js +29 -0
  72. package/lib/esm/token/index.d.ts +6 -0
  73. package/lib/esm/token/index.js +6 -0
  74. package/lib/esm/types.d.ts +26 -0
  75. package/lib/esm/types.js +13 -0
  76. package/lib/esm/user/User.d.ts +20 -0
  77. package/lib/esm/user/User.js +19 -0
  78. package/lib/esm/user/index.d.ts +1 -0
  79. package/lib/esm/user/index.js +1 -0
  80. package/lib/esm/utils.d.ts +13 -0
  81. package/lib/esm/utils.js +10 -0
  82. package/lib/esm/vault/Vault.d.ts +214 -0
  83. package/lib/esm/vault/Vault.js +289 -0
  84. package/lib/esm/vault/VaultConfig.d.ts +11 -0
  85. package/lib/esm/vault/VaultConfig.js +10 -0
  86. package/lib/esm/vault/VaultMarketAllocation.d.ts +20 -0
  87. package/lib/esm/vault/VaultMarketAllocation.js +27 -0
  88. package/lib/esm/vault/VaultMarketConfig.d.ts +43 -0
  89. package/lib/esm/vault/VaultMarketConfig.js +39 -0
  90. package/lib/esm/vault/VaultMarketPublicAllocatorConfig.d.ts +29 -0
  91. package/lib/esm/vault/VaultMarketPublicAllocatorConfig.js +24 -0
  92. package/lib/esm/vault/VaultUser.d.ts +26 -0
  93. package/lib/esm/vault/VaultUser.js +24 -0
  94. package/lib/esm/vault/VaultUtils.d.ts +16 -0
  95. package/lib/esm/vault/VaultUtils.js +17 -0
  96. package/lib/esm/vault/index.d.ts +8 -0
  97. package/lib/esm/vault/index.js +8 -0
  98. package/lib/esm/vault/v2/VaultV2.d.ts +87 -0
  99. package/lib/esm/vault/v2/VaultV2.js +154 -0
  100. package/lib/esm/vault/v2/VaultV2Adapter.d.ts +29 -0
  101. package/lib/esm/vault/v2/VaultV2Adapter.js +12 -0
  102. package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +30 -0
  103. package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.js +54 -0
  104. package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +33 -0
  105. package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +63 -0
  106. package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.d.ts +24 -0
  107. package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.js +36 -0
  108. package/lib/esm/vault/v2/index.d.ts +5 -0
  109. package/lib/esm/vault/v2/index.js +5 -0
  110. package/package.json +16 -7
  111. package/src/index.ts +14 -0
  112. /package/lib/{addresses.d.ts → cjs/addresses.d.ts} +0 -0
  113. /package/lib/{addresses.js → cjs/addresses.js} +0 -0
  114. /package/lib/{chain.d.ts → cjs/chain.d.ts} +0 -0
  115. /package/lib/{chain.js → cjs/chain.js} +0 -0
  116. /package/lib/{constants.d.ts → cjs/constants.d.ts} +0 -0
  117. /package/lib/{constants.js → cjs/constants.js} +0 -0
  118. /package/lib/{holding → cjs/holding}/AssetBalances.d.ts +0 -0
  119. /package/lib/{holding → cjs/holding}/AssetBalances.js +0 -0
  120. /package/lib/{holding → cjs/holding}/Holding.d.ts +0 -0
  121. /package/lib/{holding → cjs/holding}/Holding.js +0 -0
  122. /package/lib/{holding → cjs/holding}/index.d.ts +0 -0
  123. /package/lib/{holding → cjs/holding}/index.js +0 -0
  124. /package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  125. /package/lib/{index.js → cjs/index.js} +0 -0
  126. /package/lib/{market → cjs/market}/Market.d.ts +0 -0
  127. /package/lib/{market → cjs/market}/Market.js +0 -0
  128. /package/lib/{market → cjs/market}/MarketParams.d.ts +0 -0
  129. /package/lib/{market → cjs/market}/MarketParams.js +0 -0
  130. /package/lib/{market → cjs/market}/MarketUtils.d.ts +0 -0
  131. /package/lib/{market → cjs/market}/MarketUtils.js +0 -0
  132. /package/lib/{market → cjs/market}/index.d.ts +0 -0
  133. /package/lib/{market → cjs/market}/index.js +0 -0
  134. /package/lib/{math → cjs/math}/AdaptiveCurveIrmLib.d.ts +0 -0
  135. /package/lib/{math → cjs/math}/AdaptiveCurveIrmLib.js +0 -0
  136. /package/lib/{math → cjs/math}/MathLib.d.ts +0 -0
  137. /package/lib/{math → cjs/math}/MathLib.js +0 -0
  138. /package/lib/{math → cjs/math}/SharesMath.d.ts +0 -0
  139. /package/lib/{math → cjs/math}/SharesMath.js +0 -0
  140. /package/lib/{math → cjs/math}/index.d.ts +0 -0
  141. /package/lib/{math → cjs/math}/index.js +0 -0
  142. /package/lib/{position → cjs/position}/Position.d.ts +0 -0
  143. /package/lib/{position → cjs/position}/Position.js +0 -0
  144. /package/lib/{position → cjs/position}/index.d.ts +0 -0
  145. /package/lib/{position → cjs/position}/index.js +0 -0
  146. /package/lib/{token → cjs/token}/ConstantWrappedToken.d.ts +0 -0
  147. /package/lib/{token → cjs/token}/ConstantWrappedToken.js +0 -0
  148. /package/lib/{token → cjs/token}/Eip5267Domain.d.ts +0 -0
  149. /package/lib/{token → cjs/token}/Eip5267Domain.js +0 -0
  150. /package/lib/{token → cjs/token}/ExchangeRateWrappedToken.d.ts +0 -0
  151. /package/lib/{token → cjs/token}/ExchangeRateWrappedToken.js +0 -0
  152. /package/lib/{token → cjs/token}/Token.d.ts +0 -0
  153. /package/lib/{token → cjs/token}/Token.js +0 -0
  154. /package/lib/{token → cjs/token}/VaultToken.d.ts +0 -0
  155. /package/lib/{token → cjs/token}/VaultToken.js +0 -0
  156. /package/lib/{token → cjs/token}/WrappedToken.d.ts +0 -0
  157. /package/lib/{token → cjs/token}/WrappedToken.js +0 -0
  158. /package/lib/{token → cjs/token}/index.d.ts +0 -0
  159. /package/lib/{token → cjs/token}/index.js +0 -0
  160. /package/lib/{types.d.ts → cjs/types.d.ts} +0 -0
  161. /package/lib/{types.js → cjs/types.js} +0 -0
  162. /package/lib/{user → cjs/user}/User.d.ts +0 -0
  163. /package/lib/{user → cjs/user}/User.js +0 -0
  164. /package/lib/{user → cjs/user}/index.d.ts +0 -0
  165. /package/lib/{user → cjs/user}/index.js +0 -0
  166. /package/lib/{utils.d.ts → cjs/utils.d.ts} +0 -0
  167. /package/lib/{utils.js → cjs/utils.js} +0 -0
  168. /package/lib/{vault → cjs/vault}/Vault.d.ts +0 -0
  169. /package/lib/{vault → cjs/vault}/Vault.js +0 -0
  170. /package/lib/{vault → cjs/vault}/VaultConfig.d.ts +0 -0
  171. /package/lib/{vault → cjs/vault}/VaultConfig.js +0 -0
  172. /package/lib/{vault → cjs/vault}/VaultMarketAllocation.d.ts +0 -0
  173. /package/lib/{vault → cjs/vault}/VaultMarketAllocation.js +0 -0
  174. /package/lib/{vault → cjs/vault}/VaultMarketConfig.d.ts +0 -0
  175. /package/lib/{vault → cjs/vault}/VaultMarketConfig.js +0 -0
  176. /package/lib/{vault → cjs/vault}/VaultMarketPublicAllocatorConfig.d.ts +0 -0
  177. /package/lib/{vault → cjs/vault}/VaultMarketPublicAllocatorConfig.js +0 -0
  178. /package/lib/{vault → cjs/vault}/VaultUser.d.ts +0 -0
  179. /package/lib/{vault → cjs/vault}/VaultUser.js +0 -0
  180. /package/lib/{vault → cjs/vault}/VaultUtils.d.ts +0 -0
  181. /package/lib/{vault → cjs/vault}/VaultUtils.js +0 -0
  182. /package/lib/{vault → cjs/vault}/v2/VaultV2Adapter.js +0 -0
  183. /package/lib/{vault → cjs/vault}/v2/index.d.ts +0 -0
  184. /package/lib/{vault → cjs/vault}/v2/index.js +0 -0
@@ -86,6 +86,14 @@ export declare namespace VaultV2Errors {
86
86
  constructor(address: Address);
87
87
  }
88
88
  }
89
+ export declare class UnknownFactory extends Error {
90
+ constructor();
91
+ }
92
+ export declare class UnknownOfFactory extends Error {
93
+ readonly factory: Address;
94
+ readonly address: Address;
95
+ constructor(factory: Address, address: Address);
96
+ }
89
97
  export interface ErrorClass<E extends Error = Error> {
90
98
  new (...args: any[]): E;
91
99
  }
@@ -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 = exports.InvalidMarketParamsError = void 0;
3
+ exports.UnknownOfFactory = exports.UnknownFactory = exports.VaultV2Errors = exports.BlueErrors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = exports.InvalidMarketParamsError = void 0;
4
4
  exports._try = _try;
5
5
  const viem_1 = require("viem");
6
6
  class InvalidMarketParamsError extends Error {
@@ -172,6 +172,22 @@ var VaultV2Errors;
172
172
  }
173
173
  VaultV2Errors.UnsupportedLiquidityAdapter = UnsupportedLiquidityAdapter;
174
174
  })(VaultV2Errors || (exports.VaultV2Errors = VaultV2Errors = {}));
175
+ class UnknownFactory extends Error {
176
+ constructor() {
177
+ super(`unknown factory`);
178
+ }
179
+ }
180
+ exports.UnknownFactory = UnknownFactory;
181
+ class UnknownOfFactory extends Error {
182
+ factory;
183
+ address;
184
+ constructor(factory, address) {
185
+ super(`address "${address}" is not from the ${factory} factory`);
186
+ this.factory = factory;
187
+ this.address = address;
188
+ }
189
+ }
190
+ exports.UnknownOfFactory = UnknownOfFactory;
175
191
  function _try(accessor, ...errorClasses) {
176
192
  const maybeCatchError = (error) => {
177
193
  if (errorClasses.length === 0 ||
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,7 +1,7 @@
1
1
  import type { Address } from "viem";
2
- import { type IMarket, Market } from "../market";
3
- import type { BigIntish } from "../types";
4
- import { AccrualPosition, type IAccrualPosition } from "./Position";
2
+ import { type IMarket, Market } from "../market/index.js";
3
+ import type { BigIntish } from "../types.js";
4
+ import { AccrualPosition, type IAccrualPosition } from "./Position.js";
5
5
  export interface IPreLiquidationParams {
6
6
  preLltv: BigIntish;
7
7
  preLCF1: BigIntish;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PreLiquidationPosition = exports.PreLiquidationParams = void 0;
4
- const constants_1 = require("../constants");
5
- const market_1 = require("../market");
6
- const math_1 = require("../math");
7
- const Position_1 = require("./Position");
4
+ const constants_js_1 = require("../constants.js");
5
+ const index_js_1 = require("../market/index.js");
6
+ const index_js_2 = require("../math/index.js");
7
+ const Position_js_1 = require("./Position.js");
8
8
  class PreLiquidationParams {
9
9
  preLltv;
10
10
  preLCF1;
@@ -21,14 +21,14 @@ class PreLiquidationParams {
21
21
  this.preLiquidationOracle = preLiquidationOracle;
22
22
  }
23
23
  getCloseFactor(quotient) {
24
- return (this.preLCF1 + math_1.MathLib.wMulDown(quotient, this.preLCF2 - this.preLCF1));
24
+ return (this.preLCF1 + index_js_2.MathLib.wMulDown(quotient, this.preLCF2 - this.preLCF1));
25
25
  }
26
26
  getIncentiveFactor(quotient) {
27
- return (this.preLIF1 + math_1.MathLib.wMulDown(quotient, this.preLIF2 - this.preLIF1));
27
+ return (this.preLIF1 + index_js_2.MathLib.wMulDown(quotient, this.preLIF2 - this.preLIF1));
28
28
  }
29
29
  }
30
30
  exports.PreLiquidationParams = PreLiquidationParams;
31
- class PreLiquidationPosition extends Position_1.AccrualPosition {
31
+ class PreLiquidationPosition extends Position_js_1.AccrualPosition {
32
32
  preLiquidationParams;
33
33
  preLiquidation;
34
34
  preLiquidationOraclePrice;
@@ -48,7 +48,7 @@ class PreLiquidationPosition extends Position_1.AccrualPosition {
48
48
  this.preLiquidation = preLiquidation;
49
49
  if (preLiquidationOraclePrice != null)
50
50
  this.preLiquidationOraclePrice = BigInt(preLiquidationOraclePrice);
51
- this._baseMarket = new market_1.Market(market);
51
+ this._baseMarket = new index_js_1.Market(market);
52
52
  }
53
53
  get market() {
54
54
  return this._baseMarket;
@@ -65,10 +65,10 @@ class PreLiquidationPosition extends Position_1.AccrualPosition {
65
65
  if (collateralValue == null)
66
66
  return;
67
67
  const { borrowAssets } = this;
68
- if (borrowAssets > math_1.MathLib.wMulDown(collateralValue, this._lltv))
68
+ if (borrowAssets > index_js_2.MathLib.wMulDown(collateralValue, this._lltv))
69
69
  return;
70
70
  return (borrowAssets <=
71
- math_1.MathLib.wMulDown(collateralValue, this.preLiquidationParams.preLltv));
71
+ index_js_2.MathLib.wMulDown(collateralValue, this.preLiquidationParams.preLltv));
72
72
  }
73
73
  /**
74
74
  * @inheritdoc `undefined` if the pre-liquidation's oracle reverts.
@@ -79,8 +79,8 @@ class PreLiquidationPosition extends Position_1.AccrualPosition {
79
79
  return;
80
80
  const { borrowAssets } = this;
81
81
  return (borrowAssets >
82
- math_1.MathLib.wMulDown(collateralValue, this.preLiquidationParams.preLltv) &&
83
- borrowAssets <= math_1.MathLib.wMulDown(collateralValue, this._lltv));
82
+ index_js_2.MathLib.wMulDown(collateralValue, this.preLiquidationParams.preLltv) &&
83
+ borrowAssets <= index_js_2.MathLib.wMulDown(collateralValue, this._lltv));
84
84
  }
85
85
  /**
86
86
  * @inheritdoc `undefined` if the pre-liquidation's oracle reverts.
@@ -93,10 +93,10 @@ class PreLiquidationPosition extends Position_1.AccrualPosition {
93
93
  const { ltv } = this;
94
94
  if (ltv == null)
95
95
  return;
96
- const quotient = math_1.MathLib.wDivDown(ltv - this.preLiquidationParams.preLltv, this._lltv - this.preLiquidationParams.preLltv);
97
- const repayableShares = math_1.MathLib.wMulDown(this.borrowShares, this.preLiquidationParams.getCloseFactor(quotient));
98
- const repayableAssets = math_1.MathLib.wMulDown(math_1.SharesMath.toAssets(repayableShares, this._market.totalBorrowAssets, this._market.totalBorrowShares, "Down"), this.preLiquidationParams.getIncentiveFactor(quotient));
99
- return math_1.MathLib.mulDivDown(repayableAssets, constants_1.ORACLE_PRICE_SCALE, this._market.price);
96
+ const quotient = index_js_2.MathLib.wDivDown(ltv - this.preLiquidationParams.preLltv, this._lltv - this.preLiquidationParams.preLltv);
97
+ const repayableShares = index_js_2.MathLib.wMulDown(this.borrowShares, this.preLiquidationParams.getCloseFactor(quotient));
98
+ const repayableAssets = index_js_2.MathLib.wMulDown(index_js_2.SharesMath.toAssets(repayableShares, this._market.totalBorrowAssets, this._market.totalBorrowShares, "Down"), this.preLiquidationParams.getIncentiveFactor(quotient));
99
+ return index_js_2.MathLib.mulDivDown(repayableAssets, constants_js_1.ORACLE_PRICE_SCALE, this._market.price);
100
100
  }
101
101
  }
102
102
  exports.PreLiquidationPosition = PreLiquidationPosition;
@@ -1,4 +1,4 @@
1
- import type { BigIntish } from "./types";
1
+ import type { BigIntish } from "./types.js";
2
2
  export declare const defaultPreLiquidationParamsRegistry: Map<bigint, {
3
3
  preLltv: bigint;
4
4
  preLCF1: bigint;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDefaultPreLiquidationParams = exports.defaultPreLiquidationParamsRegistry = void 0;
4
4
  const viem_1 = require("viem");
5
- const errors_1 = require("./errors");
5
+ const errors_js_1 = require("./errors.js");
6
6
  exports.defaultPreLiquidationParamsRegistry = new Map([
7
7
  [
8
8
  (0, viem_1.parseEther)("0.385"),
@@ -89,7 +89,7 @@ const getDefaultPreLiquidationParams = (lltv) => {
89
89
  lltv = BigInt(lltv);
90
90
  const defaultParams = exports.defaultPreLiquidationParamsRegistry.get(lltv);
91
91
  if (defaultParams == null)
92
- throw new errors_1.UnsupportedPreLiquidationParamsError(lltv);
92
+ throw new errors_js_1.UnsupportedPreLiquidationParamsError(lltv);
93
93
  return defaultParams;
94
94
  };
95
95
  exports.getDefaultPreLiquidationParams = getDefaultPreLiquidationParams;
@@ -5,4 +5,4 @@ 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";
8
+ export * from "./v2/index.js";
@@ -21,4 +21,4 @@ __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);
24
+ __exportStar(require("./v2/index.js"), exports);
@@ -1,9 +1,9 @@
1
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";
2
+ import { type RoundingDirection } from "../../math/index.js";
3
+ import { type IToken, WrappedToken } from "../../token/index.js";
4
+ import type { BigIntish } from "../../types.js";
5
+ import { type CapacityLimit } from "../../utils.js";
6
+ import type { IAccrualVaultV2Adapter } from "./VaultV2Adapter.js";
7
7
  export interface IVaultV2Allocation {
8
8
  id: Hash;
9
9
  absoluteCap: bigint;
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccrualVaultV2 = exports.VaultV2 = void 0;
4
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 {
5
+ const errors_js_1 = require("../../errors.js");
6
+ const index_js_1 = require("../../math/index.js");
7
+ const index_js_2 = require("../../token/index.js");
8
+ const utils_js_1 = require("../../utils.js");
9
+ class VaultV2 extends index_js_2.WrappedToken {
10
10
  asset;
11
11
  totalAssets;
12
12
  _totalAssets;
@@ -47,10 +47,10 @@ class VaultV2 extends token_1.WrappedToken {
47
47
  return this._wrap(assets, "Down");
48
48
  }
49
49
  _wrap(amount, rounding) {
50
- return math_1.MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this.totalAssets + 1n, rounding);
50
+ return index_js_1.MathLib.mulDiv(amount, this.totalSupply + this.virtualShares, this.totalAssets + 1n, rounding);
51
51
  }
52
52
  _unwrap(amount, rounding) {
53
- return math_1.MathLib.mulDiv(amount, this.totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
53
+ return index_js_1.MathLib.mulDiv(amount, this.totalAssets + 1n, this.totalSupply + this.virtualShares, rounding);
54
54
  }
55
55
  }
56
56
  exports.VaultV2 = VaultV2;
@@ -70,29 +70,29 @@ class AccrualVaultV2 extends VaultV2 {
70
70
  */
71
71
  maxDeposit(assets) {
72
72
  if (this.liquidityAdapter === viem_1.zeroAddress)
73
- return { value: BigInt(assets), limiter: utils_1.CapacityLimitReason.balance };
73
+ return { value: BigInt(assets), limiter: utils_js_1.CapacityLimitReason.balance };
74
74
  let liquidityAdapterLimit;
75
75
  if (this.accrualLiquidityAdapter != null)
76
76
  liquidityAdapterLimit = this.accrualLiquidityAdapter.maxDeposit(this.liquidityData, assets);
77
77
  if (this.liquidityAllocations == null || liquidityAdapterLimit == null)
78
- throw new errors_1.VaultV2Errors.UnsupportedLiquidityAdapter(this.liquidityAdapter);
78
+ throw new errors_js_1.VaultV2Errors.UnsupportedLiquidityAdapter(this.liquidityAdapter);
79
79
  // At this stage: `liquidityAdapterLimit.value <= assets`
80
80
  for (const { absoluteCap, relativeCap, allocation } of this
81
81
  .liquidityAllocations) {
82
82
  // `absoluteCap` can be set lower than `allocation`.
83
- const absoluteMaxDeposit = math_1.MathLib.zeroFloorSub(absoluteCap, allocation);
83
+ const absoluteMaxDeposit = index_js_1.MathLib.zeroFloorSub(absoluteCap, allocation);
84
84
  if (liquidityAdapterLimit.value > absoluteMaxDeposit)
85
85
  liquidityAdapterLimit = {
86
86
  value: absoluteMaxDeposit,
87
- limiter: utils_1.CapacityLimitReason.vaultV2_absoluteCap,
87
+ limiter: utils_js_1.CapacityLimitReason.vaultV2_absoluteCap,
88
88
  };
89
- if (relativeCap !== math_1.MathLib.WAD) {
89
+ if (relativeCap !== index_js_1.MathLib.WAD) {
90
90
  // `relativeCap` can be set lower than `allocation / totalAssets`.
91
- const relativeMaxDeposit = math_1.MathLib.zeroFloorSub(math_1.MathLib.wMulDown(this.totalAssets, relativeCap), allocation);
91
+ const relativeMaxDeposit = index_js_1.MathLib.zeroFloorSub(index_js_1.MathLib.wMulDown(this.totalAssets, relativeCap), allocation);
92
92
  if (liquidityAdapterLimit.value > relativeMaxDeposit)
93
93
  liquidityAdapterLimit = {
94
94
  value: relativeMaxDeposit,
95
- limiter: utils_1.CapacityLimitReason.vaultV2_relativeCap,
95
+ limiter: utils_js_1.CapacityLimitReason.vaultV2_relativeCap,
96
96
  };
97
97
  }
98
98
  }
@@ -105,18 +105,18 @@ class AccrualVaultV2 extends VaultV2 {
105
105
  maxWithdraw(shares) {
106
106
  const assets = this.toAssets(shares);
107
107
  if (this.liquidityAdapter === viem_1.zeroAddress)
108
- return { value: BigInt(assets), limiter: utils_1.CapacityLimitReason.balance };
108
+ return { value: BigInt(assets), limiter: utils_js_1.CapacityLimitReason.balance };
109
109
  let liquidity = this.assetBalance;
110
110
  if (this.accrualLiquidityAdapter != null)
111
111
  liquidity += this.accrualLiquidityAdapter.maxWithdraw(this.liquidityData).value;
112
112
  if (assets > liquidity)
113
113
  return {
114
114
  value: liquidity,
115
- limiter: utils_1.CapacityLimitReason.liquidity,
115
+ limiter: utils_js_1.CapacityLimitReason.liquidity,
116
116
  };
117
117
  return {
118
118
  value: assets,
119
- limiter: utils_1.CapacityLimitReason.balance,
119
+ limiter: utils_js_1.CapacityLimitReason.balance,
120
120
  };
121
121
  }
122
122
  /**
@@ -128,24 +128,24 @@ class AccrualVaultV2 extends VaultV2 {
128
128
  timestamp = BigInt(timestamp);
129
129
  const elapsed = timestamp - this.lastUpdate;
130
130
  if (elapsed < 0n)
131
- throw new errors_1.VaultV2Errors.InvalidInterestAccrual(this.address, timestamp, this.lastUpdate);
131
+ throw new errors_js_1.VaultV2Errors.InvalidInterestAccrual(this.address, timestamp, this.lastUpdate);
132
132
  // Corresponds to the `firstTotalAssets == 0` onchain check.
133
133
  if (elapsed === 0n)
134
134
  return { vault, performanceFeeShares: 0n, managementFeeShares: 0n };
135
135
  const realAssets = vault.accrualAdapters.reduce((curr, adapter) => curr + adapter.realAssets(timestamp), vault.assetBalance);
136
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);
137
+ index_js_1.MathLib.wMulDown(vault._totalAssets * elapsed, vault.maxRate);
138
+ const newTotalAssets = index_js_1.MathLib.min(realAssets, maxTotalAssets);
139
+ const interest = index_js_1.MathLib.zeroFloorSub(newTotalAssets, vault._totalAssets);
140
140
  const performanceFeeAssets = interest > 0n && vault.performanceFee > 0n
141
- ? math_1.MathLib.wMulDown(interest, vault.performanceFee)
141
+ ? index_js_1.MathLib.wMulDown(interest, vault.performanceFee)
142
142
  : 0n;
143
143
  const managementFeeAssets = elapsed > 0n && vault.managementFee > 0n
144
- ? math_1.MathLib.wMulDown(newTotalAssets * elapsed, vault.managementFee)
144
+ ? index_js_1.MathLib.wMulDown(newTotalAssets * elapsed, vault.managementFee)
145
145
  : 0n;
146
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);
147
+ const performanceFeeShares = index_js_1.MathLib.mulDivDown(performanceFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
148
+ const managementFeeShares = index_js_1.MathLib.mulDivDown(managementFeeAssets, vault.totalSupply + vault.virtualShares, newTotalAssetsWithoutFees + 1n);
149
149
  vault.totalAssets = newTotalAssets;
150
150
  vault._totalAssets = newTotalAssets;
151
151
  if (performanceFeeShares)
@@ -1,6 +1,6 @@
1
1
  import type { Address, Hash, Hex } from "viem";
2
- import type { BigIntish } from "../../types";
3
- import type { CapacityLimit } from "../../utils";
2
+ import type { BigIntish } from "../../types.js";
3
+ import type { CapacityLimit } from "../../utils.js";
4
4
  export interface IVaultV2Adapter {
5
5
  address: Address;
6
6
  parentVault: Address;
@@ -1,10 +1,10 @@
1
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";
2
+ import { type IMarketParams, MarketParams } from "../../market/index.js";
3
+ import type { AccrualPosition } from "../../position/index.js";
4
+ import type { BigIntish } from "../../types.js";
5
+ import { CapacityLimitReason } from "../../utils.js";
6
+ import { VaultV2Adapter } from "./VaultV2Adapter.js";
7
+ import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
8
8
  export interface IVaultV2MorphoMarketV1Adapter extends Omit<IVaultV2Adapter, "adapterId"> {
9
9
  marketParamsList: IMarketParams[];
10
10
  }
@@ -26,5 +26,5 @@ export declare class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMa
26
26
  value: bigint;
27
27
  limiter: CapacityLimitReason;
28
28
  };
29
- maxWithdraw(data: Hex): import("../../utils").CapacityLimit;
29
+ maxWithdraw(data: Hex): import("../../utils.js").CapacityLimit;
30
30
  }
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccrualVaultV2MorphoMarketV1Adapter = exports.VaultV2MorphoMarketV1Adapter = void 0;
4
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 {
5
+ const index_js_1 = require("../../market/index.js");
6
+ const utils_js_1 = require("../../utils.js");
7
+ const VaultV2Adapter_js_1 = require("./VaultV2Adapter.js");
8
+ class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter_js_1.VaultV2Adapter {
9
9
  static adapterId(address) {
10
10
  return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["this", address]));
11
11
  }
@@ -13,7 +13,7 @@ class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter_1.VaultV2Adapter {
13
13
  return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["collateralToken", address]));
14
14
  }
15
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]));
16
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }, index_js_1.marketParamsAbi], ["this/marketParams", address, params]));
17
17
  }
18
18
  marketParamsList;
19
19
  constructor({ marketParamsList, ...vaultV2Adapter }) {
@@ -21,7 +21,7 @@ class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter_1.VaultV2Adapter {
21
21
  ...vaultV2Adapter,
22
22
  adapterId: VaultV2MorphoMarketV1Adapter.adapterId(vaultV2Adapter.address),
23
23
  });
24
- this.marketParamsList = marketParamsList.map((params) => new market_1.MarketParams(params));
24
+ this.marketParamsList = marketParamsList.map((params) => new index_js_1.MarketParams(params));
25
25
  }
26
26
  ids(params) {
27
27
  return [
@@ -44,15 +44,15 @@ class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMarketV1Adapter {
44
44
  maxDeposit(_data, assets) {
45
45
  return {
46
46
  value: BigInt(assets),
47
- limiter: utils_1.CapacityLimitReason.balance,
47
+ limiter: utils_js_1.CapacityLimitReason.balance,
48
48
  };
49
49
  }
50
50
  maxWithdraw(data) {
51
- const marketId = market_1.MarketParams.fromHex(data).id;
51
+ const marketId = index_js_1.MarketParams.fromHex(data).id;
52
52
  const position = this.positions.find((position) => position.marketId === marketId);
53
53
  return (position?.market?.getWithdrawCapacityLimit(position) ?? {
54
54
  value: 0n,
55
- limiter: utils_1.CapacityLimitReason.position,
55
+ limiter: utils_js_1.CapacityLimitReason.position,
56
56
  });
57
57
  }
58
58
  }
@@ -1,9 +1,9 @@
1
1
  import { type Address, type Hex } from "viem";
2
- import { type Market, MarketParams } from "../../market";
3
- import type { BigIntish, MarketId } from "../../types";
4
- import { CapacityLimitReason } from "../../utils";
5
- import { VaultV2Adapter } from "./VaultV2Adapter";
6
- import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter";
2
+ import { type Market, MarketParams } from "../../market/index.js";
3
+ import type { BigIntish, MarketId } from "../../types.js";
4
+ import { CapacityLimitReason } from "../../utils.js";
5
+ import { VaultV2Adapter } from "./VaultV2Adapter.js";
6
+ import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
7
7
  export interface IVaultV2MorphoMarketV1AdapterV2 extends Omit<IVaultV2Adapter, "adapterId"> {
8
8
  marketIds: MarketId[];
9
9
  adaptiveCurveIrm: Address;
@@ -29,5 +29,5 @@ export declare class AccrualVaultV2MorphoMarketV1AdapterV2 extends VaultV2Morpho
29
29
  value: bigint;
30
30
  limiter: CapacityLimitReason;
31
31
  };
32
- maxWithdraw(data: Hex): import("../../utils").CapacityLimit;
32
+ maxWithdraw(data: Hex): import("../../utils.js").CapacityLimit;
33
33
  }
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1AdapterV2 = void 0;
4
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 VaultV2MorphoMarketV1AdapterV2 extends VaultV2Adapter_1.VaultV2Adapter {
5
+ const index_js_1 = require("../../market/index.js");
6
+ const utils_js_1 = require("../../utils.js");
7
+ const VaultV2Adapter_js_1 = require("./VaultV2Adapter.js");
8
+ class VaultV2MorphoMarketV1AdapterV2 extends VaultV2Adapter_js_1.VaultV2Adapter {
9
9
  static adapterId(address) {
10
10
  return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["this", address]));
11
11
  }
@@ -13,7 +13,7 @@ class VaultV2MorphoMarketV1AdapterV2 extends VaultV2Adapter_1.VaultV2Adapter {
13
13
  return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["collateralToken", address]));
14
14
  }
15
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]));
16
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }, index_js_1.marketParamsAbi], ["this/marketParams", address, params]));
17
17
  }
18
18
  marketIds;
19
19
  adaptiveCurveIrm;
@@ -51,17 +51,17 @@ class AccrualVaultV2MorphoMarketV1AdapterV2 extends VaultV2MorphoMarketV1Adapter
51
51
  maxDeposit(_data, assets) {
52
52
  return {
53
53
  value: BigInt(assets),
54
- limiter: utils_1.CapacityLimitReason.balance,
54
+ limiter: utils_js_1.CapacityLimitReason.balance,
55
55
  };
56
56
  }
57
57
  maxWithdraw(data) {
58
- const marketId = market_1.MarketParams.fromHex(data).id;
58
+ const marketId = index_js_1.MarketParams.fromHex(data).id;
59
59
  const market = this.markets.find((market) => market.id === marketId);
60
60
  return (market?.getWithdrawCapacityLimit({
61
61
  supplyShares: this.supplyShares[marketId] ?? 0n,
62
62
  }) ?? {
63
63
  value: 0n,
64
- limiter: utils_1.CapacityLimitReason.position,
64
+ limiter: utils_js_1.CapacityLimitReason.position,
65
65
  });
66
66
  }
67
67
  }
@@ -1,11 +1,11 @@
1
1
  import { type Address, type Hex } from "viem";
2
- import { VaultV2Adapter } from "./VaultV2Adapter";
2
+ import { VaultV2Adapter } from "./VaultV2Adapter.js";
3
3
  export interface IVaultV2MorphoVaultV1Adapter extends Omit<IVaultV2Adapter, "adapterId"> {
4
4
  morphoVaultV1: Address;
5
5
  }
6
- import type { BigIntish } from "../../types";
7
- import type { AccrualVault } from "../Vault";
8
- import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter";
6
+ import type { BigIntish } from "../../types.js";
7
+ import type { AccrualVault } from "../Vault.js";
8
+ import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
9
9
  export declare class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter implements IVaultV2MorphoVaultV1Adapter {
10
10
  static adapterId(address: Address): `0x${string}`;
11
11
  readonly morphoVaultV1: Address;
@@ -19,6 +19,6 @@ export declare class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVau
19
19
  shares: bigint;
20
20
  constructor(adapter: IAccrualVaultV2MorphoVaultV1Adapter, accrualVaultV1: AccrualVault, shares: bigint);
21
21
  realAssets(timestamp?: BigIntish): bigint;
22
- maxDeposit(_data: Hex, assets: BigIntish): import("../..").CapacityLimit;
23
- maxWithdraw(_data: Hex): import("../..").CapacityLimit;
22
+ maxDeposit(_data: Hex, assets: BigIntish): import("../../utils.js").CapacityLimit;
23
+ maxWithdraw(_data: Hex): import("../../utils.js").CapacityLimit;
24
24
  }
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccrualVaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoVaultV1Adapter = void 0;
4
4
  const viem_1 = require("viem");
5
- const VaultV2Adapter_1 = require("./VaultV2Adapter");
6
- class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter_1.VaultV2Adapter {
5
+ const VaultV2Adapter_js_1 = require("./VaultV2Adapter.js");
6
+ class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter_js_1.VaultV2Adapter {
7
7
  static adapterId(address) {
8
8
  return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["this", address]));
9
9
  }