@morpho-org/blue-sdk 2.0.0-next.2 → 2.0.0-next.21

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 (47) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -6
  3. package/lib/addresses.d.ts +1 -1
  4. package/lib/addresses.js +63 -58
  5. package/lib/chain.js +9 -6
  6. package/lib/constants.js +12 -9
  7. package/lib/errors.d.ts +5 -1
  8. package/lib/errors.js +27 -9
  9. package/lib/holding/AssetBalances.js +5 -1
  10. package/lib/holding/Holding.js +9 -5
  11. package/lib/holding/index.js +18 -2
  12. package/lib/index.js +28 -12
  13. package/lib/market/Market.d.ts +35 -23
  14. package/lib/market/Market.js +75 -54
  15. package/lib/market/{MarketConfig.d.ts → MarketParams.d.ts} +6 -6
  16. package/lib/market/{MarketConfig.js → MarketParams.js} +22 -20
  17. package/lib/market/MarketUtils.d.ts +81 -32
  18. package/lib/market/MarketUtils.js +138 -56
  19. package/lib/market/index.d.ts +1 -1
  20. package/lib/market/index.js +19 -3
  21. package/lib/math/AdaptiveCurveIrmLib.js +25 -22
  22. package/lib/math/MathLib.js +11 -8
  23. package/lib/math/SharesMath.js +8 -5
  24. package/lib/math/index.js +19 -3
  25. package/lib/position/Position.d.ts +22 -13
  26. package/lib/position/Position.js +49 -43
  27. package/lib/position/index.js +17 -1
  28. package/lib/token/ConstantWrappedToken.js +10 -6
  29. package/lib/token/ExchangeRateWrappedToken.js +9 -5
  30. package/lib/token/Token.d.ts +13 -13
  31. package/lib/token/Token.js +27 -25
  32. package/lib/token/VaultToken.js +9 -5
  33. package/lib/token/WrappedToken.js +11 -7
  34. package/lib/token/index.js +21 -5
  35. package/lib/types.js +9 -4
  36. package/lib/user/User.js +5 -1
  37. package/lib/user/index.js +17 -1
  38. package/lib/vault/Vault.d.ts +8 -0
  39. package/lib/vault/Vault.js +26 -21
  40. package/lib/vault/VaultConfig.js +7 -3
  41. package/lib/vault/VaultMarketAllocation.js +8 -4
  42. package/lib/vault/VaultMarketConfig.js +5 -1
  43. package/lib/vault/VaultMarketPublicAllocatorConfig.js +5 -1
  44. package/lib/vault/VaultUser.js +5 -1
  45. package/lib/vault/VaultUtils.js +9 -6
  46. package/lib/vault/index.js +23 -7
  47. package/package.json +20 -41
