@morpho-org/blue-sdk 2.0.0-next.9 → 2.0.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 (56) hide show
  1. package/lib/addresses.d.ts +1 -1
  2. package/lib/addresses.js +63 -58
  3. package/lib/chain.js +9 -6
  4. package/lib/constants.js +12 -9
  5. package/lib/errors.d.ts +5 -0
  6. package/lib/errors.js +37 -13
  7. package/lib/holding/AssetBalances.d.ts +2 -2
  8. package/lib/holding/AssetBalances.js +5 -1
  9. package/lib/holding/Holding.d.ts +5 -5
  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 +37 -25
  14. package/lib/market/Market.js +72 -51
  15. package/lib/market/MarketParams.d.ts +4 -3
  16. package/lib/market/MarketParams.js +16 -14
  17. package/lib/market/MarketUtils.d.ts +81 -30
  18. package/lib/market/MarketUtils.js +135 -51
  19. package/lib/market/index.js +19 -3
  20. package/lib/math/AdaptiveCurveIrmLib.js +25 -22
  21. package/lib/math/MathLib.d.ts +1 -16
  22. package/lib/math/MathLib.js +6 -29
  23. package/lib/math/SharesMath.js +8 -5
  24. package/lib/math/index.js +19 -3
  25. package/lib/position/Position.d.ts +28 -19
  26. package/lib/position/Position.js +49 -43
  27. package/lib/position/index.js +17 -1
  28. package/lib/token/ConstantWrappedToken.d.ts +2 -2
  29. package/lib/token/ConstantWrappedToken.js +10 -6
  30. package/lib/token/ExchangeRateWrappedToken.d.ts +2 -2
  31. package/lib/token/ExchangeRateWrappedToken.js +9 -5
  32. package/lib/token/Token.d.ts +15 -15
  33. package/lib/token/Token.js +27 -25
  34. package/lib/token/VaultToken.d.ts +4 -4
  35. package/lib/token/VaultToken.js +9 -5
  36. package/lib/token/WrappedToken.d.ts +2 -2
  37. package/lib/token/WrappedToken.js +11 -7
  38. package/lib/token/index.js +21 -5
  39. package/lib/types.js +9 -4
  40. package/lib/user/User.js +5 -1
  41. package/lib/user/index.js +17 -1
  42. package/lib/vault/Vault.d.ts +20 -12
  43. package/lib/vault/Vault.js +26 -21
  44. package/lib/vault/VaultConfig.d.ts +3 -4
  45. package/lib/vault/VaultConfig.js +9 -5
  46. package/lib/vault/VaultMarketAllocation.d.ts +3 -3
  47. package/lib/vault/VaultMarketAllocation.js +8 -4
  48. package/lib/vault/VaultMarketConfig.d.ts +3 -3
  49. package/lib/vault/VaultMarketConfig.js +5 -1
  50. package/lib/vault/VaultMarketPublicAllocatorConfig.d.ts +3 -3
  51. package/lib/vault/VaultMarketPublicAllocatorConfig.js +5 -1
  52. package/lib/vault/VaultUser.d.ts +3 -3
  53. package/lib/vault/VaultUser.js +5 -1
  54. package/lib/vault/VaultUtils.js +9 -6
  55. package/lib/vault/index.js +23 -7
  56. package/package.json +9 -19
@@ -1,10 +1,10 @@
1
1
  import type { AccrualPosition } from "../position/index.js";
2
2
  import type { VaultMarketConfig } from "./VaultMarketConfig.js";
