@morpho-org/blue-sdk 5.1.0 → 5.1.2
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 +4 -0
- package/lib/addresses.js +2 -0
- package/lib/market/Market.d.ts +8 -0
- package/lib/market/Market.js +14 -5
- package/lib/vault/Vault.d.ts +7 -1
- package/lib/vault/Vault.js +16 -8
- package/lib/vault/VaultMarketAllocation.d.ts +2 -2
- package/lib/vault/VaultMarketAllocation.js +2 -1
- package/package.json +1 -1
package/lib/addresses.d.ts
CHANGED
|
@@ -396,6 +396,7 @@ declare const _addressesRegistry: {
|
|
|
396
396
|
};
|
|
397
397
|
readonly 1329: {
|
|
398
398
|
readonly morpho: "0xc9cDAc20FCeAAF616f7EB0bb6Cd2c69dcfa9094c";
|
|
399
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
399
400
|
readonly bundler3: {
|
|
400
401
|
readonly bundler3: "0xF9457356F18A3349Bb317Ac144c3Bcc62e5761aD";
|
|
401
402
|
readonly generalAdapter1: "0x02e0e71e145f254820B9D89c9E6068f08256F601";
|
|
@@ -406,6 +407,7 @@ declare const _addressesRegistry: {
|
|
|
406
407
|
readonly chainlinkOracleFactory: "0x4bD68c2FF3274207EC07ED281C915758b6F23F07";
|
|
407
408
|
readonly preLiquidationFactory: "0x65eD61058cEB4895B7d62437BaCEA39b04f6D27B";
|
|
408
409
|
readonly wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7";
|
|
410
|
+
readonly usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392";
|
|
409
411
|
};
|
|
410
412
|
};
|
|
411
413
|
export type ChainDeployments<Addresses = ChainAddresses> = {
|
|
@@ -1095,6 +1097,7 @@ export declare let addressesRegistry: {
|
|
|
1095
1097
|
};
|
|
1096
1098
|
readonly 1329: {
|
|
1097
1099
|
readonly morpho: "0xc9cDAc20FCeAAF616f7EB0bb6Cd2c69dcfa9094c";
|
|
1100
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
1098
1101
|
readonly bundler3: {
|
|
1099
1102
|
readonly bundler3: "0xF9457356F18A3349Bb317Ac144c3Bcc62e5761aD";
|
|
1100
1103
|
readonly generalAdapter1: "0x02e0e71e145f254820B9D89c9E6068f08256F601";
|
|
@@ -1105,6 +1108,7 @@ export declare let addressesRegistry: {
|
|
|
1105
1108
|
readonly chainlinkOracleFactory: "0x4bD68c2FF3274207EC07ED281C915758b6F23F07";
|
|
1106
1109
|
readonly preLiquidationFactory: "0x65eD61058cEB4895B7d62437BaCEA39b04f6D27B";
|
|
1107
1110
|
readonly wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7";
|
|
1111
|
+
readonly usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392";
|
|
1108
1112
|
};
|
|
1109
1113
|
};
|
|
1110
1114
|
export declare let addresses: Record<number, ChainAddresses>;
|
package/lib/addresses.js
CHANGED
|
@@ -386,6 +386,7 @@ const _addressesRegistry = {
|
|
|
386
386
|
},
|
|
387
387
|
[chain_js_1.ChainId.SeiMainnet]: {
|
|
388
388
|
morpho: "0xc9cDAc20FCeAAF616f7EB0bb6Cd2c69dcfa9094c",
|
|
389
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
389
390
|
bundler3: {
|
|
390
391
|
bundler3: "0xF9457356F18A3349Bb317Ac144c3Bcc62e5761aD",
|
|
391
392
|
generalAdapter1: "0x02e0e71e145f254820B9D89c9E6068f08256F601",
|
|
@@ -396,6 +397,7 @@ const _addressesRegistry = {
|
|
|
396
397
|
chainlinkOracleFactory: "0x4bD68c2FF3274207EC07ED281C915758b6F23F07",
|
|
397
398
|
preLiquidationFactory: "0x65eD61058cEB4895B7d62437BaCEA39b04f6D27B",
|
|
398
399
|
wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7",
|
|
400
|
+
usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392",
|
|
399
401
|
},
|
|
400
402
|
};
|
|
401
403
|
const _deployments = {
|
package/lib/market/Market.d.ts
CHANGED
|
@@ -191,6 +191,14 @@ export declare class Market implements IMarket {
|
|
|
191
191
|
* Defaults to `Time.timestamp()` (returns the current borrow APY).
|
|
192
192
|
*/
|
|
193
193
|
getAvgBorrowApy(timestamp?: BigIntish): number;
|
|
194
|
+
/**
|
|
195
|
+
* Returns the average rate at which interest _would_ accrue for suppliers of this market,
|
|
196
|
+
* if `accrueInterest` was called at the given timestamp (scaled by WAD).
|
|
197
|
+
* @param timestamp The timestamp at which to calculate the average supply rate.
|
|
198
|
+
* Must be greater than or equal to `lastUpdate`.
|
|
199
|
+
* Defaults to `Time.timestamp()` (returns the current average supply rate).
|
|
200
|
+
*/
|
|
201
|
+
getAvgSupplyRate(timestamp?: BigIntish): bigint;
|
|
194
202
|
/**
|
|
195
203
|
* The market's experienced supply-side Annual Percentage Yield (APY),
|
|
196
204
|
* if interest was to be accrued at the given timestamp.
|
package/lib/market/Market.js
CHANGED
|
@@ -4,7 +4,6 @@ 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");
|
|
8
7
|
const MarketParams_js_1 = require("./MarketParams.js");
|
|
9
8
|
const MarketUtils_js_1 = require("./MarketUtils.js");
|
|
10
9
|
var CapacityLimitReason;
|
|
@@ -209,8 +208,8 @@ class Market {
|
|
|
209
208
|
* Defaults to `Time.timestamp()` (returns the current supply APY).
|
|
210
209
|
*/
|
|
211
210
|
getSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
212
|
-
const
|
|
213
|
-
return (
|
|
211
|
+
const borrowRate = this.getEndBorrowRate(timestamp);
|
|
212
|
+
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));
|
|
214
213
|
}
|
|
215
214
|
/**
|
|
216
215
|
* The market's experienced borrow-side Annual Percentage Yield (APY),
|
|
@@ -223,6 +222,17 @@ class Market {
|
|
|
223
222
|
const borrowRate = this.getAvgBorrowRate(timestamp);
|
|
224
223
|
return MarketUtils_js_1.MarketUtils.rateToApy(borrowRate);
|
|
225
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Returns the average rate at which interest _would_ accrue for suppliers of this market,
|
|
227
|
+
* if `accrueInterest` was called at the given timestamp (scaled by WAD).
|
|
228
|
+
* @param timestamp The timestamp at which to calculate the average supply rate.
|
|
229
|
+
* Must be greater than or equal to `lastUpdate`.
|
|
230
|
+
* Defaults to `Time.timestamp()` (returns the current average supply rate).
|
|
231
|
+
*/
|
|
232
|
+
getAvgSupplyRate(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
233
|
+
const borrowRate = this.getAvgBorrowRate(timestamp);
|
|
234
|
+
return index_js_1.MathLib.wMulUp(index_js_1.MathLib.wMulDown(borrowRate, this.utilization), index_js_1.MathLib.WAD - this.fee);
|
|
235
|
+
}
|
|
226
236
|
/**
|
|
227
237
|
* The market's experienced supply-side Annual Percentage Yield (APY),
|
|
228
238
|
* if interest was to be accrued at the given timestamp.
|
|
@@ -231,8 +241,7 @@ class Market {
|
|
|
231
241
|
* Defaults to `Time.timestamp()` (returns the current supply APY).
|
|
232
242
|
*/
|
|
233
243
|
getAvgSupplyApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
234
|
-
|
|
235
|
-
return (borrowApy * +(0, viem_1.formatEther)(this.utilization) * (1 - +(0, viem_1.formatEther)(this.fee)));
|
|
244
|
+
return MarketUtils_js_1.MarketUtils.rateToApy(this.getAvgSupplyRate(timestamp));
|
|
236
245
|
}
|
|
237
246
|
/**
|
|
238
247
|
* Returns a new market derived from this market, whose interest has been accrued up to the given timestamp.
|
package/lib/vault/Vault.d.ts
CHANGED
|
@@ -156,9 +156,15 @@ export declare class AccrualVault extends Vault implements IAccrualVault {
|
|
|
156
156
|
/**
|
|
157
157
|
* The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
|
|
158
158
|
* weighted-averaged over its market deposits, after deducting the performance fee.
|
|
159
|
-
* If interested in the APY at a specific timestamp, use `
|
|
159
|
+
* If interested in the APY at a specific timestamp, use `getNetApy(timestamp)` instead.
|
|
160
160
|
*/
|
|
161
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.
|
|
166
|
+
*/
|
|
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,
|
package/lib/vault/Vault.js
CHANGED
|
@@ -5,7 +5,6 @@ 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");
|
|
9
8
|
const VaultMarketAllocation_js_1 = require("./VaultMarketAllocation.js");
|
|
10
9
|
class Vault extends index_js_3.VaultToken {
|
|
11
10
|
/**
|
|
@@ -165,24 +164,33 @@ class AccrualVault extends Vault {
|
|
|
165
164
|
/**
|
|
166
165
|
* The MetaMorpho vault's current instantaneous Annual Percentage Yield (APY)
|
|
167
166
|
* weighted-averaged over its market deposits, after deducting the performance fee.
|
|
168
|
-
* If interested in the APY at a specific timestamp, use `
|
|
167
|
+
* If interested in the APY at a specific timestamp, use `getNetApy(timestamp)` instead.
|
|
169
168
|
*/
|
|
170
169
|
get netApy() {
|
|
171
170
|
return this.getNetApy();
|
|
172
171
|
}
|
|
173
172
|
/**
|
|
174
|
-
* The MetaMorpho vault's
|
|
173
|
+
* The MetaMorpho vault's per-second rate at which interest _would_ accrue,
|
|
175
174
|
* weighted-averaged over its market deposits, before deducting the performance fee,
|
|
176
175
|
* if interest was to be accrued on each market at the given timestamp.
|
|
177
176
|
*/
|
|
178
|
-
|
|
177
|
+
_getAvgRate(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
179
178
|
if (this.totalAssets === 0n)
|
|
180
|
-
return
|
|
179
|
+
return 0n;
|
|
181
180
|
return (this.allocations
|
|
182
181
|
.values()
|
|
183
182
|
.reduce((total, { position }) => total +
|
|
184
|
-
position.market.
|
|
185
|
-
|
|
183
|
+
position.market.getAvgSupplyRate(timestamp) * position.supplyAssets, 0n) / this.totalAssets);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The MetaMorpho vault's experienced Annual Percentage Yield (APY)
|
|
187
|
+
* weighted-averaged over its market deposits, before deducting the performance fee,
|
|
188
|
+
* if interest was to be accrued on each market at the given timestamp.
|
|
189
|
+
*/
|
|
190
|
+
getApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
191
|
+
if (this.totalAssets === 0n)
|
|
192
|
+
return 0;
|
|
193
|
+
return index_js_1.MarketUtils.rateToApy(this._getAvgRate(timestamp));
|
|
186
194
|
}
|
|
187
195
|
/**
|
|
188
196
|
* The MetaMorpho vault's experienced Annual Percentage Yield (APY)
|
|
@@ -190,7 +198,7 @@ class AccrualVault extends Vault {
|
|
|
190
198
|
* if interest was to be accrued on each market at the given timestamp.
|
|
191
199
|
*/
|
|
192
200
|
getNetApy(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
193
|
-
return this.
|
|
201
|
+
return index_js_1.MarketUtils.rateToApy(index_js_2.MathLib.wMulDown(this._getAvgRate(timestamp), index_js_2.MathLib.WAD - this.fee));
|
|
194
202
|
}
|
|
195
203
|
getAllocationProportion(marketId) {
|
|
196
204
|
if (this.totalAssets === 0n)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AccrualPosition } from "../position/index.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type IVaultMarketConfig, VaultMarketConfig } from "./VaultMarketConfig.js";
|
|
3
3
|
export interface IVaultMarketAllocation {
|
|
4
|
-
config:
|
|
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() {
|
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.1.
|
|
4
|
+
"version": "5.1.2",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|