@@ -1,59 +1,61 @@
1
- import { NATIVE_ADDRESS } from "../addresses.js";
2
- import { ChainUtils } from "../chain.js";
3
- import { MathLib } from "../math/index.js";
4
- export class Token {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Token = void 0;
4
+ const addresses_js_1 = require("../addresses.js");
5
+ const chain_js_1 = require("../chain.js");
6
+ const index_js_1 = require("../math/index.js");
7
+ class Token {
5
8
  static native(chainId) {
6
- const currency = ChainUtils.CHAIN_METADATA[chainId].nativeCurrency;
7
- return new Token({ ...currency, address: NATIVE_ADDRESS });
9
+ const currency = chain_js_1.ChainUtils.CHAIN_METADATA[chainId].nativeCurrency;
10
+ return new Token({ ...currency, address: addresses_js_1.NATIVE_ADDRESS });
8
11
  }
9
12
  /**
10
13
  * The token's address.
11
14
  */
12
15
  address;
13
16
  /**
14
- * The token's number of decimals.
17
+ * The token's name.
15
18
  */
16
- decimals;
19
+ name;
17
20
  /**
18
21
  * The token's symbol.
19
22
  */
20
23
  symbol;
21
24
  /**
22
- * The name of the token (defaults to the symbol).
25
+ * The token's number of decimals. Defaults to 0.
23
26
  */
24
- name;
25
- constructor({ address, decimals, symbol, name }) {
26
- this.address = address;
27
- this.decimals = Number(decimals);
28
- this.symbol = symbol;
29
- this.name = name ?? symbol;
30
- }
31
- }
32
- export class TokenWithPrice extends Token {
27
+ decimals;
33
28
  /**
34
29
  * Price of the token in USD (scaled by WAD).
35
30
  */
36
31
  price;
37
- constructor(token, price) {
38
- super(token);
39
- this.price = price;
32
+ constructor({ address, name, symbol, decimals = 0, price }) {
33
+ this.address = address;
34
+ this.name = name;
35
+ this.symbol = symbol;
36
+ this.decimals = Number(decimals);
37
+ if (price != null)
38
+ this.price = BigInt(price);
40
39
  }
41
40
  /**
42
41
  * Quotes an amount in USD (scaled by WAD) in this token.
42
+ * Returns `undefined` iff the token's price is undefined.
43
43
  * @param amount The amount of USD to quote.
44
44
  */
45
45
  fromUsd(amount, rounding = "Down") {
46
46
  if (this.price == null)
47
- return null;
48
- return MathLib.mulDiv(amount, 10n ** BigInt(this.decimals), this.price, rounding);
47
+ return;
48
+ return index_js_1.MathLib.mulDiv(amount, 10n ** BigInt(this.decimals), this.price, rounding);
49
49
  }
50
50
  /**
51
51
  * Quotes an amount of tokens in USD (scaled by WAD).
52
+ * Returns `undefined` iff the token's price is undefined.
52
53
  * @param amount The amount of tokens to quote.
53
54
  */
54
55
  toUsd(amount, rounding = "Down") {
55
56
  if (this.price == null)
56
- return null;
57
- return MathLib.mulDiv(amount, this.price, 10n ** BigInt(this.decimals), rounding);
57
+ return;
58
+ return index_js_1.MathLib.mulDiv(amount, this.price, 10n ** BigInt(this.decimals), rounding);
58
59
  }
59
60
  }
61
+ exports.Token = Token;
@@ -1,6 +1,9 @@
1
- import { VaultUtils } from "../vault/VaultUtils.js";
2
- import { WrappedToken } from "./WrappedToken.js";
3
- export class VaultToken extends WrappedToken {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultToken = void 0;
4
+ const VaultUtils_js_1 = require("../vault/VaultUtils.js");
5
+ const WrappedToken_js_1 = require("./WrappedToken.js");
6
+ class VaultToken extends WrappedToken_js_1.WrappedToken {
4
7
  asset;
5
8
  decimalsOffset;
6
9
  /**
@@ -19,9 +22,10 @@ export class VaultToken extends WrappedToken {
19
22
  this.decimalsOffset = BigInt(config.decimalsOffset);
20
23
  }
21
24
  _wrap(amount, rounding) {
22
- return VaultUtils.toShares(amount, this, rounding);
25
+ return VaultUtils_js_1.VaultUtils.toShares(amount, this, rounding);
23
26
  }
24
27
  _unwrap(amount, rounding) {
25
- return VaultUtils.toAssets(amount, this, rounding);
28
+ return VaultUtils_js_1.VaultUtils.toAssets(amount, this, rounding);
26
29
  }
27
30
  }
31
+ exports.VaultToken = VaultToken;
@@ -1,6 +1,9 @@
1
- import { MathLib } from "../math/index.js";
2
- import { Token } from "./Token.js";
3
- export class WrappedToken extends Token {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WrappedToken = void 0;
4
+ const index_js_1 = require("../math/index.js");
5
+ const Token_js_1 = require("./Token.js");
6
+ class WrappedToken extends Token_js_1.Token {
4
7
  underlying;
5
8
  constructor(token, underlying) {
6
9
  super(token);
@@ -9,21 +12,22 @@ export class WrappedToken extends Token {
9
12
  /** The expected amount when wrapping `unwrappedAmount` */
10
13
  toWrappedExactAmountIn(unwrappedAmount, slippage = 0n, rounding = "Down") {
11
14
  const wrappedAmount = this._wrap(unwrappedAmount, rounding);
12
- return MathLib.wMul(wrappedAmount, MathLib.WAD - slippage, "Down");
15
+ return index_js_1.MathLib.wMul(wrappedAmount, index_js_1.MathLib.WAD - slippage, "Down");
13
16
  }
14
17
  /** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
15
18
  toWrappedExactAmountOut(wrappedAmount, slippage = 0n, rounding = "Up") {
16
- const wAmountTarget = MathLib.wDiv(wrappedAmount, MathLib.WAD - slippage, rounding);
19
+ const wAmountTarget = index_js_1.MathLib.wDiv(wrappedAmount, index_js_1.MathLib.WAD - slippage, rounding);
17
20
  return this._unwrap(wAmountTarget, rounding);
18
21
  }
19
22
  /** The expected amount when unwrapping `wrappedAmount` */
20
23
  toUnwrappedExactAmountIn(wrappedAmount, slippage = 0n, rounding = "Down") {
21
24
  const unwrappedAmount = this._unwrap(wrappedAmount, rounding);
22
- return MathLib.wMul(unwrappedAmount, MathLib.WAD - slippage, "Up");
25
+ return index_js_1.MathLib.wMul(unwrappedAmount, index_js_1.MathLib.WAD - slippage, "Up");
23
26
  }
24
27
  /** The amount of wrappedTokens that should be unwrapped to receive `unwrappedAmount` */
25
28
  toUnwrappedExactAmountOut(unwrappedAmount, slippage = 0n, rounding = "Up") {
26
- const unwrappedAmountToTarget = MathLib.wDiv(unwrappedAmount, MathLib.WAD - slippage, rounding);
29
+ const unwrappedAmountToTarget = index_js_1.MathLib.wDiv(unwrappedAmount, index_js_1.MathLib.WAD - slippage, rounding);
27
30
  return this._wrap(unwrappedAmountToTarget, rounding);
28
31
  }
29
32
  }
33
+ exports.WrappedToken = WrappedToken;
@@ -1,5 +1,21 @@
1
- export * from "./Token.js";
2
- export * from "./WrappedToken.js";
3
- export * from "./ConstantWrappedToken.js";
4
- export * from "./ExchangeRateWrappedToken.js";
5
- export * from "./VaultToken.js";
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("./Token.js"), exports);
18
+ __exportStar(require("./WrappedToken.js"), exports);
19
+ __exportStar(require("./ConstantWrappedToken.js"), exports);
20
+ __exportStar(require("./ExchangeRateWrappedToken.js"), exports);
21
+ __exportStar(require("./VaultToken.js"), exports);
package/lib/types.js CHANGED
@@ -1,7 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMarketId = exports.TransactionType = void 0;
4
+ exports.isFetched = isFetched;
1
5
  /**
2
6
  * The possible transaction type on the Blue contract
3
7
  */
4
- export var TransactionType;
8
+ var TransactionType;
5
9
  (function (TransactionType) {
6
10
  TransactionType["Supply"] = "Supply";
7
11
  TransactionType["SupplyCollateral"] = "Supply Collateral";
@@ -9,9 +13,10 @@ export var TransactionType;
9
13
  TransactionType["WithdrawCollateral"] = "Withdraw Collateral";
10
14
  TransactionType["Borrow"] = "Borrow";
11
15
  TransactionType["Repay"] = "Repay";
12
- })(TransactionType || (TransactionType = {}));
16
+ })(TransactionType || (exports.TransactionType = TransactionType = {}));
13
17
  // TODO: replace with isDefined
