@morpho-org/blue-sdk 5.23.1 → 5.23.3
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/README.md +11 -2
- package/lib/cjs/addresses.d.ts +184 -0
- package/lib/cjs/addresses.js +102 -0
- package/lib/cjs/chain.d.ts +37 -1
- package/lib/cjs/chain.js +24 -0
- package/lib/cjs/errors.js +2 -0
- package/lib/cjs/holding/index.d.ts +1 -1
- package/lib/cjs/holding/index.js +1 -1
- package/lib/cjs/index.d.ts +6 -6
- package/lib/cjs/index.js +6 -6
- package/lib/cjs/market/Market.js +15 -0
- package/lib/cjs/market/MarketParams.d.ts +1 -1
- package/lib/cjs/market/MarketParams.js +1 -1
- package/lib/cjs/market/MarketUtils.d.ts +26 -2
- package/lib/cjs/market/MarketUtils.js +49 -6
- package/lib/cjs/market/index.d.ts +2 -2
- package/lib/cjs/market/index.js +2 -2
- package/lib/cjs/math/AdaptiveCurveIrmLib.js +8 -0
- package/lib/cjs/math/MathLib.js +14 -0
- package/lib/cjs/math/SharesMath.js +2 -0
- package/lib/cjs/math/index.d.ts +1 -1
- package/lib/cjs/math/index.js +1 -1
- package/lib/cjs/position/Position.js +9 -0
- package/lib/cjs/position/PreLiquidationPosition.d.ts +1 -0
- package/lib/cjs/position/PreLiquidationPosition.js +8 -0
- package/lib/cjs/preLiquidation.js +1 -0
- package/lib/cjs/token/ConstantWrappedToken.js +5 -0
- package/lib/cjs/token/ExchangeRateWrappedToken.js +1 -0
- package/lib/cjs/token/WrappedToken.js +4 -0
- package/lib/cjs/token/index.d.ts +3 -3
- package/lib/cjs/token/index.js +3 -3
- package/lib/cjs/vault/Vault.js +1 -0
- package/lib/cjs/vault/VaultUtils.js +8 -2
- package/lib/cjs/vault/index.d.ts +2 -2
- package/lib/cjs/vault/index.js +2 -2
- package/lib/cjs/vault/v2/VaultV2.js +2 -0
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +1 -1
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1Adapter.js +3 -1
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +1 -1
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +1 -0
- package/lib/cjs/vault/v2/VaultV2MorphoVaultV1Adapter.js +1 -0
- package/lib/esm/addresses.d.ts +184 -0
- package/lib/esm/addresses.js +102 -0
- package/lib/esm/chain.d.ts +37 -1
- package/lib/esm/chain.js +24 -0
- package/lib/esm/errors.js +2 -0
- package/lib/esm/holding/index.d.ts +1 -1
- package/lib/esm/holding/index.js +1 -1
- package/lib/esm/index.d.ts +6 -6
- package/lib/esm/index.js +6 -6
- package/lib/esm/market/Market.js +15 -0
- package/lib/esm/market/MarketParams.d.ts +1 -1
- package/lib/esm/market/MarketParams.js +1 -1
- package/lib/esm/market/MarketUtils.d.ts +26 -2
- package/lib/esm/market/MarketUtils.js +48 -5
- package/lib/esm/market/index.d.ts +2 -2
- package/lib/esm/market/index.js +2 -2
- package/lib/esm/math/AdaptiveCurveIrmLib.js +8 -0
- package/lib/esm/math/MathLib.js +14 -0
- package/lib/esm/math/SharesMath.js +2 -0
- package/lib/esm/math/index.d.ts +1 -1
- package/lib/esm/math/index.js +1 -1
- package/lib/esm/position/Position.js +9 -0
- package/lib/esm/position/PreLiquidationPosition.d.ts +1 -0
- package/lib/esm/position/PreLiquidationPosition.js +8 -0
- package/lib/esm/preLiquidation.js +1 -0
- package/lib/esm/token/ConstantWrappedToken.js +5 -0
- package/lib/esm/token/ExchangeRateWrappedToken.js +1 -0
- package/lib/esm/token/WrappedToken.js +4 -0
- package/lib/esm/token/index.d.ts +3 -3
- package/lib/esm/token/index.js +3 -3
- package/lib/esm/vault/Vault.js +1 -0
- package/lib/esm/vault/VaultUtils.js +8 -2
- package/lib/esm/vault/index.d.ts +2 -2
- package/lib/esm/vault/index.js +2 -2
- package/lib/esm/vault/v2/VaultV2.js +2 -0
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +1 -1
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.js +3 -1
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +1 -1
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +1 -0
- package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.js +1 -0
- package/package.json +6 -6
- package/src/index.ts +6 -6
|
@@ -6,11 +6,17 @@ export var VaultUtils;
|
|
|
6
6
|
return MathLib.zeroFloorSub(18n, decimals);
|
|
7
7
|
}
|
|
8
8
|
VaultUtils.decimalsOffset = decimalsOffset;
|
|
9
|
-
|
|
9
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
10
|
+
function toAssets(shares, { totalAssets, totalSupply,
|
|
11
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
12
|
+
decimalsOffset, }, rounding = "Down") {
|
|
10
13
|
return MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
|
|
11
14
|
}
|
|
12
15
|
VaultUtils.toAssets = toAssets;
|
|
13
|
-
|
|
16
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
17
|
+
function toShares(assets, { totalAssets, totalSupply,
|
|
18
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
19
|
+
decimalsOffset, }, rounding = "Up") {
|
|
14
20
|
return MathLib.mulDiv(assets, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
|
|
15
21
|
}
|
|
16
22
|
VaultUtils.toShares = toShares;
|
package/lib/esm/vault/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./Vault.js";
|
|
2
2
|
export * from "./VaultConfig.js";
|
|
3
3
|
export * from "./VaultMarketAllocation.js";
|
|
4
4
|
export * from "./VaultMarketConfig.js";
|
|
5
5
|
export * from "./VaultMarketPublicAllocatorConfig.js";
|
|
6
6
|
export * from "./VaultUser.js";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./VaultUtils.js";
|
|
8
8
|
export * from "./v2/index.js";
|
package/lib/esm/vault/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./Vault.js";
|
|
2
2
|
export * from "./VaultConfig.js";
|
|
3
3
|
export * from "./VaultMarketAllocation.js";
|
|
4
4
|
export * from "./VaultMarketConfig.js";
|
|
5
5
|
export * from "./VaultMarketPublicAllocatorConfig.js";
|
|
6
6
|
export * from "./VaultUser.js";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./VaultUtils.js";
|
|
8
8
|
export * from "./v2/index.js";
|
|
@@ -55,6 +55,7 @@ export class AccrualVaultV2 extends VaultV2 {
|
|
|
55
55
|
accrualAdapters;
|
|
56
56
|
assetBalance;
|
|
57
57
|
forceDeallocatePenalties;
|
|
58
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
58
59
|
constructor(vault, accrualLiquidityAdapter, accrualAdapters, assetBalance,
|
|
59
60
|
/**
|
|
60
61
|
* The force deallocate penalty for each adapter, keyed by adapter address.
|
|
@@ -126,6 +127,7 @@ export class AccrualVaultV2 extends VaultV2 {
|
|
|
126
127
|
*/
|
|
127
128
|
accrueInterest(timestamp) {
|
|
128
129
|
const vault = new AccrualVaultV2(this, this.accrualLiquidityAdapter, this.accrualAdapters, this.assetBalance, this.forceDeallocatePenalties);
|
|
130
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
129
131
|
timestamp = BigInt(timestamp);
|
|
130
132
|
const elapsed = timestamp - this.lastUpdate;
|
|
131
133
|
if (elapsed < 0n)
|
|
@@ -3,8 +3,8 @@ import { type IMarketParams, MarketParams } from "../../market/index.js";
|
|
|
3
3
|
import type { AccrualPosition } from "../../position/index.js";
|
|
4
4
|
import type { BigIntish } from "../../types.js";
|
|
5
5
|
import { CapacityLimitReason } from "../../utils.js";
|
|
6
|
-
import { VaultV2Adapter } from "./VaultV2Adapter.js";
|
|
7
6
|
import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
|
|
7
|
+
import { VaultV2Adapter } from "./VaultV2Adapter.js";
|
|
8
8
|
export interface IVaultV2MorphoMarketV1Adapter extends Omit<IVaultV2Adapter, "adapterId" | "type"> {
|
|
9
9
|
type?: "VaultV2MorphoMarketV1Adapter";
|
|
10
10
|
marketParamsList: IMarketParams[];
|
|
@@ -46,7 +46,9 @@ export class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMarketV1Ad
|
|
|
46
46
|
}
|
|
47
47
|
maxWithdraw(data) {
|
|
48
48
|
const marketId = MarketParams.fromHex(data).id;
|
|
49
|
-
const position = this.positions.find(
|
|
49
|
+
const position = this.positions.find(
|
|
50
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
51
|
+
(position) => position.marketId === marketId);
|
|
50
52
|
return (position?.market?.getWithdrawCapacityLimit(position) ?? {
|
|
51
53
|
value: 0n,
|
|
52
54
|
limiter: CapacityLimitReason.position,
|
|
@@ -2,8 +2,8 @@ import { type Address, type Hex } from "viem";
|
|
|
2
2
|
import { type Market, MarketParams } from "../../market/index.js";
|
|
3
3
|
import type { BigIntish, MarketId } from "../../types.js";
|
|
4
4
|
import { CapacityLimitReason } from "../../utils.js";
|
|
5
|
-
import { VaultV2Adapter } from "./VaultV2Adapter.js";
|
|
6
5
|
import type { IAccrualVaultV2Adapter, IVaultV2Adapter } from "./VaultV2Adapter.js";
|
|
6
|
+
import { VaultV2Adapter } from "./VaultV2Adapter.js";
|
|
7
7
|
export interface IVaultV2MorphoMarketV1AdapterV2 extends Omit<IVaultV2Adapter, "adapterId" | "type"> {
|
|
8
8
|
type?: "VaultV2MorphoMarketV1AdapterV2";
|
|
9
9
|
marketIds: MarketId[];
|
|
@@ -53,6 +53,7 @@ export class AccrualVaultV2MorphoMarketV1AdapterV2 extends VaultV2MorphoMarketV1
|
|
|
53
53
|
}
|
|
54
54
|
maxWithdraw(data) {
|
|
55
55
|
const marketId = MarketParams.fromHex(data).id;
|
|
56
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
56
57
|
const market = this.markets.find((market) => market.id === marketId);
|
|
57
58
|
return (market?.getWithdrawCapacityLimit({
|
|
58
59
|
supplyShares: this.supplyShares[marketId] ?? 0n,
|
|
@@ -20,6 +20,7 @@ export class VaultV2MorphoVaultV1Adapter extends VaultV2Adapter {
|
|
|
20
20
|
export class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter {
|
|
21
21
|
accrualVaultV1;
|
|
22
22
|
shares;
|
|
23
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
23
24
|
constructor(adapter, accrualVaultV1, shares) {
|
|
24
25
|
super(adapter);
|
|
25
26
|
this.accrualVaultV1 = accrualVaultV1;
|
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.23.
|
|
4
|
+
"version": "5.23.3",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Rubilmax <rmilon@gmail.com>"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"lib"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@noble/hashes": "^
|
|
22
|
+
"@noble/hashes": "^2.2.0",
|
|
23
23
|
"@types/lodash.isplainobject": "^4.0.9",
|
|
24
24
|
"@types/lodash.mergewith": "^4.6.9",
|
|
25
25
|
"lodash.isplainobject": "^4.0.6",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"@morpho-org/morpho-ts": "^2.5.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"typescript": "^
|
|
33
|
-
"viem": "^2.
|
|
34
|
-
"vitest": "^4.1.
|
|
32
|
+
"typescript": "^6.0.3",
|
|
33
|
+
"viem": "^2.49.3",
|
|
34
|
+
"vitest": "^4.1.6",
|
|
35
35
|
"@morpho-org/morpho-ts": "^2.5.1",
|
|
36
|
-
"@morpho-org/test": "^2.7.
|
|
36
|
+
"@morpho-org/test": "^2.7.3"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"prepublish": "$npm_execpath build",
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export * from "./addresses.js";
|
|
2
|
+
export * from "./chain.js";
|
|
2
3
|
export * from "./constants.js";
|
|
3
4
|
export * from "./errors.js";
|
|
5
|
+
export * from "./holding/index.js";
|
|
4
6
|
export * from "./market/index.js";
|
|
5
|
-
export * from "./chain.js";
|
|
6
|
-
export * from "./token/index.js";
|
|
7
|
-
export * from "./types.js";
|
|
8
7
|
export * from "./math/index.js";
|
|
9
|
-
export * from "./user/index.js";
|
|
10
|
-
export * from "./holding/index.js";
|
|
11
8
|
export * from "./position/index.js";
|
|
12
|
-
export * from "./vault/index.js";
|
|
13
9
|
export * from "./preLiquidation.js";
|
|
10
|
+
export * from "./token/index.js";
|
|
11
|
+
export * from "./types.js";
|
|
12
|
+
export * from "./user/index.js";
|
|
14
13
|
export * from "./utils.js";
|
|
14
|
+
export * from "./vault/index.js";
|