@morpho-org/blue-sdk 6.0.1 → 6.1.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 (139) hide show
  1. package/lib/cjs/addresses.d.ts +105 -0
  2. package/lib/cjs/addresses.js +74 -0
  3. package/lib/cjs/chain.d.ts +84 -1
  4. package/lib/cjs/chain.js +78 -0
  5. package/lib/cjs/errors.d.ts +34 -0
  6. package/lib/cjs/errors.js +28 -0
  7. package/lib/cjs/holding/AssetBalances.d.ts +3 -0
  8. package/lib/cjs/holding/AssetBalances.js +1 -0
  9. package/lib/cjs/holding/Holding.d.ts +6 -0
  10. package/lib/cjs/holding/Holding.js +2 -0
  11. package/lib/cjs/market/Market.d.ts +4 -0
  12. package/lib/cjs/market/MarketParams.d.ts +3 -0
  13. package/lib/cjs/market/MarketParams.js +1 -0
  14. package/lib/cjs/market/MarketUtils.d.ts +397 -0
  15. package/lib/cjs/market/MarketUtils.js +397 -2
  16. package/lib/cjs/math/AdaptiveCurveIrmLib.d.ts +51 -1
  17. package/lib/cjs/math/AdaptiveCurveIrmLib.js +51 -1
  18. package/lib/cjs/math/MathLib.d.ts +152 -4
  19. package/lib/cjs/math/MathLib.js +151 -4
  20. package/lib/cjs/math/SharesMath.d.ts +34 -0
  21. package/lib/cjs/math/SharesMath.js +34 -0
  22. package/lib/cjs/position/Position.d.ts +4 -0
  23. package/lib/cjs/position/Position.js +2 -0
  24. package/lib/cjs/position/PreLiquidationPosition.d.ts +4 -0
  25. package/lib/cjs/position/PreLiquidationPosition.js +2 -0
  26. package/lib/cjs/preLiquidation.d.ts +16 -0
  27. package/lib/cjs/preLiquidation.js +16 -0
  28. package/lib/cjs/token/ConstantWrappedToken.d.ts +1 -0
  29. package/lib/cjs/token/ConstantWrappedToken.js +1 -0
  30. package/lib/cjs/token/Eip5267Domain.d.ts +4 -0
  31. package/lib/cjs/token/Eip5267Domain.js +2 -0
  32. package/lib/cjs/token/ExchangeRateWrappedToken.d.ts +1 -0
  33. package/lib/cjs/token/ExchangeRateWrappedToken.js +1 -0
  34. package/lib/cjs/token/Token.d.ts +2 -0
  35. package/lib/cjs/token/Token.js +1 -0
  36. package/lib/cjs/token/VaultToken.d.ts +2 -0
  37. package/lib/cjs/token/VaultToken.js +1 -0
  38. package/lib/cjs/token/WrappedToken.d.ts +1 -0
  39. package/lib/cjs/token/WrappedToken.js +1 -0
  40. package/lib/cjs/types.d.ts +17 -0
  41. package/lib/cjs/types.js +13 -0
  42. package/lib/cjs/user/User.d.ts +1 -0
  43. package/lib/cjs/user/User.js +1 -0
  44. package/lib/cjs/utils.d.ts +2 -0
  45. package/lib/cjs/utils.js +1 -0
  46. package/lib/cjs/vault/Vault.d.ts +7 -0
  47. package/lib/cjs/vault/Vault.js +2 -0
  48. package/lib/cjs/vault/VaultConfig.d.ts +2 -0
  49. package/lib/cjs/vault/VaultConfig.js +1 -0
  50. package/lib/cjs/vault/VaultMarketAllocation.d.ts +2 -0
  51. package/lib/cjs/vault/VaultMarketAllocation.js +1 -0
  52. package/lib/cjs/vault/VaultMarketConfig.d.ts +2 -0
  53. package/lib/cjs/vault/VaultMarketConfig.js +1 -0
  54. package/lib/cjs/vault/VaultMarketPublicAllocatorConfig.d.ts +1 -0
  55. package/lib/cjs/vault/VaultMarketPublicAllocatorConfig.js +1 -0
  56. package/lib/cjs/vault/VaultUser.d.ts +2 -0
  57. package/lib/cjs/vault/VaultUser.js +1 -0
  58. package/lib/cjs/vault/VaultUtils.d.ts +49 -0
  59. package/lib/cjs/vault/VaultUtils.js +49 -0
  60. package/lib/cjs/vault/v2/VaultV2.d.ts +5 -0
  61. package/lib/cjs/vault/v2/VaultV2.js +2 -0
  62. package/lib/cjs/vault/v2/VaultV2Adapter.d.ts +3 -0
  63. package/lib/cjs/vault/v2/VaultV2Adapter.js +1 -0
  64. package/lib/cjs/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +4 -0
  65. package/lib/cjs/vault/v2/VaultV2MorphoMarketV1Adapter.js +2 -0
  66. package/lib/cjs/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +4 -0
  67. package/lib/cjs/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +2 -0
  68. package/lib/cjs/vault/v2/VaultV2MorphoVaultV1Adapter.d.ts +4 -0
  69. package/lib/cjs/vault/v2/VaultV2MorphoVaultV1Adapter.js +2 -0
  70. package/lib/esm/addresses.d.ts +105 -0
  71. package/lib/esm/addresses.js +74 -0
  72. package/lib/esm/chain.d.ts +84 -1
  73. package/lib/esm/chain.js +78 -0
  74. package/lib/esm/errors.d.ts +34 -0
  75. package/lib/esm/errors.js +28 -0
  76. package/lib/esm/holding/AssetBalances.d.ts +3 -0
  77. package/lib/esm/holding/AssetBalances.js +1 -0
  78. package/lib/esm/holding/Holding.d.ts +6 -0
  79. package/lib/esm/holding/Holding.js +2 -0
  80. package/lib/esm/market/Market.d.ts +4 -0
  81. package/lib/esm/market/MarketParams.d.ts +3 -0
  82. package/lib/esm/market/MarketParams.js +1 -0
  83. package/lib/esm/market/MarketUtils.d.ts +397 -0
  84. package/lib/esm/market/MarketUtils.js +397 -2
  85. package/lib/esm/math/AdaptiveCurveIrmLib.d.ts +51 -1
  86. package/lib/esm/math/AdaptiveCurveIrmLib.js +51 -1
  87. package/lib/esm/math/MathLib.d.ts +152 -4
  88. package/lib/esm/math/MathLib.js +151 -4
  89. package/lib/esm/math/SharesMath.d.ts +34 -0
  90. package/lib/esm/math/SharesMath.js +34 -0
  91. package/lib/esm/position/Position.d.ts +4 -0
  92. package/lib/esm/position/Position.js +2 -0
  93. package/lib/esm/position/PreLiquidationPosition.d.ts +4 -0
  94. package/lib/esm/position/PreLiquidationPosition.js +2 -0
  95. package/lib/esm/preLiquidation.d.ts +16 -0
  96. package/lib/esm/preLiquidation.js +16 -0
  97. package/lib/esm/token/ConstantWrappedToken.d.ts +1 -0
  98. package/lib/esm/token/ConstantWrappedToken.js +1 -0
  99. package/lib/esm/token/Eip5267Domain.d.ts +4 -0
  100. package/lib/esm/token/Eip5267Domain.js +2 -0
  101. package/lib/esm/token/ExchangeRateWrappedToken.d.ts +1 -0
  102. package/lib/esm/token/ExchangeRateWrappedToken.js +1 -0
  103. package/lib/esm/token/Token.d.ts +2 -0
  104. package/lib/esm/token/Token.js +1 -0
  105. package/lib/esm/token/VaultToken.d.ts +2 -0
  106. package/lib/esm/token/VaultToken.js +1 -0
  107. package/lib/esm/token/WrappedToken.d.ts +1 -0
  108. package/lib/esm/token/WrappedToken.js +1 -0
  109. package/lib/esm/types.d.ts +17 -0
  110. package/lib/esm/types.js +13 -0
  111. package/lib/esm/user/User.d.ts +1 -0
  112. package/lib/esm/user/User.js +1 -0
  113. package/lib/esm/utils.d.ts +2 -0
  114. package/lib/esm/utils.js +1 -0
  115. package/lib/esm/vault/Vault.d.ts +7 -0
  116. package/lib/esm/vault/Vault.js +2 -0
  117. package/lib/esm/vault/VaultConfig.d.ts +2 -0
  118. package/lib/esm/vault/VaultConfig.js +1 -0
  119. package/lib/esm/vault/VaultMarketAllocation.d.ts +2 -0
  120. package/lib/esm/vault/VaultMarketAllocation.js +1 -0
  121. package/lib/esm/vault/VaultMarketConfig.d.ts +2 -0
  122. package/lib/esm/vault/VaultMarketConfig.js +1 -0
  123. package/lib/esm/vault/VaultMarketPublicAllocatorConfig.d.ts +1 -0
  124. package/lib/esm/vault/VaultMarketPublicAllocatorConfig.js +1 -0
  125. package/lib/esm/vault/VaultUser.d.ts +2 -0
  126. package/lib/esm/vault/VaultUser.js +1 -0
  127. package/lib/esm/vault/VaultUtils.d.ts +49 -0
  128. package/lib/esm/vault/VaultUtils.js +49 -0
  129. package/lib/esm/vault/v2/VaultV2.d.ts +5 -0
  130. package/lib/esm/vault/v2/VaultV2.js +2 -0
  131. package/lib/esm/vault/v2/VaultV2Adapter.d.ts +3 -0
  132. package/lib/esm/vault/v2/VaultV2Adapter.js +1 -0
  133. package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +4 -0
  134. package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.js +2 -0
  135. package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +4 -0
  136. package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +2 -0
  137. package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.d.ts +4 -0
  138. package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.js +2 -0
  139. package/package.json +2 -2
