@morpho-org/blue-sdk 4.5.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.
@@ -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.5.0",
4
+ "version": "4.5.1",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"