@morpho-org/blue-sdk 5.2.0-next.0 → 5.2.0-next.1

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.
@@ -9,30 +9,6 @@ export declare const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEe
9
9
  export interface ChainAddresses {
10
10
  morpho: Address;
11
11
  permit2?: Address;
12
- /**
13
- * @deprecated All bundles should use Bundler3 instead.
14
- */
15
- bundler?: Address;
16
- /**
17
- * @deprecated All bundles should use Bundler3 instead.
18
- */
19
- aaveV3OptimizerBundler?: Address;
20
- /**
21
- * @deprecated All bundles should use Bundler3 instead.
22
- */
23
- aaveV2Bundler?: Address;
24
- /**
25
- * @deprecated All bundles should use Bundler3 instead.
26
- */
27
- aaveV3Bundler?: Address;
28
- /**
29
- * @deprecated All bundles should use Bundler3 instead.
30
- */
31
- compoundV3Bundler?: Address;
32
- /**
33
- * @deprecated All bundles should use Bundler3 instead.
34
- */
35
- compoundV2Bundler?: Address;
36
12
  bundler3: {
37
13
  bundler3: Address;
38
14
  generalAdapter1: Address;
@@ -71,10 +47,6 @@ declare const _addressesRegistry: {
71
47
  readonly 1: {
72
48
  readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
73
49
  readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
74
- /**
75
- * @deprecated All bundles should use Bundler3 instead.
76
- */
77
- readonly bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077";
78
50
  readonly bundler3: {
79
51
  readonly bundler3: "0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245";
80
52
  readonly generalAdapter1: "0x4A6c312ec70E8747a587EE860a0353cd42Be0aE0";
@@ -88,26 +60,6 @@ declare const _addressesRegistry: {
88
60
  readonly aaveV3EtherFiMigrationAdapter: "0x4011dc6581fA05F9B0c7A12AdCd676e2b1a59ca3";
89
61
  readonly aaveV3OptimizerMigrationAdapter: "0x9e2ea2d5785598a163D569D795f286F5C55ad972";
90
62
  };
91
- /**
92
- * @deprecated All bundles should use Bundler3 instead.
93
- */
94
- readonly aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c";
95
- /**
96
- * @deprecated All bundles should use Bundler3 instead.
97
- */
98
- readonly aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76";
99
- /**
100
- * @deprecated All bundles should use Bundler3 instead.
101
- */
102
- readonly aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC";
103
- /**
104
- * @deprecated All bundles should use Bundler3 instead.
105
- */
106
- readonly compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558";
107
- /**
108
- * @deprecated All bundles should use Bundler3 instead.
109
- */
110
- readonly compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647";
111
63
  readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
112
64
  readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
113
65
  readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
@@ -147,10 +99,6 @@ declare const _addressesRegistry: {
147
99
  readonly 8453: {
148
100
  readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
149
101
  readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
150
- /**
151
- * @deprecated All bundles should use Bundler3 instead.
152
- */
153
- readonly bundler: "0x23055618898e202386e6c13955a58D3C68200BFB";
154
102
  readonly bundler3: {
155
103
  readonly bundler3: "0x6BFd8137e702540E7A42B74178A4a49Ba43920C4";
156
104
  readonly generalAdapter1: "0xb98c948CFA24072e58935BC004a8A7b376AE746A";
@@ -159,18 +107,6 @@ declare const _addressesRegistry: {
159
107
  readonly compoundV3MigrationAdapter: "0x85D4812Ef92c040d4270eD8547b6835e41FbbB70";
160
108
  readonly aaveV3CoreMigrationAdapter: "0xb27Aa2a964eAd5ed661D86974b37e4fB995b36f5";
161
109
  };
162
- /**
163
- * @deprecated All bundles should use Bundler3 instead.
164
- */
165
- readonly compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223";
166
- /**
167
- * @deprecated All bundles should use Bundler3 instead.
168
- */
169
- readonly aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108";
170
- /**
171
- * @deprecated All bundles should use Bundler3 instead.
172
- */
173
- readonly compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA";
174
110
  readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
175
111
  readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
176
112
  readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
@@ -456,6 +392,7 @@ declare const _addressesRegistry: {
456
392
  readonly chainlinkOracleFactory: "0xeb476f124FaD625178759d13557A72394A6f9aF5";
457
393
  readonly preLiquidationFactory: "0x1b6782Ac7A859503cE953FBf4736311CC335B8f0";
458
394
  readonly wNative: "0x5555555555555555555555555555555555555555";
395
+ readonly usdc: "0xb88339CB7199b77E23DB6E890353E22632Ba630f";
459
396
  };
460
397
  readonly 1329: {
461
398
  readonly morpho: "0xc9cDAc20FCeAAF616f7EB0bb6Cd2c69dcfa9094c";
@@ -809,10 +746,6 @@ export declare let addressesRegistry: {
809
746
  readonly 1: {
810
747
  readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
811
748
  readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
812
- /**
813
- * @deprecated All bundles should use Bundler3 instead.
814
- */
815
- readonly bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077";
816
749
  readonly bundler3: {
817
750
  readonly bundler3: "0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245";
818
751
  readonly generalAdapter1: "0x4A6c312ec70E8747a587EE860a0353cd42Be0aE0";
@@ -826,26 +759,6 @@ export declare let addressesRegistry: {
826
759
  readonly aaveV3EtherFiMigrationAdapter: "0x4011dc6581fA05F9B0c7A12AdCd676e2b1a59ca3";
827
760
  readonly aaveV3OptimizerMigrationAdapter: "0x9e2ea2d5785598a163D569D795f286F5C55ad972";
828
761
  };
829
- /**
830
- * @deprecated All bundles should use Bundler3 instead.
831
- */
832
- readonly aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c";
833
- /**
834
- * @deprecated All bundles should use Bundler3 instead.
835
- */
836
- readonly aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76";
837
- /**
838
- * @deprecated All bundles should use Bundler3 instead.
839
- */
840
- readonly aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC";
841
- /**
842
- * @deprecated All bundles should use Bundler3 instead.
843
- */
844
- readonly compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558";
845
- /**
846
- * @deprecated All bundles should use Bundler3 instead.
847
- */
848
- readonly compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647";
849
762
  readonly adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC";
850
763
  readonly publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D";
851
764
  readonly metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24";
@@ -885,10 +798,6 @@ export declare let addressesRegistry: {
885
798
  readonly 8453: {
886
799
  readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
887
800
  readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
888
- /**
889
- * @deprecated All bundles should use Bundler3 instead.
890
- */
891
- readonly bundler: "0x23055618898e202386e6c13955a58D3C68200BFB";
892
801
  readonly bundler3: {
893
802
  readonly bundler3: "0x6BFd8137e702540E7A42B74178A4a49Ba43920C4";
894
803
  readonly generalAdapter1: "0xb98c948CFA24072e58935BC004a8A7b376AE746A";
@@ -897,18 +806,6 @@ export declare let addressesRegistry: {
897
806
  readonly compoundV3MigrationAdapter: "0x85D4812Ef92c040d4270eD8547b6835e41FbbB70";
898
807
  readonly aaveV3CoreMigrationAdapter: "0xb27Aa2a964eAd5ed661D86974b37e4fB995b36f5";
899
808
  };
900
- /**
901
- * @deprecated All bundles should use Bundler3 instead.
902
- */
903
- readonly compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223";
904
- /**
905
- * @deprecated All bundles should use Bundler3 instead.
906
- */
907
- readonly aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108";
908
- /**
909
- * @deprecated All bundles should use Bundler3 instead.
910
- */
911
- readonly compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA";
912
809
  readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
913
810
  readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
914
811
  readonly metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918";
@@ -1194,6 +1091,7 @@ export declare let addressesRegistry: {
1194
1091
  readonly chainlinkOracleFactory: "0xeb476f124FaD625178759d13557A72394A6f9aF5";
1195
1092
  readonly preLiquidationFactory: "0x1b6782Ac7A859503cE953FBf4736311CC335B8f0";
1196
1093
  readonly wNative: "0x5555555555555555555555555555555555555555";
1094
+ readonly usdc: "0xb88339CB7199b77E23DB6E890353E22632Ba630f";
1197
1095
  };
1198
1096
  readonly 1329: {
1199
1097
  readonly morpho: "0xc9cDAc20FCeAAF616f7EB0bb6Cd2c69dcfa9094c";
package/lib/addresses.js CHANGED
@@ -20,10 +20,6 @@ const _addressesRegistry = {
20
20
  [chain_js_1.ChainId.EthMainnet]: {
21
21
  morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
22
22
  permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
23
- /**
24
- * @deprecated All bundles should use Bundler3 instead.
25
- */
26
- bundler: "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077",
27
23
  bundler3: {
28
24
  bundler3: "0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245",
29
25
  generalAdapter1: "0x4A6c312ec70E8747a587EE860a0353cd42Be0aE0",
@@ -37,26 +33,6 @@ const _addressesRegistry = {
37
33
  aaveV3EtherFiMigrationAdapter: "0x4011dc6581fA05F9B0c7A12AdCd676e2b1a59ca3",
38
34
  aaveV3OptimizerMigrationAdapter: "0x9e2ea2d5785598a163D569D795f286F5C55ad972",
39
35
  },
40
- /**
41
- * @deprecated All bundles should use Bundler3 instead.
42
- */
43
- aaveV3OptimizerBundler: "0x16F38d2E764E7BeBF625a8E995b34968226D2F9c",
44
- /**
45
- * @deprecated All bundles should use Bundler3 instead.
46
- */
47
- aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76",
48
- /**
49
- * @deprecated All bundles should use Bundler3 instead.
50
- */
51
- aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC",
52
- /**
53
- * @deprecated All bundles should use Bundler3 instead.
54
- */
55
- compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558",
56
- /**
57
- * @deprecated All bundles should use Bundler3 instead.
58
- */
59
- compoundV2Bundler: "0x26bF52a84360Ad3d01d7CDc28FC2dDC04d8c8647",
60
36
  adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC",
61
37
  publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D",
62
38
  metaMorphoFactory: "0x1897A8997241C1cD4bD0698647e4EB7213535c24",
@@ -102,10 +78,6 @@ const _addressesRegistry = {
102
78
  [chain_js_1.ChainId.BaseMainnet]: {
103
79
  morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
104
80
  permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
105
- /**
106
- * @deprecated All bundles should use Bundler3 instead.
107
- */
108
- bundler: "0x23055618898e202386e6c13955a58D3C68200BFB",
109
81
  bundler3: {
110
82
  bundler3: "0x6BFd8137e702540E7A42B74178A4a49Ba43920C4",
111
83
  generalAdapter1: "0xb98c948CFA24072e58935BC004a8A7b376AE746A",
@@ -114,18 +86,6 @@ const _addressesRegistry = {
114
86
  compoundV3MigrationAdapter: "0x85D4812Ef92c040d4270eD8547b6835e41FbbB70",
115
87
  aaveV3CoreMigrationAdapter: "0xb27Aa2a964eAd5ed661D86974b37e4fB995b36f5",
116
88
  },
117
- /**
118
- * @deprecated All bundles should use Bundler3 instead.
119
- */
120
- compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223",
121
- /**
122
- * @deprecated All bundles should use Bundler3 instead.
123
- */
124
- aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108",
125
- /**
126
- * @deprecated All bundles should use Bundler3 instead.
127
- */
128
- compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA",
129
89
  adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687",
130
90
  publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
131
91
  metaMorphoFactory: "0xFf62A7c278C62eD665133147129245053Bbf5918",
@@ -421,6 +381,8 @@ const _addressesRegistry = {
421
381
  chainlinkOracleFactory: "0xeb476f124FaD625178759d13557A72394A6f9aF5",
422
382
  preLiquidationFactory: "0x1b6782Ac7A859503cE953FBf4736311CC335B8f0",
423
383
  wNative: "0x5555555555555555555555555555555555555555",
384
+ // Must implement USDC permit version 2 (otherwise breaks permit signatures).
385
+ usdc: "0xb88339CB7199b77E23DB6E890353E22632Ba630f",
424
386
  },
425
387
  [chain_js_1.ChainId.SeiMainnet]: {
426
388
  morpho: "0xc9cDAc20FCeAAF616f7EB0bb6Cd2c69dcfa9094c",
@@ -88,19 +88,9 @@ export declare class Market implements IMarket {
88
88
  */
89
89
  get utilization(): bigint;
90
90
  /**
91
- * The market's Annual Percentage Yield (APY) at the IRM's target utilization rate, if applicable (scaled by WAD).
91
+ * The market's Annual Percentage Yield (APY) at the IRM's target utilization rate, if applicable.
92
92
  */
93
- get apyAtTarget(): bigint | undefined;
94
- /**
95
- * Returns the rate at which interest accrued for suppliers of this market,
96
- * since the last time the market was updated (scaled by WAD).
97
- * @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
98
- */
99
- get supplyRate(): bigint;
100
- /**
101
- * @deprecated Use `avgBorrowRate` instead.
102
- */
103
- get borrowRate(): bigint;
93
+ get apyAtTarget(): number | undefined;
104
94
  /**
105
95
  * Returns the instantaneous rate at which interest accrues for borrowers of this market,
106
96
  * if `accrueInterest` was called immediately onchain (scaled by WAD).
@@ -127,19 +117,15 @@ export declare class Market implements IMarket {
127
117
  */
128
118
  get avgBorrowRate(): bigint;
129
119
  /**
130
- * The market's current, instantaneous supply-side Annual Percentage Yield (APY) (scaled by WAD).
120
+ * The market's current, instantaneous supply-side Annual Percentage Yield (APY).
131
121
  * If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
132
122
  */
133
- get supplyApy(): bigint;
123
+ get supplyApy(): number;
134
124
  /**
135
- * The market's current, instantaneous borrow-side Annual Percentage Yield (APY) (scaled by WAD).
125
+ * The market's current, instantaneous borrow-side Annual Percentage Yield (APY).
136
126
  * If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
137
127
  */
138
- get borrowApy(): bigint;
139
- /**
140
- * @deprecated Use `getEndBorrowRate(timestamp)` instead.
141
- */
142
- getBorrowRate(timestamp?: BigIntish): bigint;
128
+ get borrowApy(): number;
143
129
  /**
144
130
  * Returns the instantaneous rate at which interest accrues for borrowers of this market,
145
131
  * at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
@@ -173,36 +159,44 @@ export declare class Market implements IMarket {
173
159
  };
174
160
  /**
175
161
  * The market's instantaneous borrow-side Annual Percentage Yield (APY) at the given timestamp,
176
- * if the state remains unchanged (not accrued) (scaled by WAD).
162
+ * if the state remains unchanged (not accrued).
177
163
  * @param timestamp The timestamp at which to calculate the borrow APY.
178
164
  * Must be greater than or equal to `lastUpdate`.
179
165
  * Defaults to `Time.timestamp()` (returns the current borrow APY).
180
166
  */
181
- getBorrowApy(timestamp?: BigIntish): bigint;
167
+ getBorrowApy(timestamp?: BigIntish): number;
182
168
  /**
183
169
  * The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
184
- * if the state remains unchanged (not accrued) (scaled by WAD).
170
+ * if the state remains unchanged (not accrued).
185
171
  * @param timestamp The timestamp at which to calculate the supply APY.
186
172
  * Must be greater than or equal to `lastUpdate`.
187
173
  * Defaults to `Time.timestamp()` (returns the current supply APY).
188
174
  */
189
- getSupplyApy(timestamp?: BigIntish): bigint;
175
+ getSupplyApy(timestamp?: BigIntish): number;
190
176
  /**
191
177
  * The market's experienced borrow-side Annual Percentage Yield (APY),
192
- * if interest was to be accrued at the given timestamp (scaled by WAD).
178
+ * if interest was to be accrued at the given timestamp.
193
179
  * @param timestamp The timestamp at which to calculate the borrow APY.
194
180
  * Must be greater than or equal to `lastUpdate`.
195
181
  * Defaults to `Time.timestamp()` (returns the current borrow APY).
196
182
  */
197
- getAvgBorrowApy(timestamp?: BigIntish): bigint;
183
+ getAvgBorrowApy(timestamp?: BigIntish): number;
184
+ /**
185
+ * Returns the average rate at which interest _would_ accrue for suppliers of this market,
186
+ * if `accrueInterest` was called at the given timestamp (scaled by WAD).
187
+ * @param timestamp The timestamp at which to calculate the average supply rate.
188
+ * Must be greater than or equal to `lastUpdate`.
189
+ * Defaults to `Time.timestamp()` (returns the current average supply rate).
190
+ */
191
+ getAvgSupplyRate(timestamp?: BigIntish): bigint;
198
192
  /**
199
193
  * The market's experienced supply-side Annual Percentage Yield (APY),
200
- * if interest was to be accrued at the given timestamp (scaled by WAD).
194
+ * if interest was to be accrued at the given timestamp.
201
195
  * @param timestamp The timestamp at which to calculate the supply APY.
202
196
  * Must be greater than or equal to `lastUpdate`.
203
197
  * Defaults to `Time.timestamp()` (returns the current supply APY).
204
198
  */
205
- getAvgSupplyApy(timestamp?: BigIntish): bigint;
199
+ getAvgSupplyApy(timestamp?: BigIntish): number;
206
200
  /**
207
201
  * Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
208
202
  * @param timestamp The timestamp at which to accrue interest.
@@ -87,27 +87,13 @@ class Market {
87
87
  return MarketUtils_js_1.MarketUtils.getUtilization(this);
88
88
  }
89
89
  /**
90
- * The market's Annual Percentage Yield (APY) at the IRM's target utilization rate, if applicable (scaled by WAD).
90
+ * The market's Annual Percentage Yield (APY) at the IRM's target utilization rate, if applicable.
91
91
  */
92
92
  get apyAtTarget() {
93
93
  if (this.rateAtTarget == null)
94
94
  return;
95
95
  return MarketUtils_js_1.MarketUtils.rateToApy(this.rateAtTarget);
96
96
  }
97
- /**
98
- * Returns the rate at which interest accrued for suppliers of this market,
99
- * since the last time the market was updated (scaled by WAD).
100
- * @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
101
- */
102
- get supplyRate() {
103
- return MarketUtils_js_1.MarketUtils.getSupplyRate(this.avgBorrowRate, this);
104
- }
105
- /**
106
- * @deprecated Use `avgBorrowRate` instead.
107
- */
108
- get borrowRate() {
109
- return this.getAccrualBorrowRates().avgBorrowRate;
110
- }
111
97
  /**
112
98
  * Returns the instantaneous rate at which interest accrues for borrowers of this market,
113
99
  * if `accrueInterest` was called immediately onchain (scaled by WAD).
@@ -138,25 +124,19 @@ class Market {
138
124
  return this.getAccrualBorrowRates().avgBorrowRate;
139
125
  }
140
126
  /**
141
- * The market's current, instantaneous supply-side Annual Percentage Yield (APY) (scaled by WAD).
127
+ * The market's current, instantaneous supply-side Annual Percentage Yield (APY).
142
128
  * If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
143
129
  */
144
130
  get supplyApy() {
145
131
  return this.getSupplyApy();
146
132
  }
147
133
  /**
148
- * The market's current, instantaneous borrow-side Annual Percentage Yield (APY) (scaled by WAD).
134
+ * The market's current, instantaneous borrow-side Annual Percentage Yield (APY).
149
135
  * If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
150
136
  */
151
137
  get borrowApy() {
152
138
  return this.getBorrowApy();
153
139
  }
154
- /**
155
- * @deprecated Use `getEndBorrowRate(timestamp)` instead.
156
- */
157
- getBorrowRate(timestamp = morpho_ts_1.Time.timestamp()) {
158
- return this.getAccrualBorrowRates(timestamp).endBorrowRate;
159
- }
160
140
  /**
161
141
  * Returns the instantaneous rate at which interest accrues for borrowers of this market,
162
142
  * at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
@@ -204,7 +184,7 @@ class Market {
204
184
  }
205
185
  /**
206
186
  * The market's instantaneous borrow-side Annual Percentage Yield (APY) at the given timestamp,
207
- * if the state remains unchanged (not accrued) (scaled by WAD).
187
+ * if the state remains unchanged (not accrued).
208
188
  * @param timestamp The timestamp at which to calculate the borrow APY.
209
189
  * Must be greater than or equal to `lastUpdate`.
210
190
  * Defaults to `Time.timestamp()` (returns the current borrow APY).
@@ -215,18 +195,18 @@ class Market {
215
195
  }
216
196
  /**
217
197
  * The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
218
- * if the state remains unchanged (not accrued) (scaled by WAD).
198
+ * if the state remains unchanged (not accrued).
219
199
  * @param timestamp The timestamp at which to calculate the supply APY.
220
200
  * Must be greater than or equal to `lastUpdate`.
221
201
  * Defaults to `Time.timestamp()` (returns the current supply APY).
222
202
  */
223
203
  getSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
224
- const borrowApy = this.getBorrowApy(timestamp);
225
- return index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowApy, this.utilization), index_js_1.MathLib.WAD - this.fee);
204
+ const borrowRate = this.getEndBorrowRate(timestamp);
205
+ return MarketUtils_js_1.MarketUtils.rateToApy(index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowRate, this.utilization), index_js_1.MathLib.WAD - this.fee));
226
206
  }
227
207
  /**
228
208
  * The market's experienced borrow-side Annual Percentage Yield (APY),
229
- * if interest was to be accrued at the given timestamp (scaled by WAD).
209
+ * if interest was to be accrued at the given timestamp.
230
210
  * @param timestamp The timestamp at which to calculate the borrow APY.
231
211
  * Must be greater than or equal to `lastUpdate`.
232
212
  * Defaults to `Time.timestamp()` (returns the current borrow APY).
@@ -235,16 +215,26 @@ class Market {
235
215
  const borrowRate = this.getAvgBorrowRate(timestamp);
236
216
  return MarketUtils_js_1.MarketUtils.rateToApy(borrowRate);
237
217
  }
218
+ /**
219
+ * Returns the average rate at which interest _would_ accrue for suppliers of this market,
220
+ * if `accrueInterest` was called at the given timestamp (scaled by WAD).
221
+ * @param timestamp The timestamp at which to calculate the average supply rate.
222
+ * Must be greater than or equal to `lastUpdate`.
223
+ * Defaults to `Time.timestamp()` (returns the current average supply rate).
224
+ */
225
+ getAvgSupplyRate(timestamp = morpho_ts_1.Time.timestamp()) {
226
+ const borrowRate = this.getAvgBorrowRate(timestamp);
227
+ return index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowRate, this.utilization), index_js_1.MathLib.WAD - this.fee);
228
+ }
238
229
  /**
239
230
  * The market's experienced supply-side Annual Percentage Yield (APY),
240
- * if interest was to be accrued at the given timestamp (scaled by WAD).
231
+ * if interest was to be accrued at the given timestamp.
241
232
  * @param timestamp The timestamp at which to calculate the supply APY.
242
233
  * Must be greater than or equal to `lastUpdate`.
243
234
  * Defaults to `Time.timestamp()` (returns the current supply APY).
244
235
  */
245
236
  getAvgSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
246
- const borrowApy = this.getAvgBorrowApy(timestamp);
247
- return index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowApy, this.utilization), index_js_1.MathLib.WAD - this.fee);
237
+ return MarketUtils_js_1.MarketUtils.rateToApy(this.getAvgSupplyRate(timestamp));
248
238
  }
249
239
  /**
250
240
  * Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
@@ -26,29 +26,11 @@ export declare namespace MarketUtils {
26
26
  totalBorrowAssets: BigIntish;
27
27
  }): bigint;
28
28
  /**
29
- * Returns the rate at which interest accrued for suppliers on the corresponding market,
30
- * since the last time the market was updated (scaled by WAD).
31
- * @param borrowRate The average borrow rate since the last market update (scaled by WAD).
32
- * @param market The market state.
33
- * @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
34
- */
35
- function getSupplyRate(borrowRate: BigIntish, { utilization, fee }: {
36
- utilization: BigIntish;
37
- fee: BigIntish;
38
- }): bigint;
39
- /**
40
- * Returns the per-second rate continuously compounded over the given period, as calculated in Morpho Blue (scaled by WAD).
41
- * @param rate The per-second rate to compound (scaled by WAD).
42
- * @param period The period to compound the rate over (in seconds). Defaults to 1 year.
43
- * @deprecated The compounded rate is inaccurate if rate * period >> 0. If interested in the APY, use `rateToApy` instead.
44
- */
45
- function compoundRate(rate: BigIntish, period?: BigIntish): bigint;
46
- /**
47
- * Returns the per-second rate continuously compounded over a year (scaled by WAD),
29
+ * Returns the per-second rate continuously compounded over a year,
48
30
  * as calculated in Morpho Blue assuming the market is frequently accrued onchain.
49
- * @param rate The per-second rate to compound annually (scaled by WAD).
31
+ * @param rate The per-second rate to compound annually.
50
32
  */
51
- function rateToApy(rate: BigIntish): bigint;
33
+ function rateToApy(rate: BigIntish): number;
52
34
  /**
53
35
  * Returns the interest accrued on both sides of the given market
54
36
  * as well as the supply shares minted to the fee recipient.
@@ -6,7 +6,6 @@ const utils_1 = require("@noble/hashes/utils");
6
6
  const viem_1 = require("viem");
7
7
  const constants_js_1 = require("../constants.js");
8
8
  const index_js_1 = require("../math/index.js");
9
- const utils_js_1 = require("../utils.js");
10
9
  /**
11
10
  * Namespace of utility functions to ease market-related calculations.
12
11
  */
@@ -52,35 +51,12 @@ var MarketUtils;
52
51
  }
53
52
  MarketUtils.getUtilization = getUtilization;
54
53
  /**
55
- * Returns the rate at which interest accrued for suppliers on the corresponding market,
56
- * since the last time the market was updated (scaled by WAD).
57
- * @param borrowRate The average borrow rate since the last market update (scaled by WAD).
58
- * @param market The market state.
59
- * @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
60
- */
61
- function getSupplyRate(borrowRate, { utilization, fee }) {
62
- const borrowRateWithoutFees = index_js_1.MathLib.wMulUp(borrowRate, utilization);
63
- return index_js_1.MathLib.wMulUp(borrowRateWithoutFees, index_js_1.MathLib.WAD - BigInt(fee));
64
- }
65
- MarketUtils.getSupplyRate = getSupplyRate;
66
- /**
67
- * Returns the per-second rate continuously compounded over the given period, as calculated in Morpho Blue (scaled by WAD).
68
- * @param rate The per-second rate to compound (scaled by WAD).
69
- * @param period The period to compound the rate over (in seconds). Defaults to 1 year.
70
- * @deprecated The compounded rate is inaccurate if rate * period >> 0. If interested in the APY, use `rateToApy` instead.
71
- */
72
- function compoundRate(rate, period = constants_js_1.SECONDS_PER_YEAR) {
73
- return index_js_1.MathLib.wTaylorCompounded(rate, period);
74
- }
75
- MarketUtils.compoundRate = compoundRate;
76
- /**
77
- * Returns the per-second rate continuously compounded over a year (scaled by WAD),
54
+ * Returns the per-second rate continuously compounded over a year,
78
55
  * as calculated in Morpho Blue assuming the market is frequently accrued onchain.
79
- * @param rate The per-second rate to compound annually (scaled by WAD).
56
+ * @param rate The per-second rate to compound annually.
80
57
  */
81
- // TODO: return a Number for APYs.
82
58
  function rateToApy(rate) {
83
- return (0, utils_js_1.safeParseNumber)(Math.expm1(+(0, viem_1.formatEther)(BigInt(rate) * constants_js_1.SECONDS_PER_YEAR)));
59
+ return Math.expm1(+(0, viem_1.formatEther)(BigInt(rate) * constants_js_1.SECONDS_PER_YEAR));
84
60
  }
85
61
  MarketUtils.rateToApy = rateToApy;
86
62
  /**
package/lib/types.d.ts CHANGED
@@ -23,5 +23,4 @@ export declare enum TransactionType {
23
23
  export type Loadable<T> = T | undefined;
24
24
  export type Failable<T> = T | null;
25
25
  export type Fetchable<T> = Failable<Loadable<T>>;
26
- export declare function isFetched<T>(v: Fetchable<T>): v is T;
27
26
  export declare const isMarketId: (value: unknown) => value is MarketId;
package/lib/types.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isMarketId = exports.TransactionType = void 0;
4
- exports.isFetched = isFetched;
5
4
  /**
6
5
  * The possible transaction type on the Blue contract
7
6
  */
@@ -14,9 +13,5 @@ var TransactionType;
14
13
  TransactionType["Borrow"] = "Borrow";
15
14
  TransactionType["Repay"] = "Repay";
16
15
  })(TransactionType || (exports.TransactionType = TransactionType = {}));
17
- // TODO: replace with isDefined
18
- function isFetched(v) {
19
- return v !== undefined && v !== null;
20
- }
21
16
  const isMarketId = (value) => typeof value === "string" && /^0x[0-9A-Fa-f]{64}$/.test(value);
22
17
  exports.isMarketId = isMarketId;
package/lib/utils.d.ts CHANGED
@@ -11,5 +11,3 @@ export interface CapacityLimit {
11
11
  value: bigint;
12
12
  limiter: CapacityLimitReason;
13
13
  }
14
- export declare const safeParseNumber: (value: number, decimals?: number) => bigint;
15
- export declare const safeParseUnits: (strValue: string, decimals?: number) => bigint;
package/lib/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.safeParseUnits = exports.safeParseNumber = exports.CapacityLimitReason = void 0;
3
+ exports.CapacityLimitReason = void 0;
4
4
  var CapacityLimitReason;
5
5
  (function (CapacityLimitReason) {
6
6
  CapacityLimitReason["liquidity"] = "Liquidity";
@@ -11,67 +11,3 @@ var CapacityLimitReason;
11
11
  CapacityLimitReason["vaultV2_absoluteCap"] = "VaultV2_AbsoluteCap";
12
12
  CapacityLimitReason["vaultV2_relativeCap"] = "VaultV2_RelativeCap";
13
13
  })(CapacityLimitReason || (exports.CapacityLimitReason = CapacityLimitReason = {}));
14
- // Alternative to Number.toFixed that doesn't use scientific notation for excessively small or large numbers.
15
- const toFixed = (x, decimals) => new Intl.NumberFormat("en-US", {
16
- style: "decimal",
17
- useGrouping: false,
18
- maximumFractionDigits: decimals,
19
- minimumFractionDigits: decimals,
20
- }).format(x);
21
- const safeParseNumber = (value, decimals = 18) => (0, exports.safeParseUnits)(toFixed(value, decimals), decimals);
22
- exports.safeParseNumber = safeParseNumber;
23
- const safeParseUnits = (strValue, decimals = 18) => {
24
- if (!/[-+]?[0-9]*\.?[0-9]+/.test(strValue))
25
- throw Error(`invalid number: ${strValue}`);
26
- let [whole, dec = ""] = strValue.split(".");
27
- dec = dec.slice(0, decimals);
28
- return parseUnits([whole || "0", dec].filter((v) => v.length > 0).join("."), decimals);
29
- };
30
- exports.safeParseUnits = safeParseUnits;
31
- /**
32
- * Multiplies a string representation of a number by a given exponent of base 10 (10exponent).
33
- *
34
- * - Docs: https://viem.sh/docs/utilities/parseUnits
35
- *
36
- * @example
37
- * import { parseUnits } from 'viem'
38
- *
39
- * parseUnits('420', 9)
40
- * // 420000000000n
41
- */
42
- // TODO: get rid of this copy.
43
- function parseUnits(value, decimals) {
44
- let [integer, fraction = "0"] = value.split(".");
45
- const negative = integer.startsWith("-");
46
- if (negative)
47
- integer = integer.slice(1);
48
- // trim trailing zeros.
49
- fraction = fraction.replace(/(0+)$/, "");
50
- // round off if the fraction is larger than the number of decimals.
51
- if (decimals === 0) {
52
- if (Math.round(Number(`.${fraction}`)) === 1)
53
- integer = `${BigInt(integer) + 1n}`;
54
- fraction = "";
55
- }
56
- else if (fraction.length > decimals) {
57
- const [left, unit, right] = [
58
- fraction.slice(0, decimals - 1),
59
- fraction.slice(decimals - 1, decimals),
60
- fraction.slice(decimals),
61
- ];
62
- const rounded = Math.round(Number(`${unit}.${right}`));
63
- if (rounded > 9)
64
- fraction = `${BigInt(left) + BigInt(1)}0`.padStart(left.length + 1, "0");
65
- else
66
- fraction = `${left}${rounded}`;
67
- if (fraction.length > decimals) {
68
- fraction = fraction.slice(1);
69
- integer = `${BigInt(integer) + 1n}`;
70
- }
71
- fraction = fraction.slice(0, decimals);
72
- }
73
- else {
74
- fraction = fraction.padEnd(decimals, "0");
75
- }
76
- return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
77
- }
@@ -149,28 +149,34 @@ export declare class AccrualVault extends Vault implements IAccrualVault {
149
149
  get liquidity(): bigint;
150
150
  /**
151
151
  * The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
152
- * weighted-averaged over its market deposits, before deducting the performance fee (scaled by WAD).
152
+ * weighted-averaged over its market deposits, before deducting the performance fee.
153
153
  * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
154
154
  */
155
- get apy(): bigint;
155
+ get apy(): number;
156
156
  /**
157
157
  * The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
158
- * weighted-averaged over its market deposits, after deducting the performance fee (scaled by WAD).
159
- * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
158
+ * weighted-averaged over its market deposits, after deducting the performance fee.
159
+ * If interested in the APY at a specific timestamp, use `getNetApy(timestamp)` instead.
160
+ */
161
+ get netApy(): number;
162
+ /**
163
+ * The MetaMorpho vault's per-second rate at which interest _would_ accrue,
164
+ * weighted-averaged over its market deposits, before deducting the performance fee,
165
+ * if interest was to be accrued on each market at the given timestamp.
160
166
  */
161
- get netApy(): bigint;
167
+ private _getAvgRate;
162
168
  /**
163
169
  * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
164
170
  * weighted-averaged over its market deposits, before deducting the performance fee,
165
- * if interest was to be accrued on each market at the given timestamp (scaled by WAD).
171
+ * if interest was to be accrued on each market at the given timestamp.
166
172
  */
167
- getApy(timestamp?: BigIntish): bigint;
173
+ getApy(timestamp?: BigIntish): number;
168
174
  /**
169
175
  * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
170
176
  * weighted-averaged over its market deposits, after deducting the performance fee,
171
- * if interest was to be accrued on each market at the given timestamp (scaled by WAD).
177
+ * if interest was to be accrued on each market at the given timestamp.
172
178
  */
173
- getNetApy(timestamp?: BigIntish): bigint;
179
+ getNetApy(timestamp?: BigIntish): number;
174
180
  getAllocationProportion(marketId: MarketId): bigint;
175
181
  /**
176
182
  * Returns the deposit capacity limit of a given amount of assets on the vault.
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccrualVault = exports.Vault = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
- const index_js_1 = require("../math/index.js");
6
- const index_js_2 = require("../token/index.js");
5
+ const index_js_1 = require("../market/index.js");
6
+ const index_js_2 = require("../math/index.js");
7
+ const index_js_3 = require("../token/index.js");
7
8
  const utils_js_1 = require("../utils.js");
8
9
  const VaultMarketAllocation_js_1 = require("./VaultMarketAllocation.js");
9
- class Vault extends index_js_2.VaultToken {
10
+ class Vault extends index_js_3.VaultToken {
10
11
  /**
11
12
  * The MetaMorpho vault's owner address.
12
13
  */
@@ -93,7 +94,7 @@ class Vault extends index_js_2.VaultToken {
93
94
  * The amount of interest in assets accrued since the last interaction with the vault.
94
95
  */
95
96
  get totalInterest() {
96
- return index_js_1.MathLib.zeroFloorSub(this.totalAssets, this.lastTotalAssets);
97
+ return index_js_2.MathLib.zeroFloorSub(this.totalAssets, this.lastTotalAssets);
97
98
  }
98
99
  toAssets(shares, rounding = "Down") {
99
100
  return this._unwrap(shares, rounding);
@@ -155,7 +156,7 @@ class AccrualVault extends Vault {
155
156
  }
156
157
  /**
157
158
  * The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
158
- * weighted-averaged over its market deposits, before deducting the performance fee (scaled by WAD).
159
+ * weighted-averaged over its market deposits, before deducting the performance fee.
159
160
  * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
160
161
  */
161
162
  get apy() {
@@ -163,32 +164,42 @@ class AccrualVault extends Vault {
163
164
  }
164
165
  /**
165
166
  * The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
166
- * weighted-averaged over its market deposits, after deducting the performance fee (scaled by WAD).
167
- * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
167
+ * weighted-averaged over its market deposits, after deducting the performance fee.
168
+ * If interested in the APY at a specific timestamp, use `getNetApy(timestamp)` instead.
168
169
  */
169
170
  get netApy() {
170
171
  return this.getNetApy();
171
172
  }
172
173
  /**
173
- * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
174
+ * The MetaMorpho vault's per-second rate at which interest _would_ accrue,
174
175
  * weighted-averaged over its market deposits, before deducting the performance fee,
175
- * if interest was to be accrued on each market at the given timestamp (scaled by WAD).
176
+ * if interest was to be accrued on each market at the given timestamp.
176
177
  */
177
- getApy(timestamp = morpho_ts_1.Time.timestamp()) {
178
+ _getAvgRate(timestamp = morpho_ts_1.Time.timestamp()) {
178
179
  if (this.totalAssets === 0n)
179
180
  return 0n;
180
181
  return (this.allocations
181
182
  .values()
182
183
  .reduce((total, { position }) => total +
183
- position.market.getAvgSupplyApy(timestamp) * position.supplyAssets, 0n) / this.totalAssets);
184
+ position.market.getAvgSupplyRate(timestamp) * position.supplyAssets, 0n) / this.totalAssets);
185
+ }
186
+ /**
187
+ * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
188
+ * weighted-averaged over its market deposits, before deducting the performance fee,
189
+ * if interest was to be accrued on each market at the given timestamp.
190
+ */
191
+ getApy(timestamp = morpho_ts_1.Time.timestamp()) {
192
+ if (this.totalAssets === 0n)
193
+ return 0;
194
+ return index_js_1.MarketUtils.rateToApy(this._getAvgRate(timestamp));
184
195
  }
185
196
  /**
186
197
  * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
187
198
  * weighted-averaged over its market deposits, after deducting the performance fee,
188
- * if interest was to be accrued on each market at the given timestamp (scaled by WAD).
199
+ * if interest was to be accrued on each market at the given timestamp.
189
200
  */
190
201
  getNetApy(timestamp = morpho_ts_1.Time.timestamp()) {
191
- return index_js_1.MathLib.wMulDown(this.getApy(timestamp), index_js_1.MathLib.WAD - this.fee);
202
+ return index_js_1.MarketUtils.rateToApy(index_js_2.MathLib.wMulDown(this._getAvgRate(timestamp), index_js_2.MathLib.WAD - this.fee));
192
203
  }
193
204
  getAllocationProportion(marketId) {
194
205
  if (this.totalAssets === 0n)
@@ -196,7 +207,7 @@ class AccrualVault extends Vault {
196
207
  const allocation = this.allocations.get(marketId);
197
208
  if (!allocation)
198
209
  return 0n;
199
- return index_js_1.MathLib.wDivDown(allocation.position.supplyAssets, this.totalAssets);
210
+ return index_js_2.MathLib.wDivDown(allocation.position.supplyAssets, this.totalAssets);
200
211
  }
201
212
  /**
202
213
  * Returns the deposit capacity limit of a given amount of assets on the vault.
@@ -222,10 +233,10 @@ class AccrualVault extends Vault {
222
233
  assets = BigInt(assets);
223
234
  const suppliable = this.allocations
224
235
  .values()
225
- .reduce((total, { config: { cap }, position: { marketId, supplyAssets } }) => index_js_1.MathLib.min(total +
236
+ .reduce((total, { config: { cap }, position: { marketId, supplyAssets } }) => index_js_2.MathLib.min(total +
226
237
  (this.supplyQueue.includes(marketId)
227
- ? index_js_1.MathLib.zeroFloorSub(cap, supplyAssets)
228
- : 0n), index_js_1.MathLib.MAX_UINT_256), 0n);
238
+ ? index_js_2.MathLib.zeroFloorSub(cap, supplyAssets)
239
+ : 0n), index_js_2.MathLib.MAX_UINT_256), 0n);
229
240
  if (assets > suppliable)
230
241
  return {
231
242
  value: suppliable,
@@ -268,10 +279,10 @@ class AccrualVault extends Vault {
268
279
  };
269
280
  }));
270
281
  if (vault.lostAssets != null) {
271
- vault.lostAssets += index_js_1.MathLib.max(vault.lastTotalAssets - vault.lostAssets - vault.totalAssets, 0n);
282
+ vault.lostAssets += index_js_2.MathLib.max(vault.lastTotalAssets - vault.lostAssets - vault.totalAssets, 0n);
272
283
  vault.totalAssets += vault.lostAssets;
273
284
  }
274
- const feeAssets = index_js_1.MathLib.wMulDown(vault.totalInterest, vault.fee);
285
+ const feeAssets = index_js_2.MathLib.wMulDown(vault.totalInterest, vault.fee);
275
286
  vault.totalAssets -= feeAssets;
276
287
  const feeShares = vault.toShares(feeAssets, "Down");
277
288
  vault.totalAssets += feeAssets;
@@ -1,7 +1,7 @@
1
1
  import type { AccrualPosition } from "../position/index.js";
2
- import type { VaultMarketConfig } from "./VaultMarketConfig.js";
2
+ import { type IVaultMarketConfig, VaultMarketConfig } from "./VaultMarketConfig.js";
3
3
  export interface IVaultMarketAllocation {
4
- config: VaultMarketConfig;
4
+ config: IVaultMarketConfig;
5
5
  position: AccrualPosition;
6
6
  }
7
7
  export declare class VaultMarketAllocation implements IVaultMarketAllocation {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultMarketAllocation = void 0;
4
4
  const index_js_1 = require("../math/index.js");
5
+ const VaultMarketConfig_js_1 = require("./VaultMarketConfig.js");
5
6
  class VaultMarketAllocation {
6
7
  /**
7
8
  * The vault's configuration on the corresponding market.
@@ -12,7 +13,7 @@ class VaultMarketAllocation {
12
13
  */
13
14
  position;
14
15
  constructor({ config, position }) {
15
- this.config = config;
16
+ this.config = new VaultMarketConfig_js_1.VaultMarketConfig(config);
16
17
  this.position = position;
17
18
  }
18
19
  get vault() {
@@ -88,14 +88,15 @@ class AccrualVaultV2 extends VaultV2 {
88
88
  value: absoluteMaxDeposit,
89
89
  limiter: utils_1.CapacityLimitReason.vaultV2_absoluteCap,
90
90
  };
91
- // `relativeCap` can be set lower than `allocation / totalAssets`.
92
- const relativeMaxDeposit = math_1.MathLib.zeroFloorSub(math_1.MathLib.wMulDown(this.totalAssets, relativeCap), allocation);
93
- if (liquidityAdapterLimit.value > relativeMaxDeposit &&
94
- relativeCap !== math_1.MathLib.WAD)
95
- return {
96
- value: relativeMaxDeposit,
97
- limiter: utils_1.CapacityLimitReason.vaultV2_relativeCap,
98
- };
91
+ if (relativeCap !== math_1.MathLib.WAD) {
92
+ // `relativeCap` can be set lower than `allocation / totalAssets`.
93
+ const relativeMaxDeposit = math_1.MathLib.zeroFloorSub(math_1.MathLib.wMulDown(this.totalAssets, relativeCap), allocation);
94
+ if (liquidityAdapterLimit.value > relativeMaxDeposit)
95
+ return {
96
+ value: relativeMaxDeposit,
97
+ limiter: utils_1.CapacityLimitReason.vaultV2_relativeCap,
98
+ };
99
+ }
99
100
  }
100
101
  return liquidityAdapterLimit;
101
102
  }
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": "5.2.0-next.0",
4
+ "version": "5.2.0-next.1",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"