@morpho-org/blue-sdk 2.0.0-test.1 → 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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -26
  3. package/lib/addresses.d.ts +59 -55
  4. package/lib/addresses.js +42 -43
  5. package/lib/chain.d.ts +1 -1
  6. package/lib/chain.js +3 -3
  7. package/lib/errors.d.ts +7 -8
  8. package/lib/errors.js +21 -19
  9. package/lib/holding/AssetBalances.d.ts +3 -3
  10. package/lib/holding/Holding.d.ts +10 -5
  11. package/lib/holding/Holding.js +14 -4
  12. package/lib/holding/index.d.ts +2 -2
  13. package/lib/holding/index.js +2 -2
  14. package/lib/index.d.ts +12 -25
  15. package/lib/index.js +12 -38
  16. package/lib/market/Market.d.ts +48 -34
  17. package/lib/market/Market.js +76 -57
  18. package/lib/market/{MarketConfig.d.ts → MarketParams.d.ts} +8 -7
  19. package/lib/market/{MarketConfig.js → MarketParams.js} +20 -21
  20. package/lib/market/MarketUtils.d.ts +94 -42
  21. package/lib/market/MarketUtils.js +145 -67
  22. package/lib/market/index.d.ts +3 -3
  23. package/lib/market/index.js +3 -3
  24. package/lib/{maths → math}/AdaptiveCurveIrmLib.d.ts +1 -1
  25. package/lib/{maths → math}/AdaptiveCurveIrmLib.js +20 -20
  26. package/lib/{maths → math}/MathLib.d.ts +24 -42
  27. package/lib/{maths → math}/MathLib.js +41 -54
  28. package/lib/{maths → math}/SharesMath.d.ts +2 -2
  29. package/lib/{maths → math}/SharesMath.js +3 -3
  30. package/lib/math/index.d.ts +3 -0
  31. package/lib/{helpers/format → math}/index.js +3 -1
  32. package/lib/position/Position.d.ts +35 -25
  33. package/lib/position/Position.js +46 -44
  34. package/lib/position/index.d.ts +1 -1
  35. package/lib/position/index.js +1 -1
  36. package/lib/token/ConstantWrappedToken.d.ts +6 -7
  37. package/lib/token/ConstantWrappedToken.js +8 -10
  38. package/lib/token/ExchangeRateWrappedToken.d.ts +5 -5
  39. package/lib/token/ExchangeRateWrappedToken.js +5 -5
  40. package/lib/token/Token.d.ts +18 -18
  41. package/lib/token/Token.js +24 -27
  42. package/lib/token/VaultToken.d.ts +20 -11
  43. package/lib/token/VaultToken.js +15 -7
  44. package/lib/token/WrappedToken.d.ts +4 -4
  45. package/lib/token/WrappedToken.js +7 -7
  46. package/lib/token/index.d.ts +5 -5
  47. package/lib/token/index.js +5 -5
  48. package/lib/types.d.ts +3 -6
  49. package/lib/user/User.d.ts +1 -1
  50. package/lib/user/index.d.ts +1 -1
  51. package/lib/user/index.js +1 -1
  52. package/lib/vault/Vault.d.ts +22 -28
  53. package/lib/vault/Vault.js +43 -51
  54. package/lib/vault/VaultConfig.d.ts +6 -7
  55. package/lib/vault/VaultConfig.js +5 -5
  56. package/lib/vault/VaultMarketAllocation.d.ts +8 -8
  57. package/lib/vault/VaultMarketAllocation.js +3 -3
  58. package/lib/vault/VaultMarketConfig.d.ts +10 -10
  59. package/lib/vault/VaultMarketPublicAllocatorConfig.d.ts +6 -6
  60. package/lib/vault/VaultUser.d.ts +26 -0
  61. package/lib/vault/VaultUser.js +28 -0
  62. package/lib/vault/VaultUtils.d.ts +4 -6
  63. package/lib/vault/VaultUtils.js +6 -6
  64. package/lib/vault/index.d.ts +7 -6
  65. package/lib/vault/index.js +7 -6
  66. package/package.json +25 -56
  67. package/lib/chain.test.d.ts +0 -1
  68. package/lib/chain.test.js +0 -21
  69. package/lib/helpers/format/format.d.ts +0 -122
  70. package/lib/helpers/format/format.js +0 -286
  71. package/lib/helpers/format/format.test.d.ts +0 -1
  72. package/lib/helpers/format/format.test.js +0 -255
  73. package/lib/helpers/format/index.d.ts +0 -1
  74. package/lib/helpers/index.d.ts +0 -2
  75. package/lib/helpers/index.js +0 -18
  76. package/lib/helpers/locale.d.ts +0 -46
  77. package/lib/helpers/locale.js +0 -96
  78. package/lib/market/MarketUtils.test.d.ts +0 -1
  79. package/lib/market/MarketUtils.test.js +0 -38
  80. package/lib/maths/index.d.ts +0 -3
  81. package/lib/maths/index.js +0 -19
  82. package/lib/tests/mocks/markets.d.ts +0 -19
  83. package/lib/tests/mocks/markets.js +0 -121