@@ -2,13 +2,45 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultUtils = void 0;
4
4
  const index_js_1 = require("../math/index.js");
5
+ /** ERC-4626 virtual share and asset conversion helpers for MetaMorpho vaults. */
5
6
  var VaultUtils;
6
7
  (function (VaultUtils) {
8
+ /** Virtual assets added to ERC-4626 total assets in conversion formulas. */
7
9
  VaultUtils.VIRTUAL_ASSETS = 1n;
10
+ /**
11
+ * Returns the decimals offset between 18-decimal vault shares and an asset.
12
+ *
13
+ * @param decimals - The asset decimals.
14
+ * @returns The non-negative decimals offset.
15
+ * @example
16
+ * ```ts
17
+ * import { VaultUtils } from "@morpho-org/blue-sdk";
18
+ *
19
+ * const offset = VaultUtils.decimalsOffset(6n);
20
+ * // offset === 12n
21
+ * ```
22
+ */
8
23
  function decimalsOffset(decimals) {
9
24
  return index_js_1.MathLib.zeroFloorSub(18n, decimals);
10
25
  }
11
26
  VaultUtils.decimalsOffset = decimalsOffset;
27
+ /**
28
+ * Converts vault shares to underlying assets.
29
+ *
30
+ * @param shares - The amount of vault shares.
31
+ * @param vault.totalAssets - The vault's total assets.
32
+ * @param vault.totalSupply - The vault's total share supply.
33
+ * @param vault.decimalsOffset - The vault's decimals offset.
34
+ * @param rounding - Optional rounding direction. Defaults to `"Down"`.
35
+ * @returns The equivalent amount of underlying assets.
36
+ * @example
37
+ * ```ts
38
+ * import { VaultUtils } from "@morpho-org/blue-sdk";
39
+ *
40
+ * const assets = VaultUtils.toAssets(100n, { totalAssets: 1_000n, totalSupply: 100n, decimalsOffset: 0n });
41
+ * // assets satisfies bigint
42
+ * ```
43
+ */
12
44
  // biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
13
45
  function toAssets(shares, { totalAssets, totalSupply,
14
46
  // biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
@@ -16,6 +48,23 @@ var VaultUtils;
16
48
  return index_js_1.MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
17
49
  }
18
50
  VaultUtils.toAssets = toAssets;
51
+ /**
52
+ * Converts underlying assets to vault shares.
53
+ *
54
+ * @param assets - The amount of underlying assets.
55
+ * @param vault.totalAssets - The vault's total assets.
56
+ * @param vault.totalSupply - The vault's total share supply.
57
+ * @param vault.decimalsOffset - The vault's decimals offset.
58
+ * @param rounding - Optional rounding direction. Defaults to `"Up"`.
59
+ * @returns The equivalent amount of vault shares.
60
+ * @example
61
+ * ```ts
62
+ * import { VaultUtils } from "@morpho-org/blue-sdk";
63
+ *
64
+ * const shares = VaultUtils.toShares(100n, { totalAssets: 1_000n, totalSupply: 100n, decimalsOffset: 0n });
65
+ * // shares satisfies bigint
66
+ * ```
67
+ */
19
68
  // biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
20
69
  function toShares(assets, { totalAssets, totalSupply,
21
70
  // biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
@@ -4,12 +4,14 @@ import { type IToken, WrappedToken } from "../../token/index.js";
4
4
  import type { BigIntish } from "../../types.js";
5
5
  import { type CapacityLimit } from "../../utils.js";
6
6
  import type { IAccrualVaultV2Adapter } from "./VaultV2Adapter.js";
7
+ /** Plain input shape for one Vault V2 liquidity allocation. */
7
8
  export interface IVaultV2Allocation {
8
9
  id: Hash;
9
10
  absoluteCap: bigint;
10
11
  relativeCap: bigint;
11
12
  allocation: bigint;
12
13
  }
14
+ /** Plain input shape for a Morpho Vault V2. */
13
15
  export interface IVaultV2 extends IToken {
14
16
  asset: Address;
15
17
  /**
@@ -32,6 +34,7 @@ export interface IVaultV2 extends IToken {
32
34
  performanceFeeRecipient: Address;
33
35
  managementFeeRecipient: Address;
34
36
  }
37
+ /** Represents a Morpho Vault V2 and its fee, adapter, and accounting state. */
35
38
  export declare class VaultV2 extends WrappedToken implements IVaultV2 {
36
39
  readonly asset: Address;
37
40
  _totalAssets: bigint;
@@ -53,8 +56,10 @@ export declare class VaultV2 extends WrappedToken implements IVaultV2 {
53
56
  protected _wrap(amount: BigIntish, rounding: RoundingDirection): bigint;
54
57
  protected _unwrap(amount: BigIntish, rounding: RoundingDirection): bigint;
55
58
  }
59
+ /** Plain input shape for a Morpho Vault V2 paired with accrued adapter state. */
56
60
  export interface IAccrualVaultV2 extends Omit<IVaultV2, "adapters"> {
57
61
  }
62
+ /** Represents a Morpho Vault V2 with accrued adapter and liquidity state. */
58
63
  export declare class AccrualVaultV2 extends VaultV2 implements IAccrualVaultV2 {
59
64
  accrualLiquidityAdapter: IAccrualVaultV2Adapter | undefined;
60
65
  accrualAdapters: IAccrualVaultV2Adapter[];
@@ -6,6 +6,7 @@ const errors_js_1 = require("../../errors.js");
6
6
  const index_js_1 = require("../../math/index.js");
7
7
  const index_js_2 = require("../../token/index.js");
8
8
  const utils_js_1 = require("../../utils.js");
9
+ /** Represents a Morpho Vault V2 and its fee, adapter, and accounting state. */
9
10
  class VaultV2 extends index_js_2.WrappedToken {
10
11
  asset;
11
12
  _totalAssets;
@@ -53,6 +54,7 @@ class VaultV2 extends index_js_2.WrappedToken {
53
54
  }
54
55
  }
55
56
  exports.VaultV2 = VaultV2;
57
+ /** Represents a Morpho Vault V2 with accrued adapter and liquidity state. */
56
58
  class AccrualVaultV2 extends VaultV2 {
57
59
  accrualLiquidityAdapter;
58
60
  accrualAdapters;
@@ -1,6 +1,7 @@
1
1
  import type { Address, Hash, Hex } from "viem";
2
2
  import type { BigIntish } from "../../types.js";
3
3
  import type { CapacityLimit } from "../../utils.js";
4
+ /** Plain input shape for a Morpho Vault V2 adapter. */
4
5
  export interface IVaultV2Adapter {
5
6
  type: string;
6
7
  address: Address;
@@ -8,6 +9,7 @@ export interface IVaultV2Adapter {
8
9
  adapterId: Hash;
9
10
  skimRecipient: Address;
10
11
  }
12
+ /** Base class for Morpho Vault V2 adapters. */
11
13
  export declare abstract class VaultV2Adapter implements IVaultV2Adapter {
12
14
  readonly type: string;
13
15
  readonly address: Address;
@@ -16,6 +18,7 @@ export declare abstract class VaultV2Adapter implements IVaultV2Adapter {
16
18
  skimRecipient: Address;
17
19
  constructor({ type, address, parentVault, adapterId, skimRecipient, }: IVaultV2Adapter);
18
20
  }
21
+ /** Adapter interface with accrued asset and capacity methods. */
19
22
  export interface IAccrualVaultV2Adapter extends IVaultV2Adapter {
20
23
  realAssets(timestamp: BigIntish): bigint;
21
24
  /**
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultV2Adapter = void 0;
4
+ /** Base class for Morpho Vault V2 adapters. */
4
5
  class VaultV2Adapter {
5
6
  type;
6
7
  address;
@@ -5,10 +5,12 @@ import type { BigIntish } from "../../types.js";
5
5
  import { CapacityLimitReason } from "../../utils.js";
6
6
  import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
7
7
  import { VaultV2Adapter } from "./VaultV2Adapter.js";
8
+ /** Plain input shape for a Vault V2 adapter investing in Morpho Blue markets. */
8
9
  export interface IVaultV2MorphoMarketV1Adapter extends Omit<IVaultV2Adapter, "adapterId" | "type"> {
9
10
  type?: "VaultV2MorphoMarketV1Adapter";
10
11
  marketParamsList: IMarketParams[];
11
12
  }
13
+ /** Represents a Vault V2 adapter investing in Morpho Blue markets. */
12
14
  export declare class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter implements IVaultV2MorphoMarketV1Adapter {
13
15
  readonly type: "VaultV2MorphoMarketV1Adapter";
14
16
  static adapterId(address: Address): `0x${string}`;
@@ -18,8 +20,10 @@ export declare class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter impleme
18
20
  constructor({ marketParamsList, ...vaultV2Adapter }: IVaultV2MorphoMarketV1Adapter);
19
21
  ids(params: MarketParams): `0x${string}`[];
20
22
  }
23
+ /** Plain input shape for an accrued Morpho Blue market Vault V2 adapter. */
21
24
  export interface IAccrualVaultV2MorphoMarketV1Adapter extends IVaultV2MorphoMarketV1Adapter {
22
25
  }
26
+ /** Represents an accrued Morpho Blue market Vault V2 adapter. */
23
27
  export declare class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMarketV1Adapter implements IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2Adapter {
24
28
  positions: AccrualPosition[];
25
29
  constructor(adapter: IAccrualVaultV2MorphoMarketV1Adapter, positions: AccrualPosition[]);
@@ -5,6 +5,7 @@ const viem_1 = require("viem");
5
5
  const index_js_1 = require("../../market/index.js");
6
6
  const utils_js_1 = require("../../utils.js");
7
7
  const VaultV2Adapter_js_1 = require("./VaultV2Adapter.js");
8
+ /** Represents a Vault V2 adapter investing in Morpho Blue markets. */
8
9
  class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter_js_1.VaultV2Adapter {
9
10
  static adapterId(address) {
10
11
  return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["this", address]));
@@ -33,6 +34,7 @@ class VaultV2MorphoMarketV1Adapter extends VaultV2Adapter_js_1.VaultV2Adapter {
33
34
  }
34
35
  }
35
36
  exports.VaultV2MorphoMarketV1Adapter = VaultV2MorphoMarketV1Adapter;
37
+ /** Represents an accrued Morpho Blue market Vault V2 adapter. */
36
38
  class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMarketV1Adapter {
37
39
  positions;
38
40
  constructor(adapter, positions) {
@@ -4,12 +4,14 @@ import type { BigIntish, MarketId } from "../../types.js";
4
4
  import { CapacityLimitReason } from "../../utils.js";
5
5
  import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
6
6
  import { VaultV2Adapter } from "./VaultV2Adapter.js";
7
+ /** Plain input shape for a Vault V2 Morpho Blue market adapter using market ids. */
7
8
  export interface IVaultV2MorphoMarketV1AdapterV2 extends Omit<IVaultV2Adapter, "adapterId" | "type"> {
8
9
  type?: "VaultV2MorphoMarketV1AdapterV2";
9
10
  marketIds: MarketId[];
10
11
  adaptiveCurveIrm: Address;
11
12
  supplyShares: Record<MarketId, bigint>;
12
13
  }
14
+ /** Represents a Vault V2 Morpho Blue market adapter using market ids. */
13
15
  export declare class VaultV2MorphoMarketV1AdapterV2 extends VaultV2Adapter implements IVaultV2MorphoMarketV1AdapterV2 {
14
16
  readonly type: "VaultV2MorphoMarketV1AdapterV2";
15
17
  static adapterId(address: Address): `0x${string}`;
@@ -21,8 +23,10 @@ export declare class VaultV2MorphoMarketV1AdapterV2 extends VaultV2Adapter imple
21
23
  constructor({ marketIds, adaptiveCurveIrm, supplyShares, ...vaultV2Adapter }: IVaultV2MorphoMarketV1AdapterV2);
22
24
  ids(params: MarketParams): `0x${string}`[];
23
25
  }
26
+ /** Plain input shape for an accrued Vault V2 Morpho Blue market-id adapter. */
24
27
  export interface IAccrualVaultV2MorphoMarketV1AdapterV2 extends IVaultV2MorphoMarketV1AdapterV2 {
25
28
  }
29
+ /** Represents an accrued Vault V2 Morpho Blue market-id adapter. */
26
30
  export declare class AccrualVaultV2MorphoMarketV1AdapterV2 extends VaultV2MorphoMarketV1AdapterV2 implements IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2Adapter {
27
31
  markets: Market[];
28
32
  constructor(adapter: IAccrualVaultV2MorphoMarketV1AdapterV2, markets: Market[]);
@@ -5,6 +5,7 @@ const viem_1 = require("viem");
5
5
  const index_js_1 = require("../../market/index.js");
6
6
  const utils_js_1 = require("../../utils.js");
7
7
  const VaultV2Adapter_js_1 = require("./VaultV2Adapter.js");
8
+ /** Represents a Vault V2 Morpho Blue market adapter using market ids. */
8
9
  class VaultV2MorphoMarketV1AdapterV2 extends VaultV2Adapter_js_1.VaultV2Adapter {
9
10
  static adapterId(address) {
10
11
  return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["this", address]));
@@ -37,6 +38,7 @@ class VaultV2MorphoMarketV1AdapterV2 extends VaultV2Adapter_js_1.VaultV2Adapter
37
38
  }
38
39
  }
39
40
  exports.VaultV2MorphoMarketV1AdapterV2 = VaultV2MorphoMarketV1AdapterV2;
41
+ /** Represents an accrued Vault V2 Morpho Blue market-id adapter. */
40
42
  class AccrualVaultV2MorphoMarketV1AdapterV2 extends VaultV2MorphoMarketV1AdapterV2 {
41
43
  markets;
42
44
  constructor(adapter, markets) {
@@ -1,5 +1,6 @@
1
1
  import { type Address, type Hex } from "viem";
2
2
  import { VaultV2Adapter } from "./VaultV2Adapter.js";
3
+ /** Plain input shape for a Vault V2 adapter investing in a MetaMorpho V1 vault. */
3
4
  export interface IVaultV2MorphoVaultV1Adapter extends Omit<IVaultV2Adapter, "adapterId" | "type"> {
4
5
  type?: "VaultV2MorphoVaultV1Adapter";
5
6
  morphoVaultV1: Address;
@@ -7,6 +8,7 @@ export interface IVaultV2MorphoVaultV1Adapter extends Omit<IVaultV2Adapter, "ada
7
8
  import type { BigIntish } from "../../types.js";
8
9
  import type { AccrualVault } from "../Vault.js";
9
10
  import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
11
+ /** Represents a Vault V2 adapter investing in a MetaMorpho V1 vault. */
10
12
  export declare class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter implements IVaultV2MorphoVaultV1Adapter {
11
13
  readonly type: "VaultV2MorphoVaultV1Adapter";
12
14
  static adapterId(address: Address): `0x${string}`;
@@ -14,8 +16,10 @@ export declare class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter implemen
14
16
  constructor({ morphoVaultV1, ...vaultV2Adapter }: IVaultV2MorphoVaultV1Adapter);
15
17
  ids(): `0x${string}`[];
16
18
  }
19
+ /** Plain input shape for an accrued Vault V2 MetaMorpho V1 adapter. */
17
20
  export interface IAccrualVaultV2MorphoVaultV1Adapter extends IVaultV2MorphoVaultV1Adapter {
18
21
  }
22
+ /** Represents an accrued Vault V2 MetaMorpho V1 adapter. */
19
23
  export declare class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter implements IAccrualVaultV2MorphoVaultV1Adapter, IAccrualVaultV2Adapter {
20
24
  accrualVaultV1: AccrualVault;
21
25
  shares: bigint;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccrualVaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoVaultV1Adapter = void 0;
4
4
  const viem_1 = require("viem");
5
5
  const VaultV2Adapter_js_1 = require("./VaultV2Adapter.js");
6
+ /** Represents a Vault V2 adapter investing in a MetaMorpho V1 vault. */
6
7
  class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter_js_1.VaultV2Adapter {
7
8
  static adapterId(address) {
8
9
  return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "string" }, { type: "address" }], ["this", address]));
@@ -21,6 +22,7 @@ class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter_js_1.VaultV2Adapter {
21
22
  }
22
23
  }
23
24
  exports.VaultV2MorphoVaultV1Adapter = VaultV2MorphoVaultV1Adapter;
25
+ /** Represents an accrued Vault V2 MetaMorpho V1 adapter. */
24
26
  class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter {
25
27
  accrualVaultV1;
26
28
  shares;
@@ -6,6 +6,7 @@ import type { Address } from "./types.js";
6
6
  * NB: data might differ from expected onchain native token data
7
7
  */
8
8
  export declare const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
9
+ /** Registry entry for protocol, adapter, factory, and token addresses on one chain. */
9
10
  export interface ChainAddresses {
10
11
  morpho: Address;
11
12
  permit2?: Address;
@@ -725,7 +726,22 @@ declare const _addressesRegistry: {
725
726
  readonly preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440";
726
727
  readonly wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432";
727
728
  };
729
+ readonly 5042: {
730
+ readonly morpho: "0x34CD04070dD72b14E241112F6d83812Df5Af7fCD";
731
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
732
+ readonly bundler3: {
733
+ readonly bundler3: "0x855dbe13C409Df75CAF6a985Cf6993a4D0319Feb";
734
+ readonly generalAdapter1: "0x0AF5BE7BD7B615e94e1d9275414482D028952466";
735
+ };
736
+ readonly adaptiveCurveIrm: "0xF02615d094Fc02fC031C35fe705e175aA4653f20";
737
+ readonly vaultV2Factory: "0x3b0eefaBfa22ec7CF2c73877ac16e78D76749f12";
738
+ readonly morphoMarketV1AdapterV2Factory: "0x6C2FF5114E45b50bc7195c2F1f87C98cbdad62Cc";
739
+ readonly registryList: "0xdEBC92370Cd74d55DA144116138681dbbb528765";
740
+ readonly chainlinkOracleFactory: "0xbFc8D6167a02889D5EB08a023d9aB712B44f7dE8";
741
+ readonly preLiquidationFactory: "0x8edf6Ac769a7E7D81d571aC0FB8733aD724f6922";
742
+ };
728
743
  };
744
+ /** Deployment block registry with the same shape as `ChainAddresses`. */
729
745
  export type ChainDeployments<Addresses = ChainAddresses> = {
730
746
  [key in keyof Addresses]: Address extends Addresses[key] ? bigint : ChainDeployments<Addresses[key]>;
731
747
  };
@@ -1324,9 +1340,52 @@ declare const _deployments: {
1324
1340
  readonly preLiquidationFactory: 213462907n;
1325
1341
  readonly wNative: 104802159n;
1326
1342
  };
1343
+ readonly 5042: {
1344
+ readonly morpho: 1208685n;
1345
+ readonly permit2: 0n;
1346
+ readonly bundler3: {
1347
+ readonly bundler3: 1208685n;
1348
+ readonly generalAdapter1: 1208685n;
1349
+ };
1350
+ readonly adaptiveCurveIrm: 1208685n;
1351
+ readonly vaultV2Factory: 1208931n;
1352
+ readonly morphoMarketV1AdapterV2Factory: 1208978n;
1353
+ readonly registryList: 1208978n;
1354
+ readonly chainlinkOracleFactory: 1208882n;
1355
+ readonly preLiquidationFactory: 1208882n;
1356
+ };
1327
1357
  };
1358
+ /** Dot-separated label for an address entry in the chain registry. */
1328
1359
  export type AddressLabel = DottedKeys<(typeof _addressesRegistry)[ChainId]>;
1360
+ /**
1361
+ * Returns the protocol address registry for a chain.
1362
+ *
1363
+ * @param chainId - The EIP-155 chain id.
1364
+ * @returns The configured protocol, adapter, factory, and token addresses for `chainId`.
1365
+ * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
1366
+ * @example
1367
+ * ```ts
1368
+ * import { ChainId, getChainAddresses } from "@morpho-org/blue-sdk";
1369
+ *
1370
+ * const chainAddresses = getChainAddresses(ChainId.EthMainnet);
1371
+ * // chainAddresses satisfies ChainAddresses
1372
+ * ```
1373
+ */
1329
1374
  export declare const getChainAddresses: (chainId: number) => ChainAddresses;
1375
+ /**
1376
+ * Returns the unwrapped token mapped to a wrapped token on a chain.
1377
+ *
1378
+ * @param wrappedToken - The wrapped token address to resolve.
1379
+ * @param chainId - The EIP-155 chain id.
1380
+ * @returns The unwrapped token address, or `undefined` when no mapping is registered.
1381
+ * @example
1382
+ * ```ts
1383
+ * import { ChainId, getUnwrappedToken, NATIVE_ADDRESS, addresses } from "@morpho-org/blue-sdk";
1384
+ *
1385
+ * const unwrapped = getUnwrappedToken(addresses[ChainId.EthMainnet].wNative!, ChainId.EthMainnet);
1386
+ * // unwrapped === NATIVE_ADDRESS
1387
+ * ```
1388
+ */
1330
1389
  export declare function getUnwrappedToken(wrappedToken: Address, chainId: number): `0x${string}` | undefined;
1331
1390
  /**
1332
1391
  * The registry of all known ERC20Wrapper tokens.
@@ -1347,11 +1406,25 @@ export declare const permissionedBackedTokens: Record<number, Set<Address>>;
1347
1406
  * All permissioned Coinbase tokens are considered PermissionedERC20Wrapper and automatically added to the permissionedWrapperTokens registry.
1348
1407
  */
1349
1408
  export declare const permissionedCoinbaseTokens: Record<number, Set<Address>>;
1409
+ /**
1410
+ * Returns the known Coinbase-attested wrapped tokens for a chain.
1411
+ *
1412
+ * @param chainId - The EIP-155 chain id.
1413
+ * @returns A set of permissioned wrapped token addresses, or an empty set when none are registered.
1414
+ * @example
1415
+ * ```ts
1416
+ * import { ChainId, getPermissionedCoinbaseTokens } from "@morpho-org/blue-sdk";
1417
+ *
1418
+ * const tokens = getPermissionedCoinbaseTokens(ChainId.BaseMainnet);
1419
+ * // tokens satisfies Set<Address>
1420
+ * ```
1421
+ */
1350
1422
  export declare const getPermissionedCoinbaseTokens: (chainId: number) => Set<`0x${string}`>;
1351
1423
  /** /!\ These tokens can not be listed in `erc20WrapperTokens` because the following specs are different:
1352
1424
  * - calling `depositFor` supplies on blue instead of minting wrapped token to the user
1353
1425
  */
1354
1426
  export declare const convexWrapperTokens: Record<number, Set<Address>>;
1427
+ /** Deep-frozen registry of known chain addresses, keyed by chain id. */
1355
1428
  export declare let addressesRegistry: {
1356
1429
  readonly 1: {
1357
1430
  readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
@@ -2028,8 +2101,24 @@ export declare let addressesRegistry: {
2028
2101
  readonly preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440";
2029
2102
  readonly wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432";
2030
2103
  };
2104
+ readonly 5042: {
2105
+ readonly morpho: "0x34CD04070dD72b14E241112F6d83812Df5Af7fCD";
2106
+ readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
2107
+ readonly bundler3: {
2108
+ readonly bundler3: "0x855dbe13C409Df75CAF6a985Cf6993a4D0319Feb";
2109
+ readonly generalAdapter1: "0x0AF5BE7BD7B615e94e1d9275414482D028952466";
2110
+ };
2111
+ readonly adaptiveCurveIrm: "0xF02615d094Fc02fC031C35fe705e175aA4653f20";
2112
+ readonly vaultV2Factory: "0x3b0eefaBfa22ec7CF2c73877ac16e78D76749f12";
2113
+ readonly morphoMarketV1AdapterV2Factory: "0x6C2FF5114E45b50bc7195c2F1f87C98cbdad62Cc";
2114
+ readonly registryList: "0xdEBC92370Cd74d55DA144116138681dbbb528765";
2115
+ readonly chainlinkOracleFactory: "0xbFc8D6167a02889D5EB08a023d9aB712B44f7dE8";
2116
+ readonly preLiquidationFactory: "0x8edf6Ac769a7E7D81d571aC0FB8733aD724f6922";
2117
+ };
2031
2118
  };
2119
+ /** Address registry keyed by numeric chain id. */
2032
2120
  export declare let addresses: Record<number, ChainAddresses>;
2121
+ /** Deep-frozen registry of deployment blocks, keyed by chain id. */
2033
2122
  export declare let deployments: {
2034
2123
  readonly 1: {
2035
2124
  readonly morpho: 18883124n;
@@ -2625,7 +2714,22 @@ export declare let deployments: {
2625
2714
  readonly preLiquidationFactory: 213462907n;
2626
2715
  readonly wNative: 104802159n;
2627
2716
  };
2717
+ readonly 5042: {
2718
+ readonly morpho: 1208685n;
2719
+ readonly permit2: 0n;
2720
+ readonly bundler3: {
2721
+ readonly bundler3: 1208685n;
2722
+ readonly generalAdapter1: 1208685n;
2723
+ };
2724
+ readonly adaptiveCurveIrm: 1208685n;
2725
+ readonly vaultV2Factory: 1208931n;
2726
+ readonly morphoMarketV1AdapterV2Factory: 1208978n;
2727
+ readonly registryList: 1208978n;
2728
+ readonly chainlinkOracleFactory: 1208882n;
2729
+ readonly preLiquidationFactory: 1208882n;
2730
+ };
2628
2731
  };
2732
+ /** Deep-frozen registry of wrapped token to unwrapped token mappings. */
2629
2733
  export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`, `0x${string}`>>;
2630
2734
  /**
2631
2735
  * Registers custom addresses and unwrapped token mappings to extend
@@ -2642,6 +2746,7 @@ export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`,
2642
2746
  * Must provide all required deployments if chain is unknown.
2643
2747
  *
2644
2748
  * @throws {Error} If attempting to override an existing address.
2749
+ * @returns Nothing.
2645
2750
  *
2646
2751
  * @example
2647
2752
  * ```ts
@@ -710,6 +710,20 @@ const _addressesRegistry = {
710
710
  preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440",
711
711
  wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432",
712
712
  },
713
+ [ChainId.ArcMainnet]: {
714
+ morpho: "0x34CD04070dD72b14E241112F6d83812Df5Af7fCD",
715
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
716
+ bundler3: {
717
+ bundler3: "0x855dbe13C409Df75CAF6a985Cf6993a4D0319Feb",
718
+ generalAdapter1: "0x0AF5BE7BD7B615e94e1d9275414482D028952466",
719
+ },
720
+ adaptiveCurveIrm: "0xF02615d094Fc02fC031C35fe705e175aA4653f20",
721
+ vaultV2Factory: "0x3b0eefaBfa22ec7CF2c73877ac16e78D76749f12",
722
+ morphoMarketV1AdapterV2Factory: "0x6C2FF5114E45b50bc7195c2F1f87C98cbdad62Cc",
723
+ registryList: "0xdEBC92370Cd74d55DA144116138681dbbb528765",
724
+ chainlinkOracleFactory: "0xbFc8D6167a02889D5EB08a023d9aB712B44f7dE8",
725
+ preLiquidationFactory: "0x8edf6Ac769a7E7D81d571aC0FB8733aD724f6922",
726
+ },
713
727
  };
714
728
  const _deployments = {
715
729
  [ChainId.EthMainnet]: {
@@ -1306,7 +1320,35 @@ const _deployments = {
1306
1320
  preLiquidationFactory: 213462907n,
1307
1321
  wNative: 104802159n,
1308
1322
  },
1323
+ [ChainId.ArcMainnet]: {
1324
+ morpho: 1208685n,
1325
+ permit2: 0n,
1326
+ bundler3: {
1327
+ bundler3: 1208685n,
1328
+ generalAdapter1: 1208685n,
1329
+ },
1330
+ adaptiveCurveIrm: 1208685n,
1331
+ vaultV2Factory: 1208931n,
1332
+ morphoMarketV1AdapterV2Factory: 1208978n,
1333
+ registryList: 1208978n,
1334
+ chainlinkOracleFactory: 1208882n,
1335
+ preLiquidationFactory: 1208882n,
1336
+ },
1309
1337
  };
1338
+ /**
1339
+ * Returns the protocol address registry for a chain.
1340
+ *
1341
+ * @param chainId - The EIP-155 chain id.
1342
+ * @returns The configured protocol, adapter, factory, and token addresses for `chainId`.
1343
+ * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
1344
+ * @example
1345
+ * ```ts
1346
+ * import { ChainId, getChainAddresses } from "@morpho-org/blue-sdk";
1347
+ *
1348
+ * const chainAddresses = getChainAddresses(ChainId.EthMainnet);
1349
+ * // chainAddresses satisfies ChainAddresses
1350
+ * ```
1351
+ */
1310
1352
  export const getChainAddresses = (chainId) => {
1311
1353
  const chainAddresses = addresses[chainId];
1312
1354
  if (chainAddresses == null)
@@ -1436,6 +1478,20 @@ const _unwrappedTokensMapping = {
1436
1478
  [_addressesRegistry[ChainId.KaiaMainnet].wNative]: NATIVE_ADDRESS,
1437
1479
  },
1438
1480
  };
1481
+ /**
1482
+ * Returns the unwrapped token mapped to a wrapped token on a chain.
1483
+ *
1484
+ * @param wrappedToken - The wrapped token address to resolve.
1485
+ * @param chainId - The EIP-155 chain id.
1486
+ * @returns The unwrapped token address, or `undefined` when no mapping is registered.
1487
+ * @example
1488
+ * ```ts
1489
+ * import { ChainId, getUnwrappedToken, NATIVE_ADDRESS, addresses } from "@morpho-org/blue-sdk";
1490
+ *
1491
+ * const unwrapped = getUnwrappedToken(addresses[ChainId.EthMainnet].wNative!, ChainId.EthMainnet);
1492
+ * // unwrapped === NATIVE_ADDRESS
1493
+ * ```
1494
+ */
1439
1495
  export function getUnwrappedToken(wrappedToken, chainId) {
1440
1496
  return unwrappedTokensMapping[chainId]?.[wrappedToken];
1441
1497
  }
@@ -1471,6 +1527,19 @@ export const permissionedCoinbaseTokens = {
1471
1527
  _addressesRegistry[ChainId.BaseMainnet].verUsdc,
1472
1528
  ]),
1473
1529
  };
1530
+ /**
1531
+ * Returns the known Coinbase-attested wrapped tokens for a chain.
1532
+ *
1533
+ * @param chainId - The EIP-155 chain id.
1534
+ * @returns A set of permissioned wrapped token addresses, or an empty set when none are registered.
1535
+ * @example
1536
+ * ```ts
1537
+ * import { ChainId, getPermissionedCoinbaseTokens } from "@morpho-org/blue-sdk";
1538
+ *
1539
+ * const tokens = getPermissionedCoinbaseTokens(ChainId.BaseMainnet);
1540
+ * // tokens satisfies Set<Address>
1541
+ * ```
1542
+ */
1474
1543
  export const getPermissionedCoinbaseTokens = (chainId) => permissionedCoinbaseTokens[chainId] ?? new Set();
1475
1544
  entries(permissionedBackedTokens).forEach(([chainId, tokens]) => {
1476
1545
  tokens.forEach((token) => (erc20WrapperTokens[chainId] ??= new Set()).add(token));
@@ -1494,9 +1563,13 @@ export const convexWrapperTokens = {
1494
1563
  _addressesRegistry[ChainId.EthMainnet]["stkcvx2BTC-f-morpho"],
1495
1564
  ]),
1496
1565
  };
1566
+ /** Deep-frozen registry of known chain addresses, keyed by chain id. */
1497
1567
  export let addressesRegistry = deepFreeze(_addressesRegistry);
1568
+ /** Address registry keyed by numeric chain id. */
1498
1569
  export let addresses = addressesRegistry;
1570
+ /** Deep-frozen registry of deployment blocks, keyed by chain id. */
1499
1571
  export let deployments = deepFreeze(_deployments);
1572
+ /** Deep-frozen registry of wrapped token to unwrapped token mappings. */
1500
1573
  export let unwrappedTokensMapping = deepFreeze(_unwrappedTokensMapping);
1501
1574
  /**
1502
1575
  * Registers custom addresses and unwrapped token mappings to extend
@@ -1513,6 +1586,7 @@ export let unwrappedTokensMapping = deepFreeze(_unwrappedTokensMapping);
1513
1586
  * Must provide all required deployments if chain is unknown.
1514
1587
  *
1515
1588
  * @throws {Error} If attempting to override an existing address.
1589
+ * @returns Nothing.
1516
1590
  *
1517
1591
  * @example
1518
1592
  * ```ts