@morpho-org/blue-sdk 5.0.0 → 5.0.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.
@@ -127,12 +127,12 @@ export declare class Market implements IMarket {
127
127
  */
128
128
  get avgBorrowRate(): bigint;
129
129
  /**
130
- * The market's current, instantaneous supply-side Annual Percentage Yield (APY) (scaled by WAD).
130
+ * The market's current, instantaneous supply-side Annual Percentage Yield (APY).
131
131
  * If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
132
132
  */
133
- get supplyApy(): bigint;
133
+ get supplyApy(): number;
134
134
  /**
135
- * The market's current, instantaneous borrow-side Annual Percentage Yield (APY) (scaled by WAD).
135
+ * The market's current, instantaneous borrow-side Annual Percentage Yield (APY).
136
136
  * If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
137
137
  */
138
138
  get borrowApy(): number;
@@ -177,12 +177,12 @@ export declare class Market implements IMarket {
177
177
  getBorrowApy(timestamp?: BigIntish): number;
178
178
  /**
179
179
  * The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
180
- * if the state remains unchanged (not accrued) (scaled by WAD).
180
+ * if the state remains unchanged (not accrued).
181
181
  * @param timestamp The timestamp at which to calculate the supply APY.
182
182
  * Must be greater than or equal to `lastUpdate`.
183
183
  * Defaults to `Time.timestamp()` (returns the current supply APY).
184
184
  */
185
- getSupplyApy(timestamp?: BigIntish): bigint;
185
+ getSupplyApy(timestamp?: BigIntish): number;
186
186
  /**
187
187
  * The market's experienced borrow-side Annual Percentage Yield (APY),
188
188
  * if interest was to be accrued at the given timestamp.
@@ -193,12 +193,12 @@ export declare class Market implements IMarket {
193
193
  getAvgBorrowApy(timestamp?: BigIntish): number;
194
194
  /**
195
195
  * The market's experienced supply-side Annual Percentage Yield (APY),
196
- * if interest was to be accrued at the given timestamp (scaled by WAD).
196
+ * if interest was to be accrued at the given timestamp.
197
197
  * @param timestamp The timestamp at which to calculate the supply APY.
198
198
  * Must be greater than or equal to `lastUpdate`.
199
199
  * Defaults to `Time.timestamp()` (returns the current supply APY).
200
200
  */
201
- getAvgSupplyApy(timestamp?: BigIntish): bigint;
201
+ getAvgSupplyApy(timestamp?: BigIntish): number;
202
202
  /**
203
203
  * Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
204
204
  * @param timestamp The timestamp at which to accrue interest.
@@ -4,6 +4,7 @@ exports.Market = exports.CapacityLimitReason = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
5
  const errors_js_1 = require("../errors.js");
6
6
  const index_js_1 = require("../math/index.js");
7
+ const viem_1 = require("viem");
7
8
  const MarketParams_js_1 = require("./MarketParams.js");
8
9
  const MarketUtils_js_1 = require("./MarketUtils.js");
9
10
  var CapacityLimitReason;
@@ -131,14 +132,14 @@ class Market {
131
132
  return this.getAccrualBorrowRates().avgBorrowRate;
132
133
  }
133
134
  /**
134
- * The market's current, instantaneous supply-side Annual Percentage Yield (APY) (scaled by WAD).
135
+ * The market's current, instantaneous supply-side Annual Percentage Yield (APY).
135
136
  * If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
136
137
  */
137
138
  get supplyApy() {
138
139
  return this.getSupplyApy();
139
140
  }
140
141
  /**
141
- * The market's current, instantaneous borrow-side Annual Percentage Yield (APY) (scaled by WAD).
142
+ * The market's current, instantaneous borrow-side Annual Percentage Yield (APY).
142
143
  * If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
143
144
  */
144
145
  get borrowApy() {
@@ -202,14 +203,14 @@ class Market {
202
203
  }
203
204
  /**
204
205
  * The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
205
- * if the state remains unchanged (not accrued) (scaled by WAD).
206
+ * if the state remains unchanged (not accrued).
206
207
  * @param timestamp The timestamp at which to calculate the supply APY.
207
208
  * Must be greater than or equal to `lastUpdate`.
208
209
  * Defaults to `Time.timestamp()` (returns the current supply APY).
209
210
  */
210
211
  getSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
211
212
  const borrowApy = this.getBorrowApy(timestamp);
212
- return index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowApy, this.utilization), index_js_1.MathLib.WAD - this.fee);
213
+ return (borrowApy * +(0, viem_1.formatEther)(this.utilization) * (1 - +(0, viem_1.formatEther)(this.fee)));
213
214
  }