@@ -1,9 +1,9 @@
1
- import { CapacityLimit } from "../market";
2
- import { RoundingDirection } from "../maths";
3
- import { VaultToken } from "../token";
4
- import { Address, BigIntish, MarketId } from "../types";
5
- import { VaultConfig } from "./VaultConfig";
6
- import { InputVaultMarketAllocation, VaultMarketAllocation } from "./VaultMarketAllocation";
1
+ import { type CapacityLimit } from "../market/index.js";
2
+ import { type RoundingDirection } from "../math/index.js";
3
+ import { VaultToken } from "../token/index.js";
4
+ import type { Address, BigIntish, MarketId } from "../types.js";
5
+ import type { IVaultConfig } from "./VaultConfig.js";
6
+ import { type IVaultMarketAllocation, VaultMarketAllocation } from "./VaultMarketAllocation.js";
7
7
  export interface Pending<T> {
8
8
  value: T;
9
9
  validAt: bigint;
@@ -22,8 +22,7 @@ export interface VaultPublicAllocatorConfig {
22
22
  */
23
23
  accruedFee: bigint;
24
24
  }
25
- export interface InputVault {
26
- config: VaultConfig;
25
+ export interface IVault extends IVaultConfig {
27
26
  curator: Address;
28
27
  owner: Address;
29
28
  guardian: Address;
@@ -41,11 +40,15 @@ export interface InputVault {
41
40
  lastTotalAssets: bigint;
42
41
  publicAllocatorConfig?: VaultPublicAllocatorConfig;
43
42
  }
44
- export declare class Vault extends VaultToken implements InputVault {
43
+ export declare class Vault extends VaultToken implements IVault {
45
44
  /**
46
- * The MetaMorpho vault's config.
45
+ * The vault's share token's name.
47
46
  */
48
- readonly config: VaultConfig;
47
+ readonly name: string;
48
+ /**
49
+ * The vault's share token's symbol.
50
+ */
51
+ readonly symbol: string;
49
52
  /**
50
53
  * The MetaMorpho vault's owner address.
51
54
  */
@@ -94,14 +97,6 @@ export declare class Vault extends VaultToken implements InputVault {
94
97
  * The MetaMorpho vault's ordered withdraw queue.
95
98
  */
96
99
  withdrawQueue: MarketId[];
97
- /**
98
- * The ERC4626 vault's total supply of shares.
99
- */
100
- totalSupply: bigint;
101
- /**
102
- * The ERC4626 vault's total assets.
103
- */
104
- totalAssets: bigint;
105
100
  /**
106
101
  * The MetaMorpho vault's last total assets used to calculate performance fees.
107
102
  */
@@ -110,8 +105,7 @@ export declare class Vault extends VaultToken implements InputVault {
110
105
  * The MetaMorpho vault's public allocator configuration.
111
106
  */
112
107
  publicAllocatorConfig?: VaultPublicAllocatorConfig;
113
- constructor({ config, curator, owner, guardian, publicAllocatorConfig, fee, feeRecipient, skimRecipient, pendingTimelock, pendingGuardian, pendingOwner, timelock, supplyQueue, withdrawQueue, totalSupply, totalAssets, lastTotalAssets, }: InputVault);
114
- get asset(): string;
108
+ constructor({ curator, owner, guardian, publicAllocatorConfig, fee, feeRecipient, skimRecipient, pendingTimelock, pendingGuardian, pendingOwner, timelock, supplyQueue, withdrawQueue, totalSupply, totalAssets, lastTotalAssets, ...config }: IVault);
115
109
  /**
116
110
  * The amount of interest in assets accrued since the last interaction with the vault.
117
111
  */
@@ -126,9 +120,9 @@ export interface CollateralAllocation {
126
120
  markets: Set<MarketId>;
127
121
  proportion: bigint;
128
122
  }
129
- export interface InputAccrualVault extends Omit<InputVault, "withdrawQueue" | "totalAssets"> {
123
+ export interface IAccrualVault extends Omit<IVault, "withdrawQueue" | "totalAssets"> {
130
124
  }
131
- export declare class AccrualVault extends Vault implements InputAccrualVault {
125
+ export declare class AccrualVault extends Vault implements IAccrualVault {
132
126
  /**
133
127
  * The allocation of the vault on each market enabled.
134
128
  */
@@ -137,22 +131,22 @@ export declare class AccrualVault extends Vault implements InputAccrualVault {
137
131
  * The proportion of assets of the vault supplied to markets collateralized by each collateral asset.
138
132
  */
139
133
  readonly collateralAllocations: Map<Address, CollateralAllocation>;
140
- constructor(vault: InputAccrualVault,
134
+ constructor(vault: IAccrualVault,
141
135
  /**
142
136
  * The allocation of the vault on each market of the withdraw queue,
143
137
  * in the same order as the withdraw queue.
144
138
  */
145
- allocations: Omit<InputVaultMarketAllocation, "proportion">[]);
139
+ allocations: Omit<IVaultMarketAllocation, "proportion">[]);
146
140
  /**
147
141
  * The vault's liquidity directly available from allocated markets.
148
142
  */
149
143
  get liquidity(): bigint;
150
144
  /**
151
- * The MetaMorpho vault's average APY on its assets, including the performance fee.
145
+ * The MetaMorpho vault's APY on its assets averaged over its market deposits, before deducting the performance fee.
152
146
  */
153
- get avgApy(): bigint;
147
+ get apy(): bigint;
154
148
  /**
155
- * The MetaMorpho vault's average APY on its assets, excluding the performance fee.
149
+ * The MetaMorpho vault's APY on its assets averaged over its market deposits, after deducting the performance fee.
156
150
  */
157
151
  get netApy(): bigint;
158
152
  getAllocationProportion(marketId: MarketId): bigint;
@@ -1,16 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccrualVault = exports.Vault = void 0;
4
- const market_1 = require("../market");
5
- const maths_1 = require("../maths");
6
- const token_1 = require("../token");
7
- const VaultMarketAllocation_1 = require("./VaultMarketAllocation");
8
- const VaultUtils_1 = require("./VaultUtils");
9
- class Vault extends token_1.VaultToken {
10
- /**
11
- * The MetaMorpho vault's config.
12
- */
13
- config;
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 {
14
9
  /**
15
10
  * The MetaMorpho vault's owner address.
16
11
  */
@@ -59,14 +54,6 @@ class Vault extends token_1.VaultToken {
59
54
  * The MetaMorpho vault's ordered withdraw queue.
60
55
  */
61
56
  withdrawQueue;
62
- /**
63
- * The ERC4626 vault's total supply of shares.
64
- */
65
- totalSupply;
66
- /**
67
- * The ERC4626 vault's total assets.
68
- */
69
- totalAssets;
70
57
  /**
71
58
  * The MetaMorpho vault's last total assets used to calculate performance fees.
72
59
  */
@@ -75,9 +62,8 @@ class Vault extends token_1.VaultToken {
75
62
  * The MetaMorpho vault's public allocator configuration.
76
63
  */
77
64
  publicAllocatorConfig;
78
- constructor({ config, curator, owner, guardian, publicAllocatorConfig, fee, feeRecipient, skimRecipient, pendingTimelock, pendingGuardian, pendingOwner, timelock, supplyQueue, withdrawQueue, totalSupply, totalAssets, lastTotalAssets, }) {
65
+ constructor({ curator, owner, guardian, publicAllocatorConfig, fee, feeRecipient, skimRecipient, pendingTimelock, pendingGuardian, pendingOwner, timelock, supplyQueue, withdrawQueue, totalSupply, totalAssets, lastTotalAssets, ...config }) {
79
66
  super(config, { totalAssets, totalSupply });
80
- this.config = config;
81
67
  this.curator = curator;
82
68
  this.owner = owner;
83
69
  this.guardian = guardian;
@@ -93,25 +79,20 @@ class Vault extends token_1.VaultToken {
93
79
  this.timelock = timelock;
94
80
  this.supplyQueue = supplyQueue;
95
81
  this.withdrawQueue = withdrawQueue;
96
- this.totalSupply = totalSupply;
97
- this.totalAssets = totalAssets;
98
82
  this.lastTotalAssets = lastTotalAssets;
99
83
  this.publicAllocatorConfig = publicAllocatorConfig;
100
84
  }
101
- get asset() {
102
- return this.config.asset;
103
- }
104
85
  /**
105
86
  * The amount of interest in assets accrued since the last interaction with the vault.
106
87
  */
107
88
  get totalInterest() {
108
- return maths_1.MathLib.zeroFloorSub(this.totalAssets, this.lastTotalAssets);
89
+ return index_js_2.MathLib.zeroFloorSub(this.totalAssets, this.lastTotalAssets);
109
90
  }
110
91
  toAssets(shares, rounding) {
111
- return VaultUtils_1.VaultUtils.toAssets(shares, this, this.config, rounding);
92
+ return this._unwrap(shares, rounding);
112
93
  }
113
94
  toShares(assets, rounding) {
114
- return VaultUtils_1.VaultUtils.toShares(assets, this, this.config, rounding);
95
+ return this._wrap(assets, rounding);
115
96
  }
116
97
  }
117
98
  exports.Vault = Vault;
@@ -137,11 +118,11 @@ class AccrualVault extends Vault {
137
118
  });
138
119
  this.allocations = new Map(allocations.map((allocation) => [
139
120
  allocation.position.market.id,
140
- new VaultMarketAllocation_1.VaultMarketAllocation(allocation),
121
+ new VaultMarketAllocation_js_1.VaultMarketAllocation(allocation),
141
122
  ]));
142
123
  this.collateralAllocations = new Map();
143
124
  for (const { marketId, position } of this.allocations.values()) {
144
- const address = position.market.config.collateralToken;
125
+ const address = position.market.params.collateralToken;
145
126
  let exposure = this.collateralAllocations.get(address);
146
127
  if (!exposure)
147
128
  this.collateralAllocations.set(address, (exposure = {
@@ -151,8 +132,8 @@ class AccrualVault extends Vault {
151
132
  markets: new Set(),
152
133
  proportion: 0n,
153
134
  }));
154
- exposure.lltvs.add(position.market.config.lltv);
155
- exposure.oracles.add(position.market.config.oracle);
135
+ exposure.lltvs.add(position.market.params.lltv);
136
+ exposure.oracles.add(position.market.params.oracle);
156
137
  exposure.markets.add(marketId);
157
138
  exposure.proportion += this.getAllocationProportion(marketId);
158
139
  }
@@ -161,21 +142,25 @@ class AccrualVault extends Vault {
161
142
  * The vault's liquidity directly available from allocated markets.
162
143
  */
163
144
  get liquidity() {
164
- return Array.from(this.allocations.values()).reduce((total, { position }) => total + position.withdrawCapacityLimit.value, 0n);
145
+ return this.allocations
146
+ .values()
147
+ .reduce((total, { position }) => total + position.withdrawCapacityLimit.value, 0n);
165
148
  }
166
149
  /**
167
- * The MetaMorpho vault's average APY on its assets, including the performance fee.
150
+ * The MetaMorpho vault's APY on its assets averaged over its market deposits, before deducting the performance fee.
168
151
  */
169
- get avgApy() {
152
+ get apy() {
170
153
  if (this.totalAssets === 0n)
171
154
  return 0n;
172
- return (Array.from(this.allocations.values()).reduce((total, { position }) => total + position.market.supplyApy * position.supplyAssets, 0n) / this.totalAssets);
155
+ return (this.allocations
156
+ .values()
157
+ .reduce((total, { position }) => total + position.market.supplyApy * position.supplyAssets, 0n) / this.totalAssets);
173
158
  }
174
159
  /**
175
- * The MetaMorpho vault's average APY on its assets, excluding the performance fee.
160
+ * The MetaMorpho vault's APY on its assets averaged over its market deposits, after deducting the performance fee.
176
161
  */
177
162
  get netApy() {
178
- return maths_1.MathLib.wMulDown(this.avgApy, maths_1.MathLib.WAD - this.fee);
163
+ return index_js_2.MathLib.wMulDown(this.apy, index_js_2.MathLib.WAD - this.fee);
179
164
  }
180
165
  getAllocationProportion(marketId) {
181
166
  if (this.totalAssets === 0n)
@@ -183,21 +168,23 @@ class AccrualVault extends Vault {
183
168
  const allocation = this.allocations.get(marketId);
184
169
  if (!allocation)
185
170
  return 0n;
186
- return maths_1.MathLib.wDivDown(allocation.position.supplyAssets, this.totalAssets);
171
+ return index_js_2.MathLib.wDivDown(allocation.position.supplyAssets, this.totalAssets);
187
172
  }
188
173
  getDepositCapacityLimit(assets) {
189
- const suppliable = Array.from(this.allocations.values()).reduce((total, { config: { cap }, position: { marketId, supplyAssets } }) => maths_1.MathLib.min(total +
174
+ const suppliable = this.allocations
175
+ .values()
176
+ .reduce((total, { config: { cap }, position: { marketId, supplyAssets } }) => index_js_2.MathLib.min(total +
190
177
  (this.supplyQueue.includes(marketId)
191
- ? maths_1.MathLib.zeroFloorSub(cap, supplyAssets)
192
- : 0n), maths_1.MathLib.MAX_UINT_256), 0n);
178
+ ? index_js_2.MathLib.zeroFloorSub(cap, supplyAssets)
179
+ : 0n), index_js_2.MathLib.MAX_UINT_256), 0n);
193
180
  if (assets > suppliable)
194
181
  return {
195
182
  value: suppliable,
196
- limiter: market_1.CapacityLimitReason.cap,
183
+ limiter: index_js_1.CapacityLimitReason.cap,
197
184
  };
198
185
  return {
199
186
  value: assets,
200
- limiter: market_1.CapacityLimitReason.balance,
187
+ limiter: index_js_1.CapacityLimitReason.balance,
201
188
  };
202
189
  }
203
190
  getWithdrawCapacityLimit(shares) {
@@ -206,11 +193,11 @@ class AccrualVault extends Vault {
206
193
  if (assets > liquidity)
207
194
  return {
208
195
  value: liquidity,
209
- limiter: market_1.CapacityLimitReason.liquidity,
196
+ limiter: index_js_1.CapacityLimitReason.liquidity,
210
197
  };
211
198
  return {
212
199
  value: assets,
213
- limiter: market_1.CapacityLimitReason.balance,
200
+ limiter: index_js_1.CapacityLimitReason.balance,
214
201
  };
215
202
  }
216
203
  /**
@@ -218,11 +205,16 @@ class AccrualVault extends Vault {
218
205
  * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to each of the vault's market's `lastUpdate`.
219
206
  */
220
207
  accrueInterest(timestamp) {
221
- const vault = new AccrualVault(this, Array.from(this.allocations.values(), ({ config, position }) => ({
222
- config,
223
- position: position.accrueInterest(timestamp),
224
- })));
225
- const feeAssets = maths_1.MathLib.wMulDown(vault.totalInterest, vault.fee);
208
+ const vault = new AccrualVault(this,
209
+ // Keep withdraw queue order.
210
+ this.withdrawQueue.map((marketId) => {
211
+ const { config, position } = this.allocations.get(marketId);
212
+ return {
213
+ config,
214
+ position: position.accrueInterest(timestamp),
215
+ };
216
+ }));
217
+ const feeAssets = index_js_2.MathLib.wMulDown(vault.totalInterest, vault.fee);
226
218
  vault.totalAssets -= feeAssets;
227
219
  const feeShares = vault.toShares(feeAssets, "Down");
228
220
  vault.totalAssets += feeAssets;
@@ -1,14 +1,13 @@
1
- import { ChainId } from "../chain";
2
- import { Address } from "../types";
3
- export interface InputVaultConfig {
1
+ import type { ChainId } from "../chain.js";
2
+ import type { Address, BigIntish } from "../types.js";
3
+ export interface IVaultConfig {
4
4
  address: Address;
5
- decimals: number;
6
- decimalsOffset: bigint;
5
+ decimalsOffset: BigIntish;
7
6
  symbol: string;
8
7
  name: string;
9
8
  asset: Address;
10
9
  }
11
- export declare class VaultConfig implements InputVaultConfig {
10
+ export declare class VaultConfig implements IVaultConfig {
12
11
  readonly chainId?: number | undefined;
13
12
  protected static readonly _CACHE: Record<number, Record<Address, VaultConfig>>;
14
13
  static get(address: Address, chainId: ChainId): VaultConfig;
@@ -18,5 +17,5 @@ export declare class VaultConfig implements InputVaultConfig {
18
17
  readonly symbol: string;
19
18
  readonly name: string;
20
19
  readonly asset: Address;
21
- constructor({ address, decimals, decimalsOffset, symbol, name, asset, }: InputVaultConfig, chainId?: number | undefined);
20
+ constructor({ address, decimalsOffset, symbol, name, asset }: IVaultConfig, chainId?: number | undefined);
22
21
  }
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultConfig = void 0;
4
- const errors_1 = require("../errors");
4
+ const errors_js_1 = require("../errors.js");
5
5
  class VaultConfig {
6
6
  chainId;
7
7
  static _CACHE = {};
8
8
  static get(address, chainId) {
9
9
  const config = VaultConfig._CACHE[chainId]?.[address];
10
10
  if (!config)
11
- throw new errors_1.UnknownVaultConfigError(address);
11
+ throw new errors_js_1.UnknownVaultConfigError(address);
12
12
  return config;
13
13
  }
14
14
  address;
@@ -17,11 +17,11 @@ class VaultConfig {
17
17
  symbol;
18
18
  name;
19
19
  asset;
20
- constructor({ address, decimals, decimalsOffset, symbol, name, asset, }, chainId) {
20
+ constructor({ address, 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 = 18;
24
+ this.decimalsOffset = BigInt(decimalsOffset);
25
25
  this.symbol = symbol;
26
26
  this.name = name;
27
27
  this.asset = asset;
@@ -1,20 +1,20 @@
1
- import { AccrualPosition } from "../position";
2
- import { VaultMarketConfig } from "./VaultMarketConfig";
3
- export interface InputVaultMarketAllocation {
1
+ import type { AccrualPosition } from "../position/index.js";
2
+ import type { VaultMarketConfig } from "./VaultMarketConfig.js";
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
  */
11
- config: VaultMarketConfig;
11
+ readonly config: VaultMarketConfig;
12
12
  /**
13
13
  * The vault's position on the corresponding market.
14
14
  */
15
15
  readonly position: AccrualPosition;
16
- constructor({ config, position }: InputVaultMarketAllocation);
17
- get vault(): string;
18
- get marketId(): import("..").MarketId;
16
+ constructor({ config, position }: IVaultMarketAllocation);
17
+ get vault(): `0x${string}`;
18
+ get marketId(): import("../types.js").MarketId;
19
19
  get utilization(): bigint;
20
20
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultMarketAllocation = void 0;
4
- const maths_1 = require("../maths");
4
+ const index_js_1 = require("../math/index.js");
5
5
  class VaultMarketAllocation {
6
6
  /**
7
7
  * The vault's configuration on the corresponding market.
@@ -23,8 +23,8 @@ class VaultMarketAllocation {
23
23
  }
24
24
  get utilization() {
25
25
  if (this.config.cap === 0n)
26
- return maths_1.MathLib.MAX_UINT_256;
27
- return maths_1.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);
28
28
  }
29
29
  }
30
30
  exports.VaultMarketAllocation = VaultMarketAllocation;
@@ -1,24 +1,24 @@
1
- import { Address, MarketId } from "../types";
2
- import { Pending } from "./Vault";
3
- import { VaultMarketPublicAllocatorConfig } from "./VaultMarketPublicAllocatorConfig";
4
- export interface InputVaultMarketConfig {
1
+ import type { Address, MarketId } from "../types.js";
2
+ import type { Pending } from "./Vault.js";
3
+ import type { VaultMarketPublicAllocatorConfig } from "./VaultMarketPublicAllocatorConfig.js";
4
+ export interface IVaultMarketConfig {
5
5
  vault: Address;
6
6
  marketId: MarketId;
7
7
  cap: bigint;
8
8
  pendingCap: Pending<bigint>;
9
9
  removableAt: bigint;
10
10
  enabled: boolean;
11
- publicAllocatorConfig?: VaultMarketPublicAllocatorConfig;
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
  */
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;
42
- constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }: InputVaultMarketConfig);
41
+ readonly publicAllocatorConfig: VaultMarketPublicAllocatorConfig;
42
+ constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }: IVaultMarketConfig);
43
43
  }
@@ -1,22 +1,22 @@
1
- import { Address, MarketId } from "../types";
1
+ 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
  */
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
  */
@@ -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
  }
@@ -0,0 +1,26 @@
1
+ import type { Address } from "../types.js";
2
+ export interface IVaultUser {
3
+ vault: Address;
4
+ user: Address;
5
+ isAllocator: boolean;
6
+ allowance: bigint;
7
+ }
8
+ export declare class VaultUser implements IVaultUser {
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 }: IVaultUser);
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;
@@ -1,18 +1,16 @@
1
- import { RoundingDirection } from "../maths";
2
- import { BigIntish } from "../types";
1
+ import { type RoundingDirection } from "../math/index.js";
2
+ import type { BigIntish } from "../types.js";
3
3
  export declare namespace VaultUtils {
4
4
  const VIRTUAL_ASSETS = 1n;
5
5
  function decimalsOffset(decimals: BigIntish): bigint;
6
- function toAssets(shares: BigIntish, { totalAssets, totalSupply, }: {
6
+ function toAssets(shares: BigIntish, { totalAssets, totalSupply, decimalsOffset, }: {
7
7
  totalAssets: BigIntish;
8
8
  totalSupply: BigIntish;
9
- }, { decimalsOffset }: {
10
9
  decimalsOffset: BigIntish;
11
10
  }, rounding?: RoundingDirection): bigint;
12
- function toShares(assets: BigIntish, { totalAssets, totalSupply, }: {
11
+ function toShares(assets: BigIntish, { totalAssets, totalSupply, decimalsOffset, }: {
13
12
  totalAssets: BigIntish;
14
13
  totalSupply: BigIntish;
15
- }, { decimalsOffset }: {
16
14
  decimalsOffset: BigIntish;
17
15
  }, rounding?: RoundingDirection): bigint;
18
16
  }
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultUtils = void 0;
4
- const maths_1 = require("../maths");
4
+ const index_js_1 = require("../math/index.js");
5
5
  var VaultUtils;
6
6
  (function (VaultUtils) {
7
7
  VaultUtils.VIRTUAL_ASSETS = 1n;
8
8
  function decimalsOffset(decimals) {
9
- return maths_1.MathLib.zeroFloorSub(18n, decimals);
9
+ return index_js_1.MathLib.zeroFloorSub(18n, decimals);
10
10
  }
11
11
  VaultUtils.decimalsOffset = decimalsOffset;
12
- function toAssets(shares, { totalAssets, totalSupply, }, { decimalsOffset }, rounding = "Down") {
13
- return maths_1.MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
12
+ function toAssets(shares, { totalAssets, totalSupply, decimalsOffset, }, rounding = "Down") {
13
+ return index_js_1.MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
14
14
  }
15
15
  VaultUtils.toAssets = toAssets;
16
- function toShares(assets, { totalAssets, totalSupply, }, { decimalsOffset }, rounding = "Up") {
17
- return maths_1.MathLib.mulDiv(assets, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
16
+ function toShares(assets, { totalAssets, totalSupply, decimalsOffset, }, rounding = "Up") {
17
+ return index_js_1.MathLib.mulDiv(assets, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
18
18
  }
19
19
  VaultUtils.toShares = toShares;
20
20
  })(VaultUtils || (exports.VaultUtils = VaultUtils = {}));
@@ -1,6 +1,7 @@
1
- export * from "./VaultUtils";
2
- export * from "./VaultConfig";
3
- export * from "./VaultMarketAllocation";
4
- export * from "./VaultMarketConfig";
5
- export * from "./VaultMarketPublicAllocatorConfig";
6
- export * from "./Vault";
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";
@@ -14,9 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./VaultUtils"), exports);
18
- __exportStar(require("./VaultConfig"), exports);
19
- __exportStar(require("./VaultMarketAllocation"), exports);
20
- __exportStar(require("./VaultMarketConfig"), exports);
21
- __exportStar(require("./VaultMarketPublicAllocatorConfig"), exports);
22
- __exportStar(require("./Vault"), exports);
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);