@morpho-org/blue-sdk 1.10.3 → 1.10.5-alpha.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.
@@ -38,17 +38,26 @@ declare global {
38
38
  insert(index: number, substr: string, fillWith?: string): string;
39
39
  }
40
40
  }
41
+ /**
42
+ * @deprecated Import from `@morpho-org/morpho-ts`
43
+ */
41
44
  export declare abstract class BaseFormatter {
42
45
  protected abstract _options: FormatOptions;
43
46
  constructor();
44
47
  of(value: bigint, decimals: number): string;
45
48
  of(value: number): string;
46
49
  }
50
+ /**
51
+ * @deprecated Import from `@morpho-org/morpho-ts`
52
+ */
47
53
  export declare class HexFormatter extends BaseFormatter {
48
54
  protected _options: {
49
55
  format: Format;
50
56
  };
51
57
  }
58
+ /**
59
+ * @deprecated Import from `@morpho-org/morpho-ts`
60
+ */
52
61
  export declare abstract class CommonFormatter extends BaseFormatter {
53
62
  protected abstract _options: BaseFormatOptions;
54
63
  digits(_d: number): this;
@@ -60,19 +69,34 @@ export declare abstract class CommonFormatter extends BaseFormatter {
60
69
  unit(_u: string): this;
61
70
  locale(_l: string): this;
62
71
  }
72
+ /**
73
+ * @deprecated Import from `@morpho-org/morpho-ts`
74
+ */
63
75
  export declare class NumberFormatter extends CommonFormatter {
64
76
  protected _options: FormatNumberOptions;
65
77
  }
78
+ /**
79
+ * @deprecated Import from `@morpho-org/morpho-ts`
80
+ */
66
81
  export declare class CommasFormatter extends CommonFormatter {
67
82
  protected _options: FormatCommasOptions;
68
83
  }
84
+ /**
85
+ * @deprecated Import from `@morpho-org/morpho-ts`
86
+ */
69
87
  export declare class ShortFormatter extends CommonFormatter {
70
88
  protected _options: FormatShortOptions;
71
89
  smallValuesWithCommas(): this;
72
90
  }
91
+ /**
92
+ * @deprecated Import from `@morpho-org/morpho-ts`
93
+ */
73
94
  export declare class PercentFormatter extends CommonFormatter {
74
95
  protected _options: FormatPercentOptions;
75
96
  }
97
+ /**
98
+ * @deprecated Import from `@morpho-org/morpho-ts`
99
+ */
76
100
  export declare const format: {
77
101
  /**
78
102
  * Return the value as an integer in hex format
@@ -153,6 +153,9 @@ function formatBI(bi, decimals, formatOptions = { format: Format.hex }) {
153
153
  }
154
154
  return formattedValue;
155
155
  }
156
+ /**
157
+ * @deprecated Import from `@morpho-org/morpho-ts`
158
+ */
156
159
  class BaseFormatter {
157
160
  constructor() { }
158
161
  of(value, decimals) {
@@ -169,10 +172,16 @@ class BaseFormatter {
169
172
  }
170
173
  }
171
174
  exports.BaseFormatter = BaseFormatter;
175
+ /**
176
+ * @deprecated Import from `@morpho-org/morpho-ts`
177
+ */
172
178
  class HexFormatter extends BaseFormatter {
173
179
  _options = { format: Format.hex };
174
180
  }
175
181
  exports.HexFormatter = HexFormatter;
182
+ /**
183
+ * @deprecated Import from `@morpho-org/morpho-ts`
184
+ */
176
185
  class CommonFormatter extends BaseFormatter {
177
186
  digits(_d) {
178
187
  this._options.digits = _d;
@@ -208,14 +217,23 @@ class CommonFormatter extends BaseFormatter {
208
217
  }
209
218
  }
210
219
  exports.CommonFormatter = CommonFormatter;
220
+ /**
221
+ * @deprecated Import from `@morpho-org/morpho-ts`
222
+ */
211
223
  class NumberFormatter extends CommonFormatter {
212
224
  _options = { format: Format.number };
213
225
  }
214
226
  exports.NumberFormatter = NumberFormatter;
227
+ /**
228
+ * @deprecated Import from `@morpho-org/morpho-ts`
229
+ */
215
230
  class CommasFormatter extends CommonFormatter {
216
231
  _options = { format: Format.commas };
217
232
  }
218
233
  exports.CommasFormatter = CommasFormatter;
234
+ /**
235
+ * @deprecated Import from `@morpho-org/morpho-ts`
236
+ */
219
237
  class ShortFormatter extends CommonFormatter {
220
238
  _options = { format: Format.short };
221
239
  smallValuesWithCommas() {
@@ -224,10 +242,16 @@ class ShortFormatter extends CommonFormatter {
224
242
  }
225
243
  }
226
244
  exports.ShortFormatter = ShortFormatter;
245
+ /**
246
+ * @deprecated Import from `@morpho-org/morpho-ts`
247
+ */
227
248
  class PercentFormatter extends CommonFormatter {
228
249
  _options = { format: Format.percent };
229
250
  }
230
251
  exports.PercentFormatter = PercentFormatter;
252
+ /**
253
+ * @deprecated Import from `@morpho-org/morpho-ts`
254
+ */
231
255
  exports.format = {
232
256
  /**
233
257
  * Return the value as an integer in hex format
@@ -8,10 +8,14 @@ export type LocaleParts = LocaleSymbols & {
8
8
  };
9
9
  /**
10
10
  * @returns the locale symbols for the given locale defaulting to en-US
11
+ *
12
+ * @deprecated Import from `@morpho-org/morpho-ts`
11
13
  */
12
14
  export declare const getLocaleSymbols: (locale: string) => LocaleSymbols;
13
15
  /**
14
16
  * @returns the effective browser locale
17
+ *
18
+ * @deprecated Import from `@morpho-org/morpho-ts`
15
19
  */
16
20
  export declare const getEffectiveLocale: () => string;
17
21
  /**
@@ -19,18 +23,24 @@ export declare const getEffectiveLocale: () => string;
19
23
  * @param numStr the number as a string in the "from" locale (e.g. "1,2345.6" for en-US)
20
24
  * @param from the locale the numStr is in (e.g. "en-US")
21
25
  * @param to the locale to convert to (e.g. "fr-FR")
26
+ *
27
+ * @deprecated Import from `@morpho-org/morpho-ts`
22
28
  */
23
29
  export declare const convertNumStrToLocal: (numStr: string, from: string, to: string) => string;
24
30
  /**
25
31
  * @returns the value as a string in the effective browser locale
26
32
  * @param numStr the number as a string in the effective browser locale (e.g. "1,2345.6" for en-US)
27
33
  * @param to the locale to use (e.g. "fr-FR")
34
+ *
35
+ * @deprecated Import from `@morpho-org/morpho-ts`
28
36
  */
29
37
  export declare const convertNumStrFromEffectiveTo: (numStr: string, to: string) => string;
30
38
  /**
31
39
  * @returns the value as a string with the given locale symbols either from the given locale or the effective browser locale
32
40
  * @param numStr the number as a string in english format (e.g. "1,2345.6")
33
41
  * @param locale optional - the locale to use (e.g. "fr-FR")
42
+ *
43
+ * @deprecated Import from `@morpho-org/morpho-ts`
34
44
  */
35
45
  export declare const getEnUSNumberToLocalParts: (numStr: string, locale?: string) => LocaleParts;
36
46
  export {};
@@ -9,6 +9,8 @@ const _convertEnNumStrToLocale = (numStr, localSymbols) => {
9
9
  };
10
10
  /**
11
11
  * @returns the locale symbols for the given locale defaulting to en-US
12
+ *
13
+ * @deprecated Import from `@morpho-org/morpho-ts`
12
14
  */
13
15
  const getLocaleSymbols = (locale) => {
14
16
  let formatter;
@@ -31,6 +33,8 @@ const getLocaleSymbols = (locale) => {
31
33
  exports.getLocaleSymbols = getLocaleSymbols;
32
34
  /**
33
35
  * @returns the effective browser locale
36
+ *
37
+ * @deprecated Import from `@morpho-org/morpho-ts`
34
38
  */
35
39
  const getEffectiveLocale = () => {
36
40
  if (typeof window !== "undefined") {
@@ -51,6 +55,8 @@ exports.getEffectiveLocale = getEffectiveLocale;
51
55
  * @param numStr the number as a string in the "from" locale (e.g. "1,2345.6" for en-US)
52
56
  * @param from the locale the numStr is in (e.g. "en-US")
53
57
  * @param to the locale to convert to (e.g. "fr-FR")
58
+ *
59
+ * @deprecated Import from `@morpho-org/morpho-ts`
54
60
  */
55
61
  const convertNumStrToLocal = (numStr, from, to) => {
56
62
  const fromSymbols = (0, exports.getLocaleSymbols)(from);
@@ -66,6 +72,8 @@ exports.convertNumStrToLocal = convertNumStrToLocal;
66
72
  * @returns the value as a string in the effective browser locale
67
73
  * @param numStr the number as a string in the effective browser locale (e.g. "1,2345.6" for en-US)
68
74
  * @param to the locale to use (e.g. "fr-FR")
75
+ *
76
+ * @deprecated Import from `@morpho-org/morpho-ts`
69
77
  */
70
78
  const convertNumStrFromEffectiveTo = (numStr, to) => {
71
79
  const from = (0, exports.getEffectiveLocale)();
@@ -76,6 +84,8 @@ exports.convertNumStrFromEffectiveTo = convertNumStrFromEffectiveTo;
76
84
  * @returns the value as a string with the given locale symbols either from the given locale or the effective browser locale
77
85
  * @param numStr the number as a string in english format (e.g. "1,2345.6")
78
86
  * @param locale optional - the locale to use (e.g. "fr-FR")
87
+ *
88
+ * @deprecated Import from `@morpho-org/morpho-ts`
79
89
  */
80
90
  const getEnUSNumberToLocalParts = (numStr, locale) => {
81
91
  const _locale = locale || (0, exports.getEffectiveLocale)();
@@ -1,4 +1,4 @@
1
- import { Address } from "../types";
1
+ import { Address, BigIntish } from "../types";
2
2
  export declare const ERC20_ALLOWANCE_RECIPIENTS: readonly ["morpho", "permit2", "bundler"];
3
3
  export declare const PERMIT2_ALLOWANCE_RECIPIENTS: readonly ["morpho", "bundler"];
4
4
  export type Erc20AllowanceRecipient = (typeof ERC20_ALLOWANCE_RECIPIENTS)[number];
@@ -8,6 +8,11 @@ export interface Permit2Allowance {
8
8
  expiration: bigint;
9
9
  nonce: bigint;
10
10
  }
11
+ export interface InputPermit2Allowance {
12
+ amount: BigIntish;
13
+ expiration: BigIntish;
14
+ nonce: BigIntish;
15
+ }
11
16
  export interface InputHolding {
12
17
  user: Address;
13
18
  token: Address;
@@ -15,7 +20,7 @@ export interface InputHolding {
15
20
  [key in Erc20AllowanceRecipient]: bigint;
16
21
  };
17
22
  permit2Allowances: {
18
- [key in Permit2AllowanceRecipient]: Permit2Allowance;
23
+ [key in Permit2AllowanceRecipient]: InputPermit2Allowance;
19
24
  };
20
25
  erc2612Nonce?: bigint;
21
26
  canTransfer?: boolean;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Holding = exports.PERMIT2_ALLOWANCE_RECIPIENTS = exports.ERC20_ALLOWANCE_RECIPIENTS = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
- const addresses_1 = require("../addresses");
6
5
  exports.ERC20_ALLOWANCE_RECIPIENTS = [
7
6
  "morpho",
8
7
  "permit2",
@@ -42,16 +41,27 @@ class Holding {
42
41
  * `undefined` if the token does not support ERC-2612.
43
42
  */
44
43
  erc2612Nonce;
45
- constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer = true, }) {
44
+ constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer, }) {
46
45
  this.user = user;
47
46
  this.token = token;
48
47
  this.balance = balance;
49
- this.canTransfer = token === addresses_1.NATIVE_ADDRESS || canTransfer;
48
+ this.canTransfer = canTransfer;
50
49
  this.erc20Allowances = (0, morpho_ts_1.fromEntries)((0, morpho_ts_1.entries)(erc20Allowances).map(([address, allowance]) => [
51
50
  address,
52
51
  allowance,
53
52
  ]));
54
- this.permit2Allowances = permit2Allowances;
53
+ this.permit2Allowances = {
54
+ morpho: {
55
+ amount: BigInt(permit2Allowances.morpho.amount),
56
+ expiration: BigInt(permit2Allowances.morpho.expiration),
57
+ nonce: BigInt(permit2Allowances.morpho.nonce),
58
+ },
59
+ bundler: {
60
+ amount: BigInt(permit2Allowances.bundler.amount),
61
+ expiration: BigInt(permit2Allowances.bundler.expiration),
62
+ nonce: BigInt(permit2Allowances.bundler.nonce),
63
+ },
64
+ };
55
65
  if (erc2612Nonce != null)
56
66
  this.erc2612Nonce = erc2612Nonce;
57
67
  }
package/lib/index.d.ts CHANGED
@@ -9,7 +9,6 @@ export * from "./maths";
9
9
  export * from "./user";
10
10
  export * from "./holding";
11
11
  export * from "./position";
12
- export * from "./helpers";
13
12
  export * from "./vault";
14
13
  export * as constants from "./constants";
15
14
  export * as errors from "./errors";
@@ -21,5 +20,4 @@ export * as holding from "./holding";
21
20
  export * as types from "./types";
22
21
  export * as maths from "./maths";
23
22
  export * as user from "./user";
24
- export * as helpers from "./helpers";
25
23
  export * as vault from "./vault";
package/lib/index.js CHANGED
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.vault = exports.helpers = exports.user = exports.maths = exports.types = exports.holding = exports.position = exports.token = exports.chain = exports.market = exports.errors = exports.constants = void 0;
29
+ exports.vault = exports.user = exports.maths = exports.types = exports.holding = exports.position = exports.token = exports.chain = exports.market = exports.errors = exports.constants = void 0;
30
30
  __exportStar(require("./addresses"), exports);
31
31
  __exportStar(require("./constants"), exports);
32
32
  __exportStar(require("./errors"), exports);
@@ -38,7 +38,6 @@ __exportStar(require("./maths"), exports);
38
38
  __exportStar(require("./user"), exports);
39
39
  __exportStar(require("./holding"), exports);
40
40
  __exportStar(require("./position"), exports);
41
- __exportStar(require("./helpers"), exports);
42
41
  __exportStar(require("./vault"), exports);
43
42
  exports.constants = __importStar(require("./constants"));
44
43
  exports.errors = __importStar(require("./errors"));
@@ -50,5 +49,4 @@ exports.holding = __importStar(require("./holding"));
50
49
  exports.types = __importStar(require("./types"));
51
50
  exports.maths = __importStar(require("./maths"));
52
51
  exports.user = __importStar(require("./user"));
53
- exports.helpers = __importStar(require("./helpers"));
54
52
  exports.vault = __importStar(require("./vault"));
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MathLib = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
- const helpers_1 = require("../helpers");
6
5
  /**
7
6
  * Library to manage fixed-point arithmetic.
8
7
  * This library reproduces the behaviour of the solidity library MathLib
@@ -157,7 +156,7 @@ class MathLib {
157
156
  static rateToApy(rate, period) {
158
157
  const { unit, duration } = morpho_ts_1.Time.toPeriod(period);
159
158
  const factor = morpho_ts_1.Time[unit].from.y(1) / duration;
160
- return ((1 + Number(helpers_1.format.number.locale("en").of(BigInt(rate), 18))) ** factor -
159
+ return ((1 + Number(morpho_ts_1.format.number.locale("en").of(BigInt(rate), 18))) ** factor -
161
160
  1);
162
161
  }
163
162
  /**
@@ -1,11 +1,10 @@
1
1
  import { RoundingDirection } from "../maths";
2
- import { Address } from "../types";
2
+ import { Address, BigIntish } from "../types";
3
3
  import { InputToken } from "./Token";
4
4
  import { WrappedToken } from "./WrappedToken";
5
5
  export declare class ConstantWrappedToken extends WrappedToken {
6
- readonly underlying: Address;
7
- private readonly _underlyingDecimals;
8
- constructor(token: InputToken, underlying: Address, _underlyingDecimals?: number);
6
+ readonly underlyingDecimals: bigint;
7
+ constructor(token: InputToken, underlying: Address, underlyingDecimals?: BigIntish);
9
8
  toWrappedExactAmountIn(unwrappedAmount: bigint, _slippage?: bigint, rounding?: RoundingDirection): bigint;
10
9
  /** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
11
10
  toWrappedExactAmountOut(wrappedAmount: bigint, _slippage?: bigint, rounding?: RoundingDirection): bigint;
@@ -4,12 +4,10 @@ exports.ConstantWrappedToken = void 0;
4
4
  const maths_1 = require("../maths");
5
5
  const WrappedToken_1 = require("./WrappedToken");
6
6
  class ConstantWrappedToken extends WrappedToken_1.WrappedToken {
7
- underlying;
8
- _underlyingDecimals;
9
- constructor(token, underlying, _underlyingDecimals = 18) {
7
+ underlyingDecimals;
8
+ constructor(token, underlying, underlyingDecimals = 18n) {
10
9
  super(token, underlying);
11
- this.underlying = underlying;
12
- this._underlyingDecimals = _underlyingDecimals;
10
+ this.underlyingDecimals = BigInt(underlyingDecimals);
13
11
  }
14
12
  toWrappedExactAmountIn(unwrappedAmount, _slippage, rounding = "Down") {
15
13
  return super.toWrappedExactAmountIn(unwrappedAmount, 0n, rounding);
@@ -27,10 +25,10 @@ class ConstantWrappedToken extends WrappedToken_1.WrappedToken {
27
25
  return super.toUnwrappedExactAmountOut(unwrappedAmount, 0n, rounding);
28
26
  }
29
27
  _wrap(amount) {
30
- return maths_1.MathLib.mulDivDown(amount, 10n ** BigInt(this.decimals), 10n ** BigInt(this._underlyingDecimals));
28
+ return maths_1.MathLib.mulDivDown(amount, 10n ** BigInt(this.decimals), 10n ** this.underlyingDecimals);
31
29
  }
32
30
  _unwrap(amount) {
33
- return maths_1.MathLib.mulDivDown(amount, 10n ** BigInt(this._underlyingDecimals), 10n ** BigInt(this.decimals));
31
+ return maths_1.MathLib.mulDivDown(amount, 10n ** this.underlyingDecimals, 10n ** BigInt(this.decimals));
34
32
  }
35
33
  }
36
34
  exports.ConstantWrappedToken = ConstantWrappedToken;
@@ -1,9 +1,9 @@
1
1
  import { ChainId } from "../chain";
2
2
  import { RoundingDirection } from "../maths";
3
- import { Address } from "../types";
3
+ import { Address, BigIntish } from "../types";
4
4
  export interface InputToken {
5
5
  address: Address;
6
- decimals: number;
6
+ decimals: BigIntish;
7
7
  symbol: string;
8
8
  name?: string;
9
9
  }
@@ -27,7 +27,7 @@ class Token {
27
27
  name;
28
28
  constructor({ address, decimals, symbol, name }) {
29
29
  this.address = address;
30
- this.decimals = decimals;
30
+ this.decimals = Number(decimals);
31
31
  this.symbol = symbol;
32
32
  this.name = name ?? symbol;
33
33
  }
@@ -11,7 +11,7 @@ class VaultToken extends WrappedToken_1.WrappedToken {
11
11
  super(config, config.asset);
12
12
  this.totalAssets = totalAssets;
13
13
  this.totalSupply = totalSupply;
14
- this.decimalsOffset = config.decimalsOffset;
14
+ this.decimalsOffset = BigInt(config.decimalsOffset);
15
15
  }
16
16
  _wrap(amount, rounding) {
17
17
  return VaultUtils_1.VaultUtils.toShares(amount, this, this, rounding);
@@ -1,9 +1,9 @@
1
1
  import { ChainId } from "../chain";
2
- import { Address } from "../types";
2
+ import { Address, BigIntish } from "../types";
3
3
  export interface InputVaultConfig {
4
4
  address: Address;
5
- decimals: number;
6
- decimalsOffset: bigint;
5
+ decimals: BigIntish;
6
+ decimalsOffset: BigIntish;
7
7
  symbol: string;
8
8
  name: string;
9
9
  asset: Address;
@@ -20,8 +20,8 @@ class VaultConfig {
20
20
  constructor({ address, decimals, decimalsOffset, symbol, name, asset, }, chainId) {
21
21
  this.chainId = chainId;
22
22
  this.address = address;
23
- this.decimals = decimals;
24
- this.decimalsOffset = decimalsOffset;
23
+ this.decimals = Number(decimals);
24
+ this.decimalsOffset = BigInt(decimalsOffset);
25
25
  this.symbol = symbol;
26
26
  this.name = name;
27
27
  this.asset = asset;
@@ -8,7 +8,7 @@ export declare class VaultMarketAllocation implements InputVaultMarketAllocation
8
8
  /**
9
9
  * The vault's configuration on the corresponding market.
10
10
  */
11
- config: VaultMarketConfig;
11
+ readonly config: VaultMarketConfig;
12
12
  /**
13
13
  * The vault's position on the corresponding market.
14
14
  */
@@ -8,17 +8,17 @@ export interface InputVaultMarketConfig {
8
8
  pendingCap: Pending<bigint>;
9
9
  removableAt: bigint;
10
10
  enabled: boolean;
11
- publicAllocatorConfig?: VaultMarketPublicAllocatorConfig;
11
+ publicAllocatorConfig: VaultMarketPublicAllocatorConfig;
12
12
  }
13
13
  export declare class VaultMarketConfig implements InputVaultMarketConfig {
14
14
  /**
15
15
  * The vault's address.
16
16
  */
17
- vault: Address;
17
+ readonly vault: Address;
18
18
  /**
19
19
  * The market's id.
20
20
  */
21
- marketId: MarketId;
21
+ readonly marketId: MarketId;
22
22
  /**
23
23
  * The maximum amount of tokens that can be allocated to this market.
24
24
  */
@@ -38,6 +38,6 @@ export declare class VaultMarketConfig implements InputVaultMarketConfig {
38
38
  /**
39
39
  * The vault's PublicAllocator configuration on the corresponding market.
40
40
  */
41
- publicAllocatorConfig?: VaultMarketPublicAllocatorConfig;
41
+ readonly publicAllocatorConfig: VaultMarketPublicAllocatorConfig;
42
42
  constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }: InputVaultMarketConfig);
43
43
  }
@@ -12,11 +12,11 @@ export declare class VaultMarketPublicAllocatorConfig implements InputVaultMarke
12
12
  /**
13
13
  * The vault's address.
14
14
  */
15
- vault: Address;
15
+ readonly vault: Address;
16
16
  /**
17
17
  * The market's id.
18
18
  */
19
- marketId: MarketId;
19
+ readonly marketId: MarketId;
20
20
  /**
21
21
  * The maximum amount of tokens that can be allocated to this market by the vault via the PublicAllocator.
22
22
  */
@@ -0,0 +1,26 @@
1
+ import { Address } from "../types";
2
+ export interface InputVaultUser {
3
+ vault: Address;
4
+ user: Address;
5
+ isAllocator: boolean;
6
+ allowance: bigint;
7
+ }
8
+ export declare class VaultUser implements InputVaultUser {
9
+ /**
10
+ * The vault's address.
11
+ */
12
+ readonly vault: Address;
13
+ /**
14
+ * The user's address.
15
+ */
16
+ readonly user: Address;
17
+ /**
18
+ * Whether the user is an allocator of the vault.
19
+ */
20
+ isAllocator: boolean;
21
+ /**
22
+ * The allowance of the vault over the user's underlying assets.
23
+ */
24
+ allowance: bigint;
25
+ constructor({ vault, user, isAllocator, allowance }: InputVaultUser);
26
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultUser = void 0;
4
+ class VaultUser {
5
+ /**
6
+ * The vault's address.
7
+ */
8
+ vault;
9
+ /**
10
+ * The user's address.
11
+ */
12
+ user;
13
+ /**
14
+ * Whether the user is an allocator of the vault.
15
+ */
16
+ isAllocator;
17
+ /**
18
+ * The allowance of the vault over the user's underlying assets.
19
+ */
20
+ allowance;
21
+ constructor({ vault, user, isAllocator, allowance }) {
22
+ this.vault = vault;
23
+ this.user = user;
24
+ this.isAllocator = isAllocator;
25
+ this.allowance = allowance;
26
+ }
27
+ }
28
+ exports.VaultUser = VaultUser;
@@ -3,4 +3,5 @@ export * from "./VaultConfig";
3
3
  export * from "./VaultMarketAllocation";
4
4
  export * from "./VaultMarketConfig";
5
5
  export * from "./VaultMarketPublicAllocatorConfig";
6
+ export * from "./VaultUser";
6
7
  export * from "./Vault";
@@ -19,4 +19,5 @@ __exportStar(require("./VaultConfig"), exports);
19
19
  __exportStar(require("./VaultMarketAllocation"), exports);
20
20
  __exportStar(require("./VaultMarketConfig"), exports);
21
21
  __exportStar(require("./VaultMarketPublicAllocatorConfig"), exports);
22
+ __exportStar(require("./VaultUser"), exports);
22
23
  __exportStar(require("./Vault"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morpho-org/blue-sdk",
3
- "version": "1.10.3",
3
+ "version": "1.10.5-alpha.0",
4
4
  "author": "Morpho Association <contact@morpho.org>",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -16,16 +16,16 @@
16
16
  "keccak256": "^1.0.6"
17
17
  },
18
18
  "devDependencies": {
19
- "@morpho-org/morpho-test": "^1.10.3",
20
- "@morpho-org/morpho-ts": "^1.10.3",
19
+ "@morpho-org/morpho-test": "^1.10.5-alpha.0",
20
+ "@morpho-org/morpho-ts": "^1.10.5-alpha.0",
21
21
  "@types/jest": "^29.5.12",
22
22
  "@types/node": "^22.1.0",
23
23
  "jest": "^29.7.0",
24
24
  "ts-jest": "^29.2.4",
25
- "typescript": "^5.4.5"
25
+ "typescript": "^5.6.2"
26
26
  },
27
27
  "peerDependencies": {
28
- "@morpho-org/morpho-ts": "^1.10.3"
28
+ "@morpho-org/morpho-ts": "^1.10.5-alpha.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"
@@ -49,5 +49,5 @@
49
49
  ],
50
50
  "preset": "ts-jest"
51
51
  },
52
- "gitHead": "15f31811fa5a2aec804a4940d059d57ba70410d6"
52
+ "gitHead": "8a297ab2c89859f2694b33c5b9bc0f384cbecfec"
53
53
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,255 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const format_1 = require("./format");
4
- describe("format", () => {
5
- const number = 12345.6789;
6
- const bigint = 123456789n;
7
- const decimals = 4;
8
- describe("hex", () => {
9
- describe("should properly format number in hex format", () => {
10
- it("without option", () => {
11
- expect(format_1.format.hex.of(number)).toEqual((123456789).toString(16));
12
- });
13
- });
14
- describe("should properly format bigint in hex format", () => {
15
- it("without option", () => {
16
- expect(format_1.format.hex.of(bigint, decimals)).toEqual((123456789).toString(16));
17
- });
18
- });
19
- });
20
- describe("number", () => {
21
- describe("should properly format number in number format", () => {
22
- it("without option", () => {
23
- expect(format_1.format.number.of(number)).toEqual("12345.6789");
24
- });
25
- it("with digits", () => {
26
- expect(format_1.format.number.digits(2).of(number)).toEqual("12345.67");
27
- });
28
- it("with min", () => {
29
- expect(format_1.format.number.min(20000).of(number)).toEqual("< 20000.0000");
30
- });
31
- it("with max", () => {
32
- expect(format_1.format.number.max(10000).of(number)).toEqual("> 10000.0000");
33
- });
34
- it("with sign", () => {
35
- expect(format_1.format.number.sign().of(number)).toEqual("+12345.6789");
36
- });
37
- it("with unit", () => {
38
- expect(format_1.format.number.unit("$").of(number)).toEqual("$12345.6789");
39
- });
40
- it("without trailing zeros", () => {
41
- expect(format_1.format.number.digits(6).of(number)).toEqual("12345.678900");
42
- expect(format_1.format.number.digits(6).removeTrailingZero().of(number)).toEqual("12345.6789");
43
- });
44
- it("with locale", () => {
45
- expect(format_1.format.number.locale("fr-FR").of(number)).toEqual("12345,6789");
46
- });
47
- });
48
- describe("should properly format bigint in number format", () => {
49
- it("without option", () => {
50
- expect(format_1.format.number.of(bigint, decimals)).toEqual("12345.6789");
51
- });
52
- it("with digits", () => {
53
- expect(format_1.format.number.digits(2).of(bigint, decimals)).toEqual("12345.67");
54
- });
55
- it("with min", () => {
56
- expect(format_1.format.number.min(20000).of(bigint, decimals)).toEqual("< 20000.0000");
57
- });
58
- it("with max", () => {
59
- expect(format_1.format.number.max(10000).of(bigint, decimals)).toEqual("> 10000.0000");
60
- });
61
- it("with sign", () => {
62
- expect(format_1.format.number.sign().of(bigint, decimals)).toEqual("+12345.6789");
63
- });
64
- it("with unit", () => {
65
- expect(format_1.format.number.unit("$").of(bigint, decimals)).toEqual("$12345.6789");
66
- });
67
- it("without trailing zeros", () => {
68
- expect(format_1.format.number.digits(6).of(bigint, decimals)).toEqual("12345.678900");
69
- expect(format_1.format.number.digits(6).removeTrailingZero().of(bigint, decimals)).toEqual("12345.6789");
70
- });
71
- it("with locale", () => {
72
- expect(format_1.format.number.locale("fr-FR").of(bigint, decimals)).toEqual("12345,6789");
73
- });
74
- });
75
- });
76
- describe("short", () => {
77
- describe("should properly format number in short format", () => {
78
- it("without option", () => {
79
- expect(format_1.format.short.of(number)).toEqual("12.3456789k");
80
- });
81
- it("with digits", () => {
82
- expect(format_1.format.short.digits(2).of(number)).toEqual("12.34k");
83
- });
84
- it("with min", () => {
85
- expect(format_1.format.short.min(20000).of(number)).toEqual("< 20.0000000k");
86
- });
87
- it("with max", () => {
88
- expect(format_1.format.short.max(10000).of(number)).toEqual("> 10.0000000k");
89
- });
90
- it("with sign", () => {
91
- expect(format_1.format.short.sign().of(number)).toEqual("+12.3456789k");
92
- });
93
- it("with unit", () => {
94
- expect(format_1.format.short.unit("€").of(number)).toEqual("12.3456789k €");
95
- });
96
- it("without trailing zeros", () => {
97
- expect(format_1.format.short.digits(8).of(number)).toEqual("12.34567890k");
98
- expect(format_1.format.short.digits(8).removeTrailingZero().of(number)).toEqual("12.3456789k");
99
- });
100
- it("with small numbers with commas", () => {
101
- expect(format_1.format.short.smallValuesWithCommas().of(number / 10)).toEqual("1,234.56789");
102
- });
103
- it("with locale", () => {
104
- expect(format_1.format.short.locale("fr-FR").of(number)).toEqual("12,3456789k");
105
- });
106
- });
107
- describe("should properly format bigint in short format", () => {
108
- it("without option", () => {
109
- expect(format_1.format.short.of(bigint, decimals)).toEqual("12.3456789k");
110
- });
111
- it("with digits", () => {
112
- expect(format_1.format.short.digits(2).of(bigint, decimals)).toEqual("12.34k");
113
- });
114
- it("with min", () => {
115
- expect(format_1.format.short.min(20000).of(bigint, decimals)).toEqual("< 20.0000000k");
116
- });
117
- it("with max", () => {
118
- expect(format_1.format.short.max(10000).of(bigint, decimals)).toEqual("> 10.0000000k");
119
- });
120
- it("with sign", () => {
121
- expect(format_1.format.short.sign().of(bigint, decimals)).toEqual("+12.3456789k");
122
- });
123
- it("with unit", () => {
124
- expect(format_1.format.short.unit("€").of(bigint, decimals)).toEqual("12.3456789k €");
125
- });
126
- it("without trailing zeros", () => {
127
- expect(format_1.format.short.digits(8).of(bigint, decimals)).toEqual("12.34567890k");
128
- expect(format_1.format.short.digits(8).removeTrailingZero().of(bigint, decimals)).toEqual("12.3456789k");
129
- });
130
- it("with locale", () => {
131
- expect(format_1.format.short.locale("fr-FR").of(bigint, decimals)).toEqual("12,3456789k");
132
- });
133
- it("with small numbers with commas", () => {
134
- expect(format_1.format.short.smallValuesWithCommas().of(bigint, decimals + 1)).toEqual("1,234.56789");
135
- });
136
- it("with small numbers with commas with locale", () => {
137
- expect(format_1.format.short
138
- .smallValuesWithCommas()
139
- .locale("fr-FR")
140
- .of(bigint, decimals + 1)).toEqual("1\u202F234,56789");
141
- });
142
- });
143
- });
144
- describe("commas", () => {
145
- describe("should properly format number in commas format", () => {
146
- it("without option", () => {
147
- expect(format_1.format.commas.of(number)).toEqual("12,345.6789");
148
- });
149
- it("with digits", () => {
150
- expect(format_1.format.commas.digits(2).of(number)).toEqual("12,345.67");
151
- });
152
- it("with min", () => {
153
- expect(format_1.format.commas.min(20000).of(number)).toEqual("< 20,000.0000");
154
- });
155
- it("with max", () => {
156
- expect(format_1.format.commas.max(10000).of(number)).toEqual("> 10,000.0000");
157
- });
158
- it("with sign", () => {
159
- expect(format_1.format.commas.sign().of(number)).toEqual("+12,345.6789");
160
- });
161
- it("with unit", () => {
162
- expect(format_1.format.commas.unit("ETH").of(number)).toEqual("12,345.6789 ETH");
163
- });
164
- it("without trailing zeros", () => {
165
- expect(format_1.format.commas.digits(6).of(number)).toEqual("12,345.678900");
166
- expect(format_1.format.commas.digits(6).removeTrailingZero().of(number)).toEqual("12,345.6789");
167
- });
168
- it("with locale", () => {
169
- expect(format_1.format.commas.locale("fr-FR").of(number)).toEqual("12\u202F345,6789");
170
- });
171
- });
172
- describe("should properly format bigint in commas format", () => {
173
- it("without option", () => {
174
- expect(format_1.format.commas.of(bigint, decimals)).toEqual("12,345.6789");
175
- });
176
- it("with digits", () => {
177
- expect(format_1.format.commas.digits(2).of(bigint, decimals)).toEqual("12,345.67");
178
- });
179
- it("with min", () => {
180
- expect(format_1.format.commas.min(20000).of(bigint, decimals)).toEqual("< 20,000.0000");
181
- });
182
- it("with max", () => {
183
- expect(format_1.format.commas.max(10000).of(bigint, decimals)).toEqual("> 10,000.0000");
184
- });
185
- it("with sign", () => {
186
- expect(format_1.format.commas.sign().of(bigint, decimals)).toEqual("+12,345.6789");
187
- });
188
- it("with unit", () => {
189
- expect(format_1.format.commas.unit("ETH").of(bigint, decimals)).toEqual("12,345.6789 ETH");
190
- });
191
- it("without trailing zeros", () => {
192
- expect(format_1.format.commas.digits(6).of(bigint, decimals)).toEqual("12,345.678900");
193
- expect(format_1.format.commas.digits(6).removeTrailingZero().of(bigint, decimals)).toEqual("12,345.6789");
194
- });
195
- it("with locale", () => {
196
- // the correct space in fr-FR is narrow no-break space (U+202F)
197
- expect(format_1.format.commas.locale("fr-FR").of(bigint, decimals)).toEqual("12\u202F345,6789");
198
- });
199
- });
200
- });
201
- describe("percent", () => {
202
- describe("should properly format number in percent format", () => {
203
- it("without option", () => {
204
- expect(format_1.format.percent.of(number)).toEqual("1234567.8900");
205
- });
206
- it("with digits", () => {
207
- expect(format_1.format.percent.digits(1).of(number)).toEqual("1234567.8");
208
- });
209
- it("with min", () => {
210
- expect(format_1.format.percent.min(20000).of(number)).toEqual("< 2000000.0000");
211
- });
212
- it("with max", () => {
213
- expect(format_1.format.percent.max(10000).of(number)).toEqual("> 1000000.0000");
214
- });
215
- it("with sign", () => {
216
- expect(format_1.format.percent.sign().of(number)).toEqual("+1234567.8900");
217
- });
218
- it("with unit", () => {
219
- expect(format_1.format.percent.unit("%").of(number)).toEqual("1234567.8900%");
220
- });
221
- it("without trailing zeros", () => {
222
- expect(format_1.format.percent.removeTrailingZero().of(number)).toEqual("1234567.89");
223
- });
224
- it("with locale", () => {
225
- expect(format_1.format.percent.locale("fr-FR").of(number)).toEqual("1234567,8900");
226
- });
227
- });
228
- describe("should properly format bigint in percent format", () => {
229
- it("without option", () => {
230
- expect(format_1.format.percent.of(bigint, decimals)).toEqual("1234567.8900");
231
- });
232
- it("with digits", () => {
233
- expect(format_1.format.percent.digits(1).of(bigint, decimals)).toEqual("1234567.8");
234
- });
235
- it("with min", () => {
236
- expect(format_1.format.percent.min(20000).of(bigint, decimals)).toEqual("< 2000000.0000");
237
- });
238
- it("with max", () => {
239
- expect(format_1.format.percent.max(10000).of(bigint, decimals)).toEqual("> 1000000.0000");
240
- });
241
- it("with sign", () => {
242
- expect(format_1.format.percent.sign().of(bigint, decimals)).toEqual("+1234567.8900");
243
- });
244
- it("with unit", () => {
245
- expect(format_1.format.percent.unit("%").of(bigint, decimals)).toEqual("1234567.8900%");
246
- });
247
- it("without trailing zeros", () => {
248
- expect(format_1.format.percent.removeTrailingZero().of(bigint, decimals)).toEqual("1234567.89");
249
- });
250
- it("with locale", () => {
251
- expect(format_1.format.percent.locale("fr-FR").of(bigint, decimals)).toEqual("1234567,8900");
252
- });
253
- });
254
- });
255
- });
@@ -1 +0,0 @@
1
- export * from "./format";
@@ -1,17 +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("./format"), exports);
@@ -1,2 +0,0 @@
1
- export * from "./locale";
2
- export * from "./format";
@@ -1,18 +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("./locale"), exports);
18
- __exportStar(require("./format"), exports);