@morpho-org/blue-sdk 3.0.2 → 3.0.4
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.
- package/lib/addresses.d.ts +13 -0
- package/lib/addresses.js +14 -0
- package/lib/chain.d.ts +2 -1
- package/lib/chain.js +8 -0
- package/lib/market/Market.d.ts +33 -3
- package/lib/market/Market.js +60 -8
- package/lib/market/MarketUtils.d.ts +1 -0
- package/lib/market/MarketUtils.js +1 -0
- package/lib/math/AdaptiveCurveIrmLib.d.ts +1 -0
- package/lib/math/AdaptiveCurveIrmLib.js +3 -1
- package/lib/vault/Vault.d.ts +18 -2
- package/lib/vault/Vault.js +27 -2
- package/package.json +1 -1
package/lib/addresses.d.ts
CHANGED
|
@@ -321,6 +321,19 @@ export declare const addressesRegistry: {
|
|
|
321
321
|
readonly preLiquidationFactory: "0xF184156Cf6Ad4D3dA7F6449D40755A0f9de97ef3";
|
|
322
322
|
readonly wNative: "0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1";
|
|
323
323
|
};
|
|
324
|
+
readonly 123420001114: {
|
|
325
|
+
readonly morpho: "0xc7CAd9B1377Eb8103397Cb07Cb5c4f03eb2eBEa8";
|
|
326
|
+
readonly bundler3: {
|
|
327
|
+
readonly bundler3: "0xc1A86b3a552C5a34e1ecc910341A64Cc89b2CB01";
|
|
328
|
+
readonly generalAdapter1: "0x86eaf48Fd73c1Aa30E801D01d0efFd731c3E5E85";
|
|
329
|
+
};
|
|
330
|
+
readonly adaptiveCurveIrm: "0xeEccdD33c0C06d7DDa31E3C4a1Cdb35a2A756246";
|
|
331
|
+
readonly publicAllocator: "0x1e145648DA9aC9d831B4F7931C06e9828083BD40";
|
|
332
|
+
readonly metaMorphoFactory: "0xa8CD521d42b716821D7ddD2Ca6a237087aA5b487";
|
|
333
|
+
readonly chainlinkOracleFactory: "0x24Bc64f44B429EEA86c8B1f9C03F54Ab0C6c0C15";
|
|
334
|
+
readonly preLiquidationFactory: "0x6C0155CC30f760DC49138B389F5B69F56eD08841";
|
|
335
|
+
readonly wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b";
|
|
336
|
+
};
|
|
324
337
|
};
|
|
325
338
|
export declare const addresses: Record<number, ChainAddresses>;
|
|
326
339
|
export type AddressLabel = DottedKeys<(typeof addressesRegistry)[ChainId]>;
|
package/lib/addresses.js
CHANGED
|
@@ -296,6 +296,19 @@ exports.addressesRegistry = {
|
|
|
296
296
|
preLiquidationFactory: "0xF184156Cf6Ad4D3dA7F6449D40755A0f9de97ef3",
|
|
297
297
|
wNative: "0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1",
|
|
298
298
|
},
|
|
299
|
+
[chain_js_1.ChainId.CampMainnet]: {
|
|
300
|
+
morpho: "0xc7CAd9B1377Eb8103397Cb07Cb5c4f03eb2eBEa8",
|
|
301
|
+
bundler3: {
|
|
302
|
+
bundler3: "0xc1A86b3a552C5a34e1ecc910341A64Cc89b2CB01",
|
|
303
|
+
generalAdapter1: "0x86eaf48Fd73c1Aa30E801D01d0efFd731c3E5E85",
|
|
304
|
+
},
|
|
305
|
+
adaptiveCurveIrm: "0xeEccdD33c0C06d7DDa31E3C4a1Cdb35a2A756246",
|
|
306
|
+
publicAllocator: "0x1e145648DA9aC9d831B4F7931C06e9828083BD40",
|
|
307
|
+
metaMorphoFactory: "0xa8CD521d42b716821D7ddD2Ca6a237087aA5b487",
|
|
308
|
+
chainlinkOracleFactory: "0x24Bc64f44B429EEA86c8B1f9C03F54Ab0C6c0C15",
|
|
309
|
+
preLiquidationFactory: "0x6C0155CC30f760DC49138B389F5B69F56eD08841",
|
|
310
|
+
wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b",
|
|
311
|
+
},
|
|
299
312
|
};
|
|
300
313
|
exports.addresses = exports.addressesRegistry;
|
|
301
314
|
const getChainAddresses = (chainId) => {
|
|
@@ -341,6 +354,7 @@ exports.unwrappedTokensMapping = {
|
|
|
341
354
|
[chain_js_1.ChainId.ModeMainnet]: {},
|
|
342
355
|
[chain_js_1.ChainId.CornMainnet]: {},
|
|
343
356
|
[chain_js_1.ChainId.PlumeMainnet]: {},
|
|
357
|
+
[chain_js_1.ChainId.CampMainnet]: {},
|
|
344
358
|
};
|
|
345
359
|
function getUnwrappedToken(wrappedToken, chainId) {
|
|
346
360
|
return exports.unwrappedTokensMapping[chainId][wrappedToken];
|
package/lib/chain.d.ts
CHANGED
package/lib/chain.js
CHANGED
|
@@ -18,6 +18,7 @@ var ChainId;
|
|
|
18
18
|
ChainId[ChainId["ModeMainnet"] = 34443] = "ModeMainnet";
|
|
19
19
|
ChainId[ChainId["CornMainnet"] = 21000000] = "CornMainnet";
|
|
20
20
|
ChainId[ChainId["PlumeMainnet"] = 98866] = "PlumeMainnet";
|
|
21
|
+
ChainId[ChainId["CampMainnet"] = 123420001114] = "CampMainnet";
|
|
21
22
|
})(ChainId || (exports.ChainId = ChainId = {}));
|
|
22
23
|
var ChainUtils;
|
|
23
24
|
(function (ChainUtils) {
|
|
@@ -139,5 +140,12 @@ var ChainUtils;
|
|
|
139
140
|
explorerUrl: "https://phoenix-explorer.plumenetwork.xyz",
|
|
140
141
|
identifier: "plume",
|
|
141
142
|
},
|
|
143
|
+
[ChainId.CampMainnet]: {
|
|
144
|
+
name: "Camp",
|
|
145
|
+
id: ChainId.CampMainnet,
|
|
146
|
+
nativeCurrency: { name: "Camp", symbol: "CAMP", decimals: 18 },
|
|
147
|
+
explorerUrl: "https://basecamp.cloud.blockscout.com/",
|
|
148
|
+
identifier: "camp",
|
|
149
|
+
},
|
|
142
150
|
};
|
|
143
151
|
})(ChainUtils || (exports.ChainUtils = ChainUtils = {}));
|
package/lib/market/Market.d.ts
CHANGED
|
@@ -104,21 +104,51 @@ export declare class Market implements IMarket {
|
|
|
104
104
|
/**
|
|
105
105
|
* Returns the rate at which interest accrued for suppliers of this market,
|
|
106
106
|
* since the last time the market was updated (scaled by WAD).
|
|
107
|
+
* @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
|
|
107
108
|
*/
|
|
108
109
|
get supplyRate(): bigint;
|
|
109
110
|
/**
|
|
110
|
-
* Returns the rate at which interest
|
|
111
|
+
* Returns the rate at which interest accrues for borrowers of this market,
|
|
111
112
|
* since the last time the market was updated (scaled by WAD).
|
|
113
|
+
* If interested in the rate at a specific timestamp, use `getAccrualBorrowRate(timestamp)` instead.
|
|
112
114
|
*/
|
|
113
115
|
get borrowRate(): bigint;
|
|
114
116
|
/**
|
|
115
|
-
* The market's supply-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
117
|
+
* The market's current, instantaneous supply-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
118
|
+
* If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
|
|
116
119
|
*/
|
|
117
120
|
get supplyApy(): bigint;
|
|
118
121
|
/**
|
|
119
|
-
* The market's borrow-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
122
|
+
* The market's current, instantaneous borrow-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
123
|
+
* If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
|
|
120
124
|
*/
|
|
121
125
|
get borrowApy(): bigint;
|
|
126
|
+
/**
|
|
127
|
+
* Returns the instantaneous rate at which interest accrues for borrowers of this market,
|
|
128
|
+
* at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
|
|
129
|
+
* It is fundamentally different from the rate at which interest is paid by borrowers to lenders in the case of an interest accrual,
|
|
130
|
+
* as in the case of the AdaptiveCurveIRM, the (approximated) average rate since the last update is used instead.
|
|
131
|
+
* @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).
|
|
132
|
+
*/
|
|
133
|
+
getBorrowRate(timestamp?: BigIntish): bigint;
|
|
134
|
+
/**
|
|
135
|
+
* Returns the rate at which interest accrues for borrowers of this market,
|
|
136
|
+
* at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
|
|
137
|
+
* @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).
|
|
138
|
+
*/
|
|
139
|
+
getAccrualBorrowRate(timestamp?: BigIntish): bigint;
|
|
140
|
+
/**
|
|
141
|
+
* The market's instantaneous borrow-side Annual Percentage Yield (APY) at the given timestamp,
|
|
142
|
+
* if the state remains unchanged (not accrued) (scaled by WAD).
|
|
143
|
+
* @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).
|
|
144
|
+
*/
|
|
145
|
+
getBorrowApy(timestamp?: BigIntish): bigint;
|
|
146
|
+
/**
|
|
147
|
+
* The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
|
|
148
|
+
* if the state remains unchanged (not accrued) (scaled by WAD).
|
|
149
|
+
* @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).
|
|
150
|
+
*/
|
|
151
|
+
getSupplyApy(timestamp?: BigIntish): bigint;
|
|
122
152
|
/**
|
|
123
153
|
* Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
|
|
124
154
|
* @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).
|
package/lib/market/Market.js
CHANGED
|
@@ -103,30 +103,82 @@ class Market {
|
|
|
103
103
|
/**
|
|
104
104
|
* Returns the rate at which interest accrued for suppliers of this market,
|
|
105
105
|
* since the last time the market was updated (scaled by WAD).
|
|
106
|
+
* @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
|
|
106
107
|
*/
|
|
107
108
|
get supplyRate() {
|
|
108
109
|
return MarketUtils_js_1.MarketUtils.getSupplyRate(this.borrowRate, this);
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
111
|
-
* Returns the rate at which interest
|
|
112
|
+
* Returns the rate at which interest accrues for borrowers of this market,
|
|
112
113
|
* since the last time the market was updated (scaled by WAD).
|
|
114
|
+
* If interested in the rate at a specific timestamp, use `getAccrualBorrowRate(timestamp)` instead.
|
|
113
115
|
*/
|
|
114
116
|
get borrowRate() {
|
|
115
|
-
|
|
116
|
-
return 0n;
|
|
117
|
-
return index_js_1.AdaptiveCurveIrmLib.getBorrowRate(this.utilization, this.rateAtTarget, 0n).avgBorrowRate;
|
|
117
|
+
return this.getAccrualBorrowRate();
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
|
-
* The market's supply-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
120
|
+
* The market's current, instantaneous supply-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
121
|
+
* If interested in the APY at a specific timestamp, use `getSupplyApy(timestamp)` instead.
|
|
121
122
|
*/
|
|
122
123
|
get supplyApy() {
|
|
123
|
-
return
|
|
124
|
+
return this.getSupplyApy();
|
|
124
125
|
}
|
|
125
126
|
/**
|
|
126
|
-
* The market's borrow-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
127
|
+
* The market's current, instantaneous borrow-side Annual Percentage Yield (APY) (scaled by WAD).
|
|
128
|
+
* If interested in the APY at a specific timestamp, use `getBorrowApy(timestamp)` instead.
|
|
127
129
|
*/
|
|
128
130
|
get borrowApy() {
|
|
129
|
-
return
|
|
131
|
+
return this.getBorrowApy();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns the instantaneous rate at which interest accrues for borrowers of this market,
|
|
135
|
+
* at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
|
|
136
|
+
* It is fundamentally different from the rate at which interest is paid by borrowers to lenders in the case of an interest accrual,
|
|
137
|
+
* 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).
|
|
139
|
+
*/
|
|
140
|
+
getBorrowRate(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
141
|
+
if (this.rateAtTarget == null)
|
|
142
|
+
return 0n;
|
|
143
|
+
timestamp = BigInt(timestamp);
|
|
144
|
+
const elapsed = timestamp - this.lastUpdate;
|
|
145
|
+
if (elapsed < 0n)
|
|
146
|
+
throw new errors_js_1.BlueErrors.InvalidInterestAccrual(this.id, timestamp, this.lastUpdate);
|
|
147
|
+
const { endBorrowRate } = index_js_1.AdaptiveCurveIrmLib.getBorrowRate(this.utilization, this.rateAtTarget, elapsed);
|
|
148
|
+
return endBorrowRate;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns the rate at which interest accrues for borrowers of this market,
|
|
152
|
+
* at the given timestamp, if the state remains unchanged (not accrued) (scaled by WAD).
|
|
153
|
+
* @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).
|
|
154
|
+
*/
|
|
155
|
+
getAccrualBorrowRate(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
156
|
+
if (this.rateAtTarget == null)
|
|
157
|
+
return 0n;
|
|
158
|
+
timestamp = BigInt(timestamp);
|
|
159
|
+
const elapsed = timestamp - this.lastUpdate;
|
|
160
|
+
if (elapsed < 0n)
|
|
161
|
+
throw new errors_js_1.BlueErrors.InvalidInterestAccrual(this.id, timestamp, this.lastUpdate);
|
|
162
|
+
const { avgBorrowRate } = index_js_1.AdaptiveCurveIrmLib.getBorrowRate(this.utilization, this.rateAtTarget, elapsed);
|
|
163
|
+
return avgBorrowRate;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The market's instantaneous borrow-side Annual Percentage Yield (APY) at the given timestamp,
|
|
167
|
+
* if the state remains unchanged (not accrued) (scaled by WAD).
|
|
168
|
+
* @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).
|
|
169
|
+
*/
|
|
170
|
+
getBorrowApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
171
|
+
const borrowRate = this.getBorrowRate(timestamp);
|
|
172
|
+
return MarketUtils_js_1.MarketUtils.compoundRate(borrowRate);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The market's instantaneous supply-side Annual Percentage Yield (APY) at the given timestamp,
|
|
176
|
+
* if the state remains unchanged (not accrued) (scaled by WAD).
|
|
177
|
+
* @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).
|
|
178
|
+
*/
|
|
179
|
+
getSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
180
|
+
const borrowApy = this.getBorrowApy(timestamp);
|
|
181
|
+
return index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowApy, this.utilization), index_js_1.MathLib.WAD - this.fee);
|
|
130
182
|
}
|
|
131
183
|
/**
|
|
132
184
|
* Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
|
|
@@ -30,6 +30,7 @@ export declare namespace MarketUtils {
|
|
|
30
30
|
* since the last time the market was updated (scaled by WAD).
|
|
31
31
|
* @param borrowRate The average borrow rate since the last market update (scaled by WAD).
|
|
32
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.
|
|
33
34
|
*/
|
|
34
35
|
function getSupplyRate(borrowRate: BigIntish, { utilization, fee }: {
|
|
35
36
|
utilization: BigIntish;
|
|
@@ -54,6 +54,7 @@ var MarketUtils;
|
|
|
54
54
|
* since the last time the market was updated (scaled by WAD).
|
|
55
55
|
* @param borrowRate The average borrow rate since the last market update (scaled by WAD).
|
|
56
56
|
* @param market The market state.
|
|
57
|
+
* @deprecated There's no such thing as a supply rate in Morpho. Only the supply APY is meaningful.
|
|
57
58
|
*/
|
|
58
59
|
function getSupplyRate(borrowRate, { utilization, fee }) {
|
|
59
60
|
const borrowRateWithoutFees = index_js_1.MathLib.wMulUp(borrowRate, utilization);
|
|
@@ -33,6 +33,7 @@ export declare namespace AdaptiveCurveIrmLib {
|
|
|
33
33
|
function wExp(x: BigIntish): bigint;
|
|
34
34
|
function getBorrowRate(startUtilization: BigIntish, startRateAtTarget: BigIntish, elapsed: BigIntish): {
|
|
35
35
|
avgBorrowRate: bigint;
|
|
36
|
+
endBorrowRate: bigint;
|
|
36
37
|
endRateAtTarget: bigint;
|
|
37
38
|
};
|
|
38
39
|
function getUtilizationAtBorrowRate(borrowRate: BigIntish, rateAtTarget: BigIntish): bigint;
|
|
@@ -109,9 +109,11 @@ var AdaptiveCurveIrmLib;
|
|
|
109
109
|
const coeff = err < 0
|
|
110
110
|
? MathLib_js_1.MathLib.WAD - MathLib_js_1.MathLib.wDivDown(MathLib_js_1.MathLib.WAD, AdaptiveCurveIrmLib.CURVE_STEEPNESS)
|
|
111
111
|
: AdaptiveCurveIrmLib.CURVE_STEEPNESS - MathLib_js_1.MathLib.WAD;
|
|
112
|
+
const _curve = (rateAtTarget) => MathLib_js_1.MathLib.wMulDown(MathLib_js_1.MathLib.wMulDown(coeff, err) + MathLib_js_1.MathLib.WAD, rateAtTarget);
|
|
112
113
|
// Non negative if avgRateAtTarget >= 0 because if err < 0, coeff <= 1.
|
|
113
114
|
return {
|
|
114
|
-
avgBorrowRate:
|
|
115
|
+
avgBorrowRate: _curve(avgRateAtTarget),
|
|
116
|
+
endBorrowRate: _curve(endRateAtTarget),
|
|
115
117
|
endRateAtTarget,
|
|
116
118
|
};
|
|
117
119
|
}
|
package/lib/vault/Vault.d.ts
CHANGED
|
@@ -148,13 +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,
|
|
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).
|
|
153
|
+
* If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
|
|
152
154
|
*/
|
|
153
155
|
get apy(): bigint;
|
|
154
156
|
/**
|
|
155
|
-
* The MetaMorpho vault's APY on its assets averaged over its market deposits,
|
|
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).
|
|
159
|
+
* If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
|
|
156
160
|
*/
|
|
157
161
|
get netApy(): bigint;
|
|
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).
|
|
166
|
+
*/
|
|
167
|
+
getApy(timestamp: BigIntish): bigint;
|
|
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).
|
|
172
|
+
*/
|
|
173
|
+
getNetApy(timestamp: BigIntish): bigint;
|
|
158
174
|
getAllocationProportion(marketId: MarketId): bigint;
|
|
159
175
|
getDepositCapacityLimit(assets: bigint): CapacityLimit;
|
|
160
176
|
getWithdrawCapacityLimit(shares: bigint): CapacityLimit;
|
package/lib/vault/Vault.js
CHANGED
|
@@ -153,7 +153,9 @@ class AccrualVault extends Vault {
|
|
|
153
153
|
.reduce((total, { position }) => total + position.withdrawCapacityLimit.value, 0n);
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
|
-
* The MetaMorpho vault's APY on its assets averaged over its market deposits,
|
|
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).
|
|
158
|
+
* If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
|
|
157
159
|
*/
|
|
158
160
|
get apy() {
|
|
159
161
|
if (this.totalAssets === 0n)
|
|
@@ -163,11 +165,34 @@ class AccrualVault extends Vault {
|
|
|
163
165
|
.reduce((total, { position }) => total + position.market.supplyApy * position.supplyAssets, 0n) / this.totalAssets);
|
|
164
166
|
}
|
|
165
167
|
/**
|
|
166
|
-
* The MetaMorpho vault's APY on its assets averaged over its market deposits,
|
|
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).
|
|
170
|
+
* If interested in the APY at a specific timestamp, use `getApy(timestamp)` instead.
|
|
167
171
|
*/
|
|
168
172
|
get netApy() {
|
|
169
173
|
return index_js_2.MathLib.wMulDown(this.apy, index_js_2.MathLib.WAD - this.fee);
|
|
170
174
|
}
|
|
175
|
+
/**
|
|
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).
|
|
179
|
+
*/
|
|
180
|
+
getApy(timestamp) {
|
|
181
|
+
if (this.totalAssets === 0n)
|
|
182
|
+
return 0n;
|
|
183
|
+
return (this.allocations
|
|
184
|
+
.values()
|
|
185
|
+
.reduce((total, { position }) => total +
|
|
186
|
+
position.market.getSupplyApy(timestamp) * position.supplyAssets, 0n) / this.totalAssets);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
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).
|
|
192
|
+
*/
|
|
193
|
+
getNetApy(timestamp) {
|
|
194
|
+
return index_js_2.MathLib.wMulDown(this.getApy(timestamp), index_js_2.MathLib.WAD - this.fee);
|
|
195
|
+
}
|
|
171
196
|
getAllocationProportion(marketId) {
|
|
172
197
|
if (this.totalAssets === 0n)
|
|
173
198
|
return 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": "3.0.
|
|
4
|
+
"version": "3.0.4",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|