14
- export function isFetched(v) {
18
+ function isFetched(v) {
15
19
  return v !== undefined && v !== null;
16
20
  }
17
- export const isMarketId = (value) => typeof value === "string" && /^0x[0-9A-Fa-f]{64}$/.test(value);
21
+ const isMarketId = (value) => typeof value === "string" && /^0x[0-9A-Fa-f]{64}$/.test(value);
22
+ exports.isMarketId = isMarketId;
package/lib/user/User.js CHANGED
@@ -1,4 +1,7 @@
1
- export class User {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.User = void 0;
4
+ class User {
2
5
  /**
3
6
  * The user's address.
4
7
  */
@@ -17,3 +20,4 @@ export class User {
17
20
  this.morphoNonce = morphoNonce;
18
21
  }
19
22
  }
23
+ exports.User = User;
package/lib/user/index.js CHANGED
@@ -1 +1,17 @@
1
- export * from "./User.js";
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("./User.js"), exports);
@@ -41,6 +41,14 @@ export interface InputVault extends InputVaultConfig {
41
41
  publicAllocatorConfig?: VaultPublicAllocatorConfig;
42
42
  }
43
43
  export declare class Vault extends VaultToken implements InputVault {
44
+ /**
45
+ * The vault's share token's name.
46
+ */
47
+ readonly name: string;
48
+ /**
49
+ * The vault's share token's symbol.
50
+ */
51
+ readonly symbol: string;
44
52
  /**
45
53
  * The MetaMorpho vault's owner address.
46
54
  */
@@ -1,8 +1,11 @@
1
- import { CapacityLimitReason } from "../market/index.js";
2
- import { MathLib } from "../math/index.js";
3
- import { VaultToken } from "../token/index.js";
4
- import { VaultMarketAllocation, } from "./VaultMarketAllocation.js";
5
- export class Vault extends VaultToken {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccrualVault = exports.Vault = void 0;
4
+ const index_js_1 = require("../market/index.js");
5
+ const index_js_2 = require("../math/index.js");
6
+ const index_js_3 = require("../token/index.js");
7
+ const VaultMarketAllocation_js_1 = require("./VaultMarketAllocation.js");
8
+ class Vault extends index_js_3.VaultToken {
6
9
  /**
7
10
  * The MetaMorpho vault's owner address.
8
11
  */
@@ -83,7 +86,7 @@ export class Vault extends VaultToken {
83
86
  * The amount of interest in assets accrued since the last interaction with the vault.
84
87
  */
85
88
  get totalInterest() {
86
- return MathLib.zeroFloorSub(this.totalAssets, this.lastTotalAssets);
89
+ return index_js_2.MathLib.zeroFloorSub(this.totalAssets, this.lastTotalAssets);
87
90
  }
88
91
  toAssets(shares, rounding) {
89
92
  return this._unwrap(shares, rounding);
@@ -92,7 +95,8 @@ export class Vault extends VaultToken {
92
95
  return this._wrap(assets, rounding);
93
96
  }
94
97
  }
95
- export class AccrualVault extends Vault {
98
+ exports.Vault = Vault;
99
+ class AccrualVault extends Vault {
96
100
  /**
97
101
  * The allocation of the vault on each market enabled.
98
102
  */
@@ -114,11 +118,11 @@ export class AccrualVault extends Vault {
114
118
  });
115
119
  this.allocations = new Map(allocations.map((allocation) => [
116
120
  allocation.position.market.id,
117
- new VaultMarketAllocation(allocation),
121
+ new VaultMarketAllocation_js_1.VaultMarketAllocation(allocation),
118
122
  ]));
119
123
  this.collateralAllocations = new Map();
120
124
  for (const { marketId, position } of this.allocations.values()) {
121
- const address = position.market.config.collateralToken;
125
+ const address = position.market.params.collateralToken;
122
126
  let exposure = this.collateralAllocations.get(address);
123
127
  if (!exposure)
124
128
  this.collateralAllocations.set(address, (exposure = {
@@ -128,8 +132,8 @@ export class AccrualVault extends Vault {
128
132
  markets: new Set(),
129
133
  proportion: 0n,
130
134
  }));
131
- exposure.lltvs.add(position.market.config.lltv);
132
- exposure.oracles.add(position.market.config.oracle);
135
+ exposure.lltvs.add(position.market.params.lltv);
136
+ exposure.oracles.add(position.market.params.oracle);
133
137
  exposure.markets.add(marketId);
134
138
  exposure.proportion += this.getAllocationProportion(marketId);
135
139
  }
@@ -156,7 +160,7 @@ export class AccrualVault extends Vault {
156
160
  * The MetaMorpho vault's average APY on its assets, excluding the performance fee.
157
161
  */
158
162
  get netApy() {
159
- return MathLib.wMulDown(this.avgApy, MathLib.WAD - this.fee);
163
+ return index_js_2.MathLib.wMulDown(this.avgApy, index_js_2.MathLib.WAD - this.fee);
160
164
  }
161
165
  getAllocationProportion(marketId) {
162
166
  if (this.totalAssets === 0n)
@@ -164,23 +168,23 @@ export class AccrualVault extends Vault {
164
168
  const allocation = this.allocations.get(marketId);
165
169
  if (!allocation)
166
170
  return 0n;
167
- return MathLib.wDivDown(allocation.position.supplyAssets, this.totalAssets);
171
+ return index_js_2.MathLib.wDivDown(allocation.position.supplyAssets, this.totalAssets);
168
172
  }
169
173
  getDepositCapacityLimit(assets) {
170
174
  const suppliable = this.allocations
171
175
  .values()
172
- .reduce((total, { config: { cap }, position: { marketId, supplyAssets } }) => MathLib.min(total +
176
+ .reduce((total, { config: { cap }, position: { marketId, supplyAssets } }) => index_js_2.MathLib.min(total +
173
177
  (this.supplyQueue.includes(marketId)
174
- ? MathLib.zeroFloorSub(cap, supplyAssets)
175
- : 0n), MathLib.MAX_UINT_256), 0n);
178
+ ? index_js_2.MathLib.zeroFloorSub(cap, supplyAssets)
179
+ : 0n), index_js_2.MathLib.MAX_UINT_256), 0n);
176
180
  if (assets > suppliable)
177
181
  return {
178
182
  value: suppliable,
179
- limiter: CapacityLimitReason.cap,
183
+ limiter: index_js_1.CapacityLimitReason.cap,
180
184
  };
181
185
  return {
182
186
  value: assets,
183
- limiter: CapacityLimitReason.balance,
187
+ limiter: index_js_1.CapacityLimitReason.balance,
184
188
  };
185
189
  }
186
190
  getWithdrawCapacityLimit(shares) {
@@ -189,11 +193,11 @@ export class AccrualVault extends Vault {
189
193
  if (assets > liquidity)
190
194
  return {
191
195
  value: liquidity,
192
- limiter: CapacityLimitReason.liquidity,
196
+ limiter: index_js_1.CapacityLimitReason.liquidity,
193
197
  };
194
198
  return {
195
199
  value: assets,
196
- limiter: CapacityLimitReason.balance,
200
+ limiter: index_js_1.CapacityLimitReason.balance,
197
201
  };
198
202
  }
199
203
  /**
@@ -210,7 +214,7 @@ export class AccrualVault extends Vault {
210
214
  position: position.accrueInterest(timestamp),
211
215
  };
212
216
  }));
213
- const feeAssets = MathLib.wMulDown(vault.totalInterest, vault.fee);
217
+ const feeAssets = index_js_2.MathLib.wMulDown(vault.totalInterest, vault.fee);
214
218
  vault.totalAssets -= feeAssets;
215
219
  const feeShares = vault.toShares(feeAssets, "Down");
216
220
  vault.totalAssets += feeAssets;
@@ -219,3 +223,4 @@ export class AccrualVault extends Vault {
219
223
  return vault;
220
224
  }
221
225
  }
226
+ exports.AccrualVault = AccrualVault;
@@ -1,11 +1,14 @@
1
- import { UnknownVaultConfigError } from "../errors.js";
2
- export class VaultConfig {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultConfig = void 0;
4
+ const errors_js_1 = require("../errors.js");
5
+ class VaultConfig {
3
6
  chainId;
4
7
  static _CACHE = {};
5
8
  static get(address, chainId) {
6
9
  const config = VaultConfig._CACHE[chainId]?.[address];
7
10
  if (!config)
8
- throw new UnknownVaultConfigError(address);
11
+ throw new errors_js_1.UnknownVaultConfigError(address);
9
12
  return config;
10
13
  }
11
14
  address;
@@ -26,3 +29,4 @@ export class VaultConfig {
26
29
  (VaultConfig._CACHE[chainId] ??= {})[address] = this;
27
30
  }
28
31
  }
32
+ exports.VaultConfig = VaultConfig;
@@ -1,5 +1,8 @@
1
- import { MathLib } from "../math/index.js";
2
- export class VaultMarketAllocation {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultMarketAllocation = void 0;
4
+ const index_js_1 = require("../math/index.js");
5
+ class VaultMarketAllocation {
3
6
  /**
4
7
  * The vault's configuration on the corresponding market.
5
8
  */
@@ -20,7 +23,8 @@ export class VaultMarketAllocation {
20
23
  }
21
24
  get utilization() {
22
25
  if (this.config.cap === 0n)
23
- return MathLib.MAX_UINT_256;
24
- return MathLib.wDivDown(this.position.supplyAssets, this.config.cap);
26
+ return index_js_1.MathLib.MAX_UINT_256;
27
+ return index_js_1.MathLib.wDivDown(this.position.supplyAssets, this.config.cap);
25
28
  }
26
29
  }
30
+ exports.VaultMarketAllocation = VaultMarketAllocation;
@@ -1,4 +1,7 @@
1
- export class VaultMarketConfig {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultMarketConfig = void 0;
4
+ class VaultMarketConfig {
2
5
  /**
3
6
  * The vault's address.
4
7
  */
@@ -37,3 +40,4 @@ export class VaultMarketConfig {
37
40
  this.publicAllocatorConfig = publicAllocatorConfig;
38
41
  }
39
42
  }
43
+ exports.VaultMarketConfig = VaultMarketConfig;
@@ -1,4 +1,7 @@
1
- export class VaultMarketPublicAllocatorConfig {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultMarketPublicAllocatorConfig = void 0;
4
+ class VaultMarketPublicAllocatorConfig {
2
5
  /**
3
6
  * The vault's address.
4
7
  */
@@ -22,3 +25,4 @@ export class VaultMarketPublicAllocatorConfig {
22
25
  this.maxOut = maxOut;
23
26
  }
24
27
  }
28
+ exports.VaultMarketPublicAllocatorConfig = VaultMarketPublicAllocatorConfig;
@@ -1,4 +1,7 @@
1
- export class VaultUser {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultUser = void 0;
4
+ class VaultUser {
2
5
  /**
3
6
  * The vault's address.
4
7
  */
@@ -22,3 +25,4 @@ export class VaultUser {
22
25
  this.allowance = allowance;
23
26
  }
24
27
  }
28
+ exports.VaultUser = VaultUser;
@@ -1,17 +1,20 @@
1
- import { MathLib } from "../math/index.js";
2
- export var VaultUtils;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultUtils = void 0;
4
+ const index_js_1 = require("../math/index.js");
5
+ var VaultUtils;
3
6
  (function (VaultUtils) {
4
7
  VaultUtils.VIRTUAL_ASSETS = 1n;
5
8
  function decimalsOffset(decimals) {
6
- return MathLib.zeroFloorSub(18n, decimals);
9
+ return index_js_1.MathLib.zeroFloorSub(18n, decimals);
7
10
  }
8
11
  VaultUtils.decimalsOffset = decimalsOffset;
9
12
  function toAssets(shares, { totalAssets, totalSupply, decimalsOffset, }, rounding = "Down") {
10
- return MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
13
+ return index_js_1.MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
11
14
  }
12
15
  VaultUtils.toAssets = toAssets;
13
16
  function toShares(assets, { totalAssets, totalSupply, decimalsOffset, }, rounding = "Up") {
14
- return MathLib.mulDiv(assets, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
17
+ return index_js_1.MathLib.mulDiv(assets, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
15
18
  }
16
19
  VaultUtils.toShares = toShares;
17
- })(VaultUtils || (VaultUtils = {}));
20
+ })(VaultUtils || (exports.VaultUtils = VaultUtils = {}));
@@ -1,7 +1,23 @@
1
- export * from "./VaultUtils.js";
2
- export * from "./VaultConfig.js";
3
- export * from "./VaultMarketAllocation.js";
4
- export * from "./VaultMarketConfig.js";
5
- export * from "./VaultMarketPublicAllocatorConfig.js";
6
- export * from "./VaultUser.js";
7
- export * from "./Vault.js";
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("./VaultUtils.js"), exports);
18
+ __exportStar(require("./VaultConfig.js"), exports);
19
+ __exportStar(require("./VaultMarketAllocation.js"), exports);
20
+ __exportStar(require("./VaultMarketConfig.js"), exports);
21
+ __exportStar(require("./VaultMarketPublicAllocatorConfig.js"), exports);
22
+ __exportStar(require("./VaultUser.js"), exports);
23
+ __exportStar(require("./Vault.js"), exports);
package/package.json CHANGED
@@ -1,61 +1,40 @@
1
1
  {
2
2
  "name": "@morpho-org/blue-sdk",
3
- "version": "2.0.0-next.2",
4
- "author": "Morpho Labs <contact@morpho.org>",
3
+ "description": "Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).",
4
+ "version": "2.0.0-next.21",
5
+ "author": "Morpho Association <contact@morpho.org>",
6
+ "contributors": [
7
+ "Rubilmax <rmilon@gmail.com>"
8
+ ],
9
+ "repository": "github:morpho-org/sdks",
10
+ "homepage": "https://github.com/morpho-org/sdks",
11
+ "bugs": {
12
+ "url": "https://github.com/morpho-org/sdks/issues",
13
+ "email": "contact@morpho.org"
14
+ },
5
15
  "license": "MIT",
6
- "type": "module",
7
16
  "main": "lib/index.js",
8
17
  "files": [
9
18
  "lib"
10
19
  ],
11
20
  "dependencies": {
12
- "keccak256": "^1.0.6"
21
+ "@noble/hashes": "^1.5.0"
13
22
  },
14
23
  "peerDependencies": {
15
- "@morpho-org/morpho-ts": "^1.12.4"
24
+ "@morpho-org/morpho-ts": "^2.0.0-next.10"
16
25
  },
17
26
  "devDependencies": {
18
- "@types/node": "^22.1.0",
27
+ "@types/node": "^22.8.7",
19
28
  "typescript": "^5.6.3",
20
- "viem": "^2.21.19",
21
- "viem-deal": "^2.0.0",
22
- "vitest": "^2.1.3",
23
- "@morpho-org/morpho-ts": "^1.12.4",
24
- "@morpho-org/test-viem": "^1.12.4",
25
- "@morpho-org/test": "^1.12.4"
26
- },
27
- "release": {
28
- "branches": [
29
- "main",
30
- {
31
- "name": "next",
32
- "prerelease": true
33
- }
34
- ],
35
- "extends": "semantic-release-monorepo",
36
- "plugins": [
37
- "@semantic-release/commit-analyzer",
38
- "@semantic-release/release-notes-generator",
39
- [
40
- "@semantic-release/exec",
41
- {
42
- "prepareCmd": "pnpm version ${nextRelease.version} --no-git-tag-version",
43
- "publishCmd": "pnpm publish --access public --tag ${nextRelease.channel} --no-git-checks"
44
- }
45
- ],
46
- "@semantic-release/github"
47
- ]
29
+ "viem": "^2.21.40",
30
+ "vitest": "^2.1.4",
31
+ "@morpho-org/morpho-ts": "^2.0.0-next.10",
32
+ "@morpho-org/test": "^2.0.0-next.17"
48
33
  },
49
34
  "scripts": {
50
35
  "prepublish": "$npm_execpath build",
51
36
  "build": "tsc --build tsconfig.build.json",
52
37
  "test": "vitest"
53
38
  },
54
- "types": "lib/index.d.ts",
55
- "exports": {
56
- ".": {
57
- "types": "./lib/index.d.ts",
58
- "default": "./lib/index.js"
59
- }
60
- }
39
+ "types": "lib/index.d.ts"
61
40
  }