@morpho-org/blue-sdk 4.4.0 → 4.5.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.
@@ -107,19 +107,35 @@ export declare class Market implements IMarket {
107
107
  * @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
108
108
  */
109
109
  get supplyRate(): bigint;
110
+ /**
111
+ * @deprecated Use `avgBorrowRate` instead.
112
+ */
113
+ get borrowRate(): bigint;
114
+ /**
115
+ * Returns the instantaneous rate at which interest accrues for borrowers of this market,
116
+ * if `accrueInterest` was called immediately onchain (scaled by WAD).
117
+ *
118
+ * Even if `accrueInterest` is called immediately onchain,
119
+ * the instantaneous rate only corresponds to an intermediary value used to calculate
120
+ * the actual average rate experienced by borrowers of this market.
121
+ *
122
+ * If interested in the instantaneous rate experienced by existing market actors at a specific timestamp,
123
+ * use `getEndBorrowRate(timestamp)`, `getBorrowApy(timestamp)`, or `getSupplyApy(timestamp)` instead.
124
+ */
125
+ get endBorrowRate(): bigint;
110
126
  /**
111
127
  * Returns the average rate at which interest _would_ accrue from `lastUpdate`
112
128
  * till now, if `accrueInterest` was called immediately onchain (scaled by WAD).
113
129
  * If `accrueInterest` was just called, the average rate equals the instantaneous rate,
114
130
  * so it is equivalent to `getBorrowRate(lastUpdate)`.
115
131
  *
116
- * In most cases, `accrueInterest` will not be called immediately onchain, so the
117
- * average rate doesn't correspond to anything "real".
132
+ * In most cases, `accrueInterest` will not be called immediately onchain,
133
+ * so the average rate is only an intermediary value.
118
134
  *
119
- * If interested in the instantaneous rate experienced by existing market actors at a specific timestamp,
120
- * use `getBorrowRate(timestamp)`, `getBorrowApy(timestamp)`, or `getSupplyApy(timestamp)` instead.
135
+ * If interested in the average rate experienced by existing market actors at a specific timestamp,
136
+ * use `getAvgBorrowRate(timestamp)`, `getAvgBorrowApy(timestamp)`, or `getAvgSupplyApy(timestamp)` instead.
121
137
  */
122
- get borrowRate(): bigint;
138
+ get avgBorrowRate(): bigint;
123
139
  /**
124
140
  * The market's current, instantaneous supply-side Annual Percentage Yield (APY) (scaled by WAD).
125
141
  * If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
@@ -130,20 +146,36 @@ export declare class Market implements IMarket {
130
146
  * If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
131
147
  */
132
148
  get borrowApy(): bigint;
149
+ /**
150
+ * @deprecated Use `getEndBorrowRate(timestamp)` instead.
151
+ */
152
+ getBorrowRate(timestamp?: BigIntish): bigint;
133
153
  /**
134
154
  * Returns the instantaneous rate at which interest accrues for borrowers of this market,
135
155
  * at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
136
156
  * It is fundamentally different from the rate at which interest is paid by borrowers to lenders in the case of an interest accrual,
137
157
  * as in the case of the AdaptiveCurveIRM, the (approximated) average rate since the last update is used instead.
138
- * @param timestamp The timestamp at which to calculate the borrow rate. Must be greater than or equal to `lastUpdate`. Defaults to `Time.timestamp()` (returns the current borrow rate).
158
+ * @param timestamp The timestamp at which to calculate the borrow rate.
159
+ * Must be greater than or equal to `lastUpdate`.
160
+ * Defaults to `Time.timestamp()` (returns the current borrow rate).
139
161
  */
140
- getBorrowRate(timestamp?: BigIntish): bigint;
162
+ getEndBorrowRate(timestamp?: BigIntish): bigint;
141
163
  /**
142
- * Returns the rate at which interest accrues for borrowers of this market,
143
- * at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
144
- * @param timestamp The timestamp at which to calculate the accrual borrow rate. Must be greater than or equal to `lastUpdate`. Defaults to `Time.timestamp()` (returns the current borrow rate).
164
+ * Returns the average rate at which interest _would_ accrue for borrowers of this market,
165
+ * if `accrueInterest` was called at the given timestamp (scaled by WAD).
166
+ * @param timestamp The timestamp at which to calculate the average borrow rate.
167
+ * Must be greater than or equal to `lastUpdate`.
168
+ * Defaults to `Time.timestamp()` (returns the current average borrow rate).
145
169
  */
146
- protected getAccrualBorrowRate(timestamp?: BigIntish): {
170
+ getAvgBorrowRate(timestamp?: BigIntish): bigint;
171
+ /**
172
+ * Returns the rates that _would_ apply to interest accrual for borrowers of this market,
173
+ * if `accrueInterest` was called at the given timestamp (scaled by WAD).
174
+ * @param timestamp The timestamp at which to calculate the accrual borrow rate.
175
+ * Must be greater than or equal to `lastUpdate`.
176
+ * Defaults to `Time.timestamp()` (returns the current accrual borrow rate).
177
+ */
178
+ protected getAccrualBorrowRates(timestamp?: BigIntish): {
147
179
  elapsed: bigint;
148
180
  avgBorrowRate: bigint;
149
181
  endBorrowRate: bigint;
@@ -152,18 +184,40 @@ export declare class Market implements IMarket {
152
184
  /**
153
185
  * The market's instantaneous borrow-side Annual Percentage Yield (APY) at the given timestamp,
154
186
  * if the state remains unchanged (not accrued) (scaled by WAD).
155
- * @param timestamp The timestamp at which to calculate the borrow APY. Must be greater than or equal to `lastUpdate`. Defaults to `Time.timestamp()` (returns the current borrow APY).
187
+ * @param timestamp The timestamp at which to calculate the borrow APY.
188
+ * Must be greater than or equal to `lastUpdate`.
189
+ * Defaults to `Time.timestamp()` (returns the current borrow APY).
156
190
  */
157
191
  getBorrowApy(timestamp?: BigIntish): bigint;
158
192
  /**
159
193
  * The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
160
194
  * if the state remains unchanged (not accrued) (scaled by WAD).
161
- * @param timestamp The timestamp at which to calculate the supply APY. Must be greater than or equal to `lastUpdate`. Defaults to `Time.timestamp()` (returns the current supply APY).
195
+ * @param timestamp The timestamp at which to calculate the supply APY.
196
+ * Must be greater than or equal to `lastUpdate`.
197
+ * Defaults to `Time.timestamp()` (returns the current supply APY).
162
198
  */
163
199
  getSupplyApy(timestamp?: BigIntish): bigint;
200
+ /**
201
+ * The market's experienced borrow-side Annual Percentage Yield (APY),
202
+ * if interest was to be accrued at the given timestamp (scaled by WAD).
203
+ * @param timestamp The timestamp at which to calculate the borrow APY.
204
+ * Must be greater than or equal to `lastUpdate`.
205
+ * Defaults to `Time.timestamp()` (returns the current borrow APY).
206
+ */
207
+ getAvgBorrowApy(timestamp?: BigIntish): bigint;
208
+ /**
209
+ * The market's experienced supply-side Annual Percentage Yield (APY),
210
+ * if interest was to be accrued at the given timestamp (scaled by WAD).
211
+ * @param timestamp The timestamp at which to calculate the supply APY.
212
+ * Must be greater than or equal to `lastUpdate`.
213
+ * Defaults to `Time.timestamp()` (returns the current supply APY).
214
+ */
215
+ getAvgSupplyApy(timestamp?: BigIntish): bigint;
164
216
  /**
165
217
  * Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
166
- * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to `lastUpdate`. Defaults to `lastUpdate` (returns a copy of the market).
218
+ * @param timestamp The timestamp at which to accrue interest.
219
+ * Must be greater than or equal to `lastUpdate`.
220
+ * Defaults to `lastUpdate` (returns a copy of the market).
167
221
  */
168
222
  accrueInterest(timestamp?: BigIntish): Market;
169
223
  supply(assets: bigint, shares: bigint, timestamp?: BigIntish): {
@@ -107,7 +107,27 @@ class Market {
107
107
  * @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
108
108
  */
109
109
  get supplyRate() {
110
- return MarketUtils_js_1.MarketUtils.getSupplyRate(this.borrowRate, this);
110
+ return MarketUtils_js_1.MarketUtils.getSupplyRate(this.avgBorrowRate, this);
111
+ }
112
+ /**
113
+ * @deprecated Use `avgBorrowRate` instead.
114
+ */
115
+ get borrowRate() {
116
+ return this.getAccrualBorrowRates().avgBorrowRate;
117
+ }
118
+ /**
119
+ * Returns the instantaneous rate at which interest accrues for borrowers of this market,
120
+ * if `accrueInterest` was called immediately onchain (scaled by WAD).
121
+ *
122
+ * Even if `accrueInterest` is called immediately onchain,
123
+ * the instantaneous rate only corresponds to an intermediary value used to calculate
124
+ * the actual average rate experienced by borrowers of this market.
125
+ *
126
+ * If interested in the instantaneous rate experienced by existing market actors at a specific timestamp,
127
+ * use `getEndBorrowRate(timestamp)`, `getBorrowApy(timestamp)`, or `getSupplyApy(timestamp)` instead.
128
+ */
129
+ get endBorrowRate() {
130
+ return this.getAccrualBorrowRates().endBorrowRate;
111
131
  }
112
132
  /**
113
133
  * Returns the average rate at which interest _would_ accrue from `lastUpdate`
@@ -115,14 +135,14 @@ class Market {
115
135
  * If `accrueInterest` was just called, the average rate equals the instantaneous rate,
116
136
  * so it is equivalent to `getBorrowRate(lastUpdate)`.
117
137
  *
118
- * In most cases, `accrueInterest` will not be called immediately onchain, so the
119
- * average rate doesn't correspond to anything "real".
138
+ * In most cases, `accrueInterest` will not be called immediately onchain,
139
+ * so the average rate is only an intermediary value.
120
140
  *
121
- * If interested in the instantaneous rate experienced by existing market actors at a specific timestamp,
122
- * use `getBorrowRate(timestamp)`, `getBorrowApy(timestamp)`, or `getSupplyApy(timestamp)` instead.
141
+ * If interested in the average rate experienced by existing market actors at a specific timestamp,
142
+ * use `getAvgBorrowRate(timestamp)`, `getAvgBorrowApy(timestamp)`, or `getAvgSupplyApy(timestamp)` instead.
123
143
  */
124
- get borrowRate() {
125
- return this.getAccrualBorrowRate().avgBorrowRate;
144
+ get avgBorrowRate() {
145
+ return this.getAccrualBorrowRates().avgBorrowRate;
126
146
  }
127
147
  /**
128
148
  * The market's current, instantaneous supply-side Annual Percentage Yield (APY) (scaled by WAD).
@@ -138,29 +158,42 @@ class Market {
138
158
  get borrowApy() {
139
159
  return this.getBorrowApy();
140
160
  }
161
+ /**
162
+ * @deprecated Use `getEndBorrowRate(timestamp)` instead.
163
+ */
164
+ getBorrowRate(timestamp = morpho_ts_1.Time.timestamp()) {
165
+ return this.getAccrualBorrowRates(timestamp).endBorrowRate;
166
+ }
141
167
  /**
142
168
  * Returns the instantaneous rate at which interest accrues for borrowers of this market,
143
169
  * at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
144
170
  * It is fundamentally different from the rate at which interest is paid by borrowers to lenders in the case of an interest accrual,
145
171
  * as in the case of the AdaptiveCurveIRM, the (approximated) average rate since the last update is used instead.
146
- * @param timestamp The timestamp at which to calculate the borrow rate. Must be greater than or equal to `lastUpdate`. Defaults to `Time.timestamp()` (returns the current borrow rate).
172
+ * @param timestamp The timestamp at which to calculate the borrow rate.
173
+ * Must be greater than or equal to `lastUpdate`.
174
+ * Defaults to `Time.timestamp()` (returns the current borrow rate).
147
175
  */
148
- getBorrowRate(timestamp = morpho_ts_1.Time.timestamp()) {
149
- if (this.rateAtTarget == null)
150
- return 0n;
151
- timestamp = BigInt(timestamp);
152
- const elapsed = timestamp - this.lastUpdate;
153
- if (elapsed < 0n)
154
- throw new errors_js_1.BlueErrors.InvalidInterestAccrual(this.id, timestamp, this.lastUpdate);
155
- const { endBorrowRate } = index_js_1.AdaptiveCurveIrmLib.getBorrowRate(this.utilization, this.rateAtTarget, elapsed);
156
- return endBorrowRate;
176
+ getEndBorrowRate(timestamp = morpho_ts_1.Time.timestamp()) {
177
+ return this.getAccrualBorrowRates(timestamp).endBorrowRate;
157
178
  }
158
179
  /**
159
- * Returns the rate at which interest accrues for borrowers of this market,
160
- * at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
161
- * @param timestamp The timestamp at which to calculate the accrual borrow rate. Must be greater than or equal to `lastUpdate`. Defaults to `Time.timestamp()` (returns the current borrow rate).
180
+ * Returns the average rate at which interest _would_ accrue for borrowers of this market,
181
+ * if `accrueInterest` was called at the given timestamp (scaled by WAD).
182
+ * @param timestamp The timestamp at which to calculate the average borrow rate.
183
+ * Must be greater than or equal to `lastUpdate`.
184
+ * Defaults to `Time.timestamp()` (returns the current average borrow rate).
185
+ */
186
+ getAvgBorrowRate(timestamp = morpho_ts_1.Time.timestamp()) {
187
+ return this.getAccrualBorrowRates(timestamp).avgBorrowRate;
188
+ }
189
+ /**
190
+ * Returns the rates that _would_ apply to interest accrual for borrowers of this market,
191
+ * if `accrueInterest` was called at the given timestamp (scaled by WAD).
192
+ * @param timestamp The timestamp at which to calculate the accrual borrow rate.
193
+ * Must be greater than or equal to `lastUpdate`.
194
+ * Defaults to `Time.timestamp()` (returns the current accrual borrow rate).
162
195
  */
163
- getAccrualBorrowRate(timestamp = morpho_ts_1.Time.timestamp()) {
196
+ getAccrualBorrowRates(timestamp = morpho_ts_1.Time.timestamp()) {
164
197
  timestamp = BigInt(timestamp);
165
198
  const elapsed = timestamp - this.lastUpdate;
166
199
  if (elapsed < 0n)
@@ -179,28 +212,56 @@ class Market {
179
212
  /**
180
213
  * The market's instantaneous borrow-side Annual Percentage Yield (APY) at the given timestamp,
181
214
  * if the state remains unchanged (not accrued) (scaled by WAD).
182
- * @param timestamp The timestamp at which to calculate the borrow APY. Must be greater than or equal to `lastUpdate`. Defaults to `Time.timestamp()` (returns the current borrow APY).
215
+ * @param timestamp The timestamp at which to calculate the borrow APY.
216
+ * Must be greater than or equal to `lastUpdate`.
217
+ * Defaults to `Time.timestamp()` (returns the current borrow APY).
183
218
  */
184
219
  getBorrowApy(timestamp = morpho_ts_1.Time.timestamp()) {
185
- const borrowRate = this.getBorrowRate(timestamp);
220
+ const borrowRate = this.getEndBorrowRate(timestamp);
186
221
  return MarketUtils_js_1.MarketUtils.compoundRate(borrowRate);
187
222
  }
188
223
  /**
189
224
  * The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
190
225
  * if the state remains unchanged (not accrued) (scaled by WAD).
191
- * @param timestamp The timestamp at which to calculate the supply APY. Must be greater than or equal to `lastUpdate`. Defaults to `Time.timestamp()` (returns the current supply APY).
226
+ * @param timestamp The timestamp at which to calculate the supply APY.
227
+ * Must be greater than or equal to `lastUpdate`.
228
+ * Defaults to `Time.timestamp()` (returns the current supply APY).
192
229
  */
193
230
  getSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
194
231
  const borrowApy = this.getBorrowApy(timestamp);
195
232
  return index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowApy, this.utilization), index_js_1.MathLib.WAD - this.fee);
196
233
  }
234
+ /**
235
+ * The market's experienced borrow-side Annual Percentage Yield (APY),
236
+ * if interest was to be accrued at the given timestamp (scaled by WAD).
237
+ * @param timestamp The timestamp at which to calculate the borrow APY.
238
+ * Must be greater than or equal to `lastUpdate`.
239
+ * Defaults to `Time.timestamp()` (returns the current borrow APY).
240
+ */
241
+ getAvgBorrowApy(timestamp = morpho_ts_1.Time.timestamp()) {
242
+ const borrowRate = this.getAvgBorrowRate(timestamp);
243
+ return MarketUtils_js_1.MarketUtils.compoundRate(borrowRate);
244
+ }
245
+ /**
246
+ * The market's experienced supply-side Annual Percentage Yield (APY),
247
+ * if interest was to be accrued at the given timestamp (scaled by WAD).
248
+ * @param timestamp The timestamp at which to calculate the supply APY.
249
+ * Must be greater than or equal to `lastUpdate`.
250
+ * Defaults to `Time.timestamp()` (returns the current supply APY).
251
+ */
252
+ getAvgSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
253
+ const borrowApy = this.getAvgBorrowApy(timestamp);
254
+ return index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowApy, this.utilization), index_js_1.MathLib.WAD - this.fee);
255
+ }
197
256
  /**
198
257
  * Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
199
- * @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to `lastUpdate`. Defaults to `lastUpdate` (returns a copy of the market).
258
+ * @param timestamp The timestamp at which to accrue interest.
259
+ * Must be greater than or equal to `lastUpdate`.
260
+ * Defaults to `lastUpdate` (returns a copy of the market).
200
261
  */
201
262
  accrueInterest(timestamp = this.lastUpdate) {
202
263
  timestamp = BigInt(timestamp);
203
- const { elapsed, avgBorrowRate, endRateAtTarget } = this.getAccrualBorrowRate(timestamp);
264
+ const { elapsed, avgBorrowRate, endRateAtTarget } = this.getAccrualBorrowRates(timestamp);
204
265
  const { interest, feeShares } = MarketUtils_js_1.MarketUtils.getAccruedInterest(avgBorrowRate, this, elapsed);
205
266
  return new Market({
206
267
  ...this,
@@ -148,29 +148,29 @@ export declare class AccrualVault extends Vault implements IAccrualVault {
148
148
  */
149
149
  get liquidity(): bigint;
150
150
  /**
151
- * The MetaMorpho vault's APY on its assets averaged over its market deposits,
152
- * before deducting the performance fee, at the time of each market's last update (scaled by WAD).
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).
153
153
  * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
154
154
  */
155
155
  get apy(): bigint;
156
156
  /**
157
- * The MetaMorpho vault's APY on its assets averaged over its market deposits,
158
- * after deducting the performance fee, at the time of each market's last update (scaled by WAD).
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
159
  * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
160
160
  */
161
161
  get netApy(): bigint;
162
162
  /**
163
- * The MetaMorpho vault's APY on its assets averaged over its market deposits,
164
- * before deducting the performance fee, at the given timestamp,
165
- * if the state of all the markets remains unchanged (not accrued) (scaled by WAD).
163
+ * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
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 (scaled by WAD).
166
166
  */
167
- getApy(timestamp: BigIntish): bigint;
167
+ getApy(timestamp?: BigIntish): bigint;
168
168
  /**
169
- * The MetaMorpho vault's APY on its assets averaged over its market deposits,
170
- * after deducting the performance fee, at the given timestamp,
171
- * if the state of all the markets remains unchanged (not accrued) (scaled by WAD).
169
+ * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
170
+ * 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).
172
172
  */
173
- getNetApy(timestamp: BigIntish): bigint;
173
+ getNetApy(timestamp?: BigIntish): bigint;
174
174
  getAllocationProportion(marketId: MarketId): bigint;
175
175
  getDepositCapacityLimit(assets: bigint): CapacityLimit;
176
176
  getWithdrawCapacityLimit(shares: bigint): CapacityLimit;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccrualVault = exports.Vault = void 0;
4
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
4
5
  const index_js_1 = require("../market/index.js");
5
6
  const index_js_2 = require("../math/index.js");
6
7
  const index_js_3 = require("../token/index.js");
@@ -153,44 +154,40 @@ class AccrualVault extends Vault {
153
154
  .reduce((total, { position }) => total + position.withdrawCapacityLimit.value, 0n);
154
155
  }
155
156
  /**
156
- * The MetaMorpho vault's APY on its assets averaged over its market deposits,
157
- * before deducting the performance fee, at the time of each market's last update (scaled by WAD).
157
+ * 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).
158
159
  * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
159
160
  */
160
161
  get apy() {
161
- if (this.totalAssets === 0n)
162
- return 0n;
163
- return (this.allocations
164
- .values()
165
- .reduce((total, { position }) => total + position.market.supplyApy * position.supplyAssets, 0n) / this.totalAssets);
162
+ return this.getApy();
166
163
  }
167
164
  /**
168
- * The MetaMorpho vault's APY on its assets averaged over its market deposits,
169
- * after deducting the performance fee, at the time of each market's last update (scaled by WAD).
165
+ * 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).
170
167
  * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
171
168
  */
172
169
  get netApy() {
173
- return index_js_2.MathLib.wMulDown(this.apy, index_js_2.MathLib.WAD - this.fee);
170
+ return this.getNetApy();
174
171
  }
175
172
  /**
176
- * The MetaMorpho vault's APY on its assets averaged over its market deposits,
177
- * before deducting the performance fee, at the given timestamp,
178
- * if the state of all the markets remains unchanged (not accrued) (scaled by WAD).
173
+ * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
174
+ * 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).
179
176
  */
180
- getApy(timestamp) {
177
+ getApy(timestamp = morpho_ts_1.Time.timestamp()) {
181
178
  if (this.totalAssets === 0n)
182
179
  return 0n;
183
180
  return (this.allocations
184
181
  .values()
185
182
  .reduce((total, { position }) => total +
186
- position.market.getSupplyApy(timestamp) * position.supplyAssets, 0n) / this.totalAssets);
183
+ position.market.getAvgSupplyApy(timestamp) * position.supplyAssets, 0n) / this.totalAssets);
187
184
  }
188
185
  /**
189
- * The MetaMorpho vault's APY on its assets averaged over its market deposits,
190
- * after deducting the performance fee, at the given timestamp,
191
- * if the state of all the markets remains unchanged (not accrued) (scaled by WAD).
186
+ * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
187
+ * 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).
192
189
  */
193
- getNetApy(timestamp) {
190
+ getNetApy(timestamp = morpho_ts_1.Time.timestamp()) {
194
191
  return index_js_2.MathLib.wMulDown(this.getApy(timestamp), index_js_2.MathLib.WAD - this.fee);
195
192
  }
196
193
  getAllocationProportion(marketId) {
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": "4.4.0",
4
+ "version": "4.5.1",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"