214
215
  /**
215
216
  * The market's experienced borrow-side Annual Percentage Yield (APY),
@@ -224,14 +225,14 @@ class Market {
224
225
  }
225
226
  /**
226
227
  * The market's experienced supply-side Annual Percentage Yield (APY),
227
- * if interest was to be accrued at the given timestamp (scaled by WAD).
228
+ * if interest was to be accrued at the given timestamp.
228
229
  * @param timestamp The timestamp at which to calculate the supply APY.
229
230
  * Must be greater than or equal to `lastUpdate`.
230
231
  * Defaults to `Time.timestamp()` (returns the current supply APY).
231
232
  */
232
233
  getAvgSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
233
234
  const borrowApy = this.getAvgBorrowApy(timestamp);
234
- return index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowApy, this.utilization), index_js_1.MathLib.WAD - this.fee);
235
+ return (borrowApy * +(0, viem_1.formatEther)(this.utilization) * (1 - +(0, viem_1.formatEther)(this.fee)));
235
236
  }
236
237
  /**
237
238
  * Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
@@ -149,28 +149,28 @@ 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).
158
+ * weighted-averaged over its market deposits, after deducting the performance fee.
159
159
  * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
160
160
  */
161
- get netApy(): bigint;
161
+ get netApy(): number;
162
162
  /**
163
163
  * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
164
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).
165
+ * if interest was to be accrued on each market at the given timestamp.
166
166
  */
167
- getApy(timestamp?: BigIntish): bigint;
167
+ getApy(timestamp?: BigIntish): number;
168
168
  /**
169
169
  * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
170
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).
171
+ * if interest was to be accrued on each market at the given timestamp.
172
172
  */
173
- getNetApy(timestamp?: BigIntish): bigint;
173
+ getNetApy(timestamp?: BigIntish): number;
174
174
  getAllocationProportion(marketId: MarketId): bigint;
175
175
  getDepositCapacityLimit(assets: bigint): CapacityLimit;
176
176
  getWithdrawCapacityLimit(shares: bigint): CapacityLimit;
@@ -5,6 +5,7 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
5
  const index_js_1 = require("../market/index.js");
6
6
  const index_js_2 = require("../math/index.js");
7
7
  const index_js_3 = require("../token/index.js");
8
+ const viem_1 = require("viem");
8
9
  const VaultMarketAllocation_js_1 = require("./VaultMarketAllocation.js");
9
10
  class Vault extends index_js_3.VaultToken {
10
11
  /**
@@ -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,7 +164,7 @@ 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
+ * weighted-averaged over its market deposits, after deducting the performance fee.
167
168
  * If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
168
169
  */
169
170
  get netApy() {
@@ -172,23 +173,24 @@ class AccrualVault extends Vault {
172
173
  /**
173
174
  * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
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
178
  getApy(timestamp = morpho_ts_1.Time.timestamp()) {
178
179
  if (this.totalAssets === 0n)
179
- return 0n;
180
+ return 0;
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.getAvgSupplyApy(timestamp) *
185
+ Number(position.supplyAssets), 0) / Number(this.totalAssets));
184
186
  }
185
187
  /**
186
188
  * The MetaMorpho vault's experienced Annual Percentage Yield (APY)
187
189
  * 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).
190
+ * if interest was to be accrued on each market at the given timestamp.
189
191
  */
190
192
  getNetApy(timestamp = morpho_ts_1.Time.timestamp()) {
191
- return index_js_2.MathLib.wMulDown(this.getApy(timestamp), index_js_2.MathLib.WAD - this.fee);
193
+ return this.getApy(timestamp) * (1 - +(0, viem_1.formatEther)(this.fee));
192
194
  }
193
195
  getAllocationProportion(marketId) {
194
196
  if (this.totalAssets === 0n)
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.0.0",
4
+ "version": "5.0.1",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -31,8 +31,8 @@
31
31
  "typescript": "^5.7.2",
32
32
  "viem": "^2.23.0",
33
33
  "vitest": "^3.0.5",
34
- "@morpho-org/morpho-ts": "^2.4.3",
35
- "@morpho-org/test": "^2.6.0"
34
+ "@morpho-org/test": "^2.6.0",
35
+ "@morpho-org/morpho-ts": "^2.4.3"
36
36
  },
37
37
  "scripts": {
38
38
  "prepublish": "$npm_execpath build",