3
- export interface InputVaultMarketAllocation {
3
+ export interface IVaultMarketAllocation {
4
4
  config: VaultMarketConfig;
5
5
  position: AccrualPosition;
6
6
  }
7
- export declare class VaultMarketAllocation implements InputVaultMarketAllocation {
7
+ export declare class VaultMarketAllocation implements IVaultMarketAllocation {
8
8
  /**
9
9
  * The vault's configuration on the corresponding market.
10
10
  */
@@ -13,7 +13,7 @@ export declare class VaultMarketAllocation implements InputVaultMarketAllocation
13
13
  * The vault's position on the corresponding market.
14
14
  */
15
15
  readonly position: AccrualPosition;
16
- constructor({ config, position }: InputVaultMarketAllocation);
16
+ constructor({ config, position }: IVaultMarketAllocation);
17
17
  get vault(): `0x${string}`;
18
18
  get marketId(): import("../types.js").MarketId;
19
19
  get utilization(): bigint;
@@ -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,7 +1,7 @@
1
1
  import type { Address, MarketId } from "../types.js";
2
2
  import type { Pending } from "./Vault.js";
3
3
  import type { VaultMarketPublicAllocatorConfig } from "./VaultMarketPublicAllocatorConfig.js";
4
- export interface InputVaultMarketConfig {
4
+ export interface IVaultMarketConfig {
5
5
  vault: Address;
6
6
  marketId: MarketId;
7
7
  cap: bigint;
@@ -10,7 +10,7 @@ export interface InputVaultMarketConfig {
10
10
  enabled: boolean;
11
11
  publicAllocatorConfig: VaultMarketPublicAllocatorConfig;
12
12
  }
13
- export declare class VaultMarketConfig implements InputVaultMarketConfig {
13
+ export declare class VaultMarketConfig implements IVaultMarketConfig {
14
14
  /**
15
15
  * The vault's address.
16
16
  */
@@ -39,5 +39,5 @@ export declare class VaultMarketConfig implements InputVaultMarketConfig {
39
39
  * The vault's PublicAllocator configuration on the corresponding market.
40
40
  */
41
41
  readonly publicAllocatorConfig: VaultMarketPublicAllocatorConfig;
42
- constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }: InputVaultMarketConfig);
42
+ constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }: IVaultMarketConfig);
43
43
  }
@@ -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;
@@ -2,13 +2,13 @@ import type { Address, MarketId } from "../types.js";
2
2
  /**
3
3
  * The vault's configuration of a market on the PublicAllocator.
4
4
  */
5
- export interface InputVaultMarketPublicAllocatorConfig {
5
+ export interface IVaultMarketPublicAllocatorConfig {
6
6
  vault: Address;
7
7
  marketId: MarketId;
8
8
  maxIn: bigint;
9
9
  maxOut: bigint;
10
10
  }
11
- export declare class VaultMarketPublicAllocatorConfig implements InputVaultMarketPublicAllocatorConfig {
11
+ export declare class VaultMarketPublicAllocatorConfig implements IVaultMarketPublicAllocatorConfig {
12
12
  /**
13
13
  * The vault's address.
14
14
  */
@@ -25,5 +25,5 @@ export declare class VaultMarketPublicAllocatorConfig implements InputVaultMarke
25
25
  * The maximum amount of tokens that can be allocated out of this market by the vault via the PublicAllocator.
26
26
  */
27
27
  maxOut: bigint;
28
- constructor({ vault, marketId, maxIn, maxOut, }: InputVaultMarketPublicAllocatorConfig);
28
+ constructor({ vault, marketId, maxIn, maxOut, }: IVaultMarketPublicAllocatorConfig);
29
29
  }
@@ -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,11 +1,11 @@
1
1
  import type { Address } from "../types.js";
2
- export interface InputVaultUser {
2
+ export interface IVaultUser {
3
3
  vault: Address;
4
4
  user: Address;
5
5
  isAllocator: boolean;
6
6
  allowance: bigint;
7
7
  }
8
- export declare class VaultUser implements InputVaultUser {
8
+ export declare class VaultUser implements IVaultUser {
9
9
  /**
10
10
  * The vault's address.
11
11
  */
@@ -22,5 +22,5 @@ export declare class VaultUser implements InputVaultUser {
22
22
  * The allowance of the vault over the user's underlying assets.
23
23
  */
24
24
  allowance: bigint;
25
- constructor({ vault, user, isAllocator, allowance }: InputVaultUser);
25
+ constructor({ vault, user, isAllocator, allowance }: IVaultUser);
26
26
  }
@@ -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,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/blue-sdk",
3
3
  "description": "Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).",
4
- "version": "2.0.0-next.9",
4
+ "version": "2.0.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -13,37 +13,27 @@
13
13
  "email": "contact@morpho.org"
14
14
  },
15
15
  "license": "MIT",
16
- "type": "module",
17
16
  "main": "lib/index.js",
18
17
  "files": [
19
18
  "lib"
20
19
  ],
21
20
  "dependencies": {
22
- "keccak256": "^1.0.6"
21
+ "@noble/hashes": "^1.5.0"
23
22
  },
24
23
  "peerDependencies": {
25
- "@morpho-org/morpho-ts": "^2.0.0-next.7"
24
+ "@morpho-org/morpho-ts": "^2.0.0"
26
25
  },
27
26
  "devDependencies": {
28
- "@types/node": "^22.1.0",
29
- "typescript": "^5.6.3",
30
- "viem": "^2.21.29",
31
- "viem-deal": "^2.0.1",
32
- "vitest": "^2.1.3",
33
- "@morpho-org/morpho-ts": "^2.0.0-next.7",
34
- "@morpho-org/test": "^2.0.0-next.10",
35
- "@morpho-org/test-viem": "^2.0.0-next.14"
27
+ "typescript": "^5.7.2",
28
+ "viem": "^2.21.54",
29
+ "vitest": "^2.1.8",
30
+ "@morpho-org/morpho-ts": "^2.0.0",
31
+ "@morpho-org/test": "^2.0.0"
36
32
  },
37
33
  "scripts": {
38
34
  "prepublish": "$npm_execpath build",
39
35
  "build": "tsc --build tsconfig.build.json",
40
36
  "test": "vitest"
41
37
  },
42
- "types": "lib/index.d.ts",
43
- "exports": {
44
- ".": {
45
- "types": "./lib/index.d.ts",
46
- "default": "./lib/index.js"
47
- }
48
- }
38
+ "types": "lib/index.d.ts"
49
39
  }