@morpho-org/blue-sdk 5.23.0 → 5.23.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/README.md +11 -2
- package/lib/cjs/addresses.d.ts +4 -0
- package/lib/cjs/addresses.js +3 -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.js +18 -0
- 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/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 +4 -3
- 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 +4 -0
- package/lib/esm/addresses.js +3 -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.js +18 -0
- 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/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 +4 -3
- 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 +2 -2
- package/src/index.ts +6 -6
|
@@ -6,6 +6,7 @@ const WrappedToken_js_1 = require("./WrappedToken.js");
|
|
|
6
6
|
class ExchangeRateWrappedToken extends WrappedToken_js_1.WrappedToken {
|
|
7
7
|
underlying;
|
|
8
8
|
wrappedTokenExchangeRate;
|
|
9
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
9
10
|
constructor(token, underlying, wrappedTokenExchangeRate) {
|
|
10
11
|
super(token, underlying);
|
|
11
12
|
this.underlying = underlying;
|
|
@@ -10,21 +10,25 @@ class WrappedToken extends Token_js_1.Token {
|
|
|
10
10
|
this.underlying = underlying;
|
|
11
11
|
}
|
|
12
12
|
/** The expected amount when wrapping `unwrappedAmount` */
|
|
13
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
13
14
|
toWrappedExactAmountIn(unwrappedAmount, slippage = 0n, rounding = "Down") {
|
|
14
15
|
const wrappedAmount = this._wrap(unwrappedAmount, rounding);
|
|
15
16
|
return index_js_1.MathLib.wMulDown(wrappedAmount, index_js_1.MathLib.WAD - slippage);
|
|
16
17
|
}
|
|
17
18
|
/** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
|
|
19
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
18
20
|
toWrappedExactAmountOut(wrappedAmount, slippage = 0n, rounding = "Up") {
|
|
19
21
|
const wAmountTarget = index_js_1.MathLib.wDiv(wrappedAmount, index_js_1.MathLib.WAD - slippage, rounding);
|
|
20
22
|
return this._unwrap(wAmountTarget, rounding);
|
|
21
23
|
}
|
|
22
24
|
/** The expected amount when unwrapping `wrappedAmount` */
|
|
25
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
23
26
|
toUnwrappedExactAmountIn(wrappedAmount, slippage = 0n, rounding = "Down") {
|
|
24
27
|
const unwrappedAmount = this._unwrap(wrappedAmount, rounding);
|
|
25
28
|
return index_js_1.MathLib.wMulUp(unwrappedAmount, index_js_1.MathLib.WAD - slippage);
|
|
26
29
|
}
|
|
27
30
|
/** The amount of wrappedTokens that should be unwrapped to receive `unwrappedAmount` */
|
|
31
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
28
32
|
toUnwrappedExactAmountOut(unwrappedAmount, slippage = 0n, rounding = "Up") {
|
|
29
33
|
const unwrappedAmountToTarget = index_js_1.MathLib.wDiv(unwrappedAmount, index_js_1.MathLib.WAD - slippage, rounding);
|
|
30
34
|
return this._wrap(unwrappedAmountToTarget, rounding);
|
package/lib/cjs/token/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./Token.js";
|
|
2
|
-
export * from "./WrappedToken.js";
|
|
3
1
|
export * from "./ConstantWrappedToken.js";
|
|
2
|
+
export * from "./Eip5267Domain.js";
|
|
4
3
|
export * from "./ExchangeRateWrappedToken.js";
|
|
4
|
+
export * from "./Token.js";
|
|
5
5
|
export * from "./VaultToken.js";
|
|
6
|
-
export * from "./
|
|
6
|
+
export * from "./WrappedToken.js";
|
package/lib/cjs/token/index.js
CHANGED
|
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Token.js"), exports);
|
|
18
|
-
__exportStar(require("./WrappedToken.js"), exports);
|
|
19
17
|
__exportStar(require("./ConstantWrappedToken.js"), exports);
|
|
18
|
+
__exportStar(require("./Eip5267Domain.js"), exports);
|
|
20
19
|
__exportStar(require("./ExchangeRateWrappedToken.js"), exports);
|
|
20
|
+
__exportStar(require("./Token.js"), exports);
|
|
21
21
|
__exportStar(require("./VaultToken.js"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./WrappedToken.js"), exports);
|
package/lib/cjs/vault/Vault.js
CHANGED
|
@@ -230,6 +230,7 @@ class AccrualVault extends Vault {
|
|
|
230
230
|
* @param assets The maximum amount of assets to deposit.
|
|
231
231
|
*/
|
|
232
232
|
maxDeposit(assets) {
|
|
233
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
233
234
|
assets = BigInt(assets);
|
|
234
235
|
const suppliable = this.allocations
|
|
235
236
|
.values()
|
|
@@ -9,11 +9,17 @@ var VaultUtils;
|
|
|
9
9
|
return index_js_1.MathLib.zeroFloorSub(18n, decimals);
|
|
10
10
|
}
|
|
11
11
|
VaultUtils.decimalsOffset = decimalsOffset;
|
|
12
|
-
|
|
12
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
13
|
+
function toAssets(shares, { totalAssets, totalSupply,
|
|
14
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
15
|
+
decimalsOffset, }, rounding = "Down") {
|
|
13
16
|
return index_js_1.MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
|
|
14
17
|
}
|
|
15
18
|
VaultUtils.toAssets = toAssets;
|
|
16
|
-
|
|
19
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
20
|
+
function toShares(assets, { totalAssets, totalSupply,
|
|
21
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
22
|
+
decimalsOffset, }, rounding = "Up") {
|
|
17
23
|
return index_js_1.MathLib.mulDiv(assets, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
|
|
18
24
|
}
|
|
19
25
|
VaultUtils.toShares = toShares;
|
package/lib/cjs/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/cjs/vault/index.js
CHANGED
|
@@ -14,11 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./Vault.js"), exports);
|
|
18
18
|
__exportStar(require("./VaultConfig.js"), exports);
|
|
19
19
|
__exportStar(require("./VaultMarketAllocation.js"), exports);
|
|
20
20
|
__exportStar(require("./VaultMarketConfig.js"), exports);
|
|
21
21
|
__exportStar(require("./VaultMarketPublicAllocatorConfig.js"), exports);
|
|
22
22
|
__exportStar(require("./VaultUser.js"), exports);
|
|
23
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./VaultUtils.js"), exports);
|
|
24
24
|
__exportStar(require("./v2/index.js"), exports);
|
|
@@ -59,6 +59,7 @@ class AccrualVaultV2 extends VaultV2 {
|
|
|
59
59
|
accrualAdapters;
|
|
60
60
|
assetBalance;
|
|
61
61
|
forceDeallocatePenalties;
|
|
62
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
62
63
|
constructor(vault, accrualLiquidityAdapter, accrualAdapters, assetBalance,
|
|
63
64
|
/**
|
|
64
65
|
* The force deallocate penalty for each adapter, keyed by adapter address.
|
|
@@ -110,10 +111,9 @@ class AccrualVaultV2 extends VaultV2 {
|
|
|
110
111
|
*/
|
|
111
112
|
maxWithdraw(shares) {
|
|
112
113
|
const assets = this.toAssets(shares);
|
|
113
|
-
if (this.liquidityAdapter === viem_1.zeroAddress)
|
|
114
|
-
return { value: BigInt(assets), limiter: utils_js_1.CapacityLimitReason.balance };
|
|
115
114
|
let liquidity = this.assetBalance;
|
|
116
|
-
if (this.
|
|
115
|
+
if (this.liquidityAdapter !== viem_1.zeroAddress &&
|
|
116
|
+
this.accrualLiquidityAdapter != null)
|
|
117
117
|
liquidity += this.accrualLiquidityAdapter.maxWithdraw(this.liquidityData).value;
|
|
118
118
|
if (assets > liquidity)
|
|
119
119
|
return {
|
|
@@ -131,6 +131,7 @@ class AccrualVaultV2 extends VaultV2 {
|
|
|
131
131
|
*/
|
|
132
132
|
accrueInterest(timestamp) {
|
|
133
133
|
const vault = new AccrualVaultV2(this, this.accrualLiquidityAdapter, this.accrualAdapters, this.assetBalance, this.forceDeallocatePenalties);
|
|
134
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
134
135
|
timestamp = BigInt(timestamp);
|
|
135
136
|
const elapsed = timestamp - this.lastUpdate;
|
|
136
137
|
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[];
|
|
@@ -50,7 +50,9 @@ class AccrualVaultV2MorphoMarketV1Adapter extends VaultV2MorphoMarketV1Adapter {
|
|
|
50
50
|
}
|
|
51
51
|
maxWithdraw(data) {
|
|
52
52
|
const marketId = index_js_1.MarketParams.fromHex(data).id;
|
|
53
|
-
const position = this.positions.find(
|
|
53
|
+
const position = this.positions.find(
|
|
54
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
55
|
+
(position) => position.marketId === marketId);
|
|
54
56
|
return (position?.market?.getWithdrawCapacityLimit(position) ?? {
|
|
55
57
|
value: 0n,
|
|
56
58
|
limiter: utils_js_1.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[];
|
|
@@ -57,6 +57,7 @@ class AccrualVaultV2MorphoMarketV1AdapterV2 extends VaultV2MorphoMarketV1Adapter
|
|
|
57
57
|
}
|
|
58
58
|
maxWithdraw(data) {
|
|
59
59
|
const marketId = index_js_1.MarketParams.fromHex(data).id;
|
|
60
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
60
61
|
const market = this.markets.find((market) => market.id === marketId);
|
|
61
62
|
return (market?.getWithdrawCapacityLimit({
|
|
62
63
|
supplyShares: this.supplyShares[marketId] ?? 0n,
|
|
@@ -24,6 +24,7 @@ exports.VaultV2MorphoVaultV1Adapter = VaultV2MorphoVaultV1Adapter;
|
|
|
24
24
|
class AccrualVaultV2MorphoVaultV1Adapter extends VaultV2MorphoVaultV1Adapter {
|
|
25
25
|
accrualVaultV1;
|
|
26
26
|
shares;
|
|
27
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
27
28
|
constructor(adapter, accrualVaultV1, shares) {
|
|
28
29
|
super(adapter);
|
|
29
30
|
this.accrualVaultV1 = accrualVaultV1;
|
package/lib/esm/addresses.d.ts
CHANGED
|
@@ -630,6 +630,7 @@ declare const _addressesRegistry: {
|
|
|
630
630
|
readonly adaptiveCurveIrm: "0x112fd4042E442C3C12C67AD23587b0afe36eB74E";
|
|
631
631
|
readonly vaultV2Factory: "0x3DE400E3F79113194fa5AF6Ae5C474947E0C82Db";
|
|
632
632
|
readonly morphoMarketV1AdapterV2Factory: "0xF85aD5f14cC903533FC409B8098B58b4C2f36697";
|
|
633
|
+
readonly morphoVaultV1AdapterFactory: "0x669771F03ab55CebF753E90C3c9D80ad9391cf25";
|
|
633
634
|
readonly registryList: "0xB118227C728b5ce52445a5aAee48C8a281C429E0";
|
|
634
635
|
readonly chainlinkOracleFactory: "0xc2c167BC5cBD833ce58239e85073258F10aD4DF6";
|
|
635
636
|
readonly preLiquidationFactory: "0xB83d2D5CAE5Fc64a408cA82447445442Fe249fe3";
|
|
@@ -1183,6 +1184,7 @@ declare const _deployments: {
|
|
|
1183
1184
|
readonly adaptiveCurveIrm: 2375313n;
|
|
1184
1185
|
readonly vaultV2Factory: 2375650n;
|
|
1185
1186
|
readonly morphoMarketV1AdapterV2Factory: 2375701n;
|
|
1187
|
+
readonly morphoVaultV1AdapterFactory: 16475630n;
|
|
1186
1188
|
readonly registryList: 2375601n;
|
|
1187
1189
|
readonly chainlinkOracleFactory: 2375626n;
|
|
1188
1190
|
readonly preLiquidationFactory: 2375010n;
|
|
@@ -1841,6 +1843,7 @@ export declare let addressesRegistry: {
|
|
|
1841
1843
|
readonly adaptiveCurveIrm: "0x112fd4042E442C3C12C67AD23587b0afe36eB74E";
|
|
1842
1844
|
readonly vaultV2Factory: "0x3DE400E3F79113194fa5AF6Ae5C474947E0C82Db";
|
|
1843
1845
|
readonly morphoMarketV1AdapterV2Factory: "0xF85aD5f14cC903533FC409B8098B58b4C2f36697";
|
|
1846
|
+
readonly morphoVaultV1AdapterFactory: "0x669771F03ab55CebF753E90C3c9D80ad9391cf25";
|
|
1844
1847
|
readonly registryList: "0xB118227C728b5ce52445a5aAee48C8a281C429E0";
|
|
1845
1848
|
readonly chainlinkOracleFactory: "0xc2c167BC5cBD833ce58239e85073258F10aD4DF6";
|
|
1846
1849
|
readonly preLiquidationFactory: "0xB83d2D5CAE5Fc64a408cA82447445442Fe249fe3";
|
|
@@ -2392,6 +2395,7 @@ export declare let deployments: {
|
|
|
2392
2395
|
readonly adaptiveCurveIrm: 2375313n;
|
|
2393
2396
|
readonly vaultV2Factory: 2375650n;
|
|
2394
2397
|
readonly morphoMarketV1AdapterV2Factory: 2375701n;
|
|
2398
|
+
readonly morphoVaultV1AdapterFactory: 16475630n;
|
|
2395
2399
|
readonly registryList: 2375601n;
|
|
2396
2400
|
readonly chainlinkOracleFactory: 2375626n;
|
|
2397
2401
|
readonly preLiquidationFactory: 2375010n;
|
package/lib/esm/addresses.js
CHANGED
|
@@ -615,6 +615,7 @@ const _addressesRegistry = {
|
|
|
615
615
|
adaptiveCurveIrm: "0x112fd4042E442C3C12C67AD23587b0afe36eB74E",
|
|
616
616
|
vaultV2Factory: "0x3DE400E3F79113194fa5AF6Ae5C474947E0C82Db",
|
|
617
617
|
morphoMarketV1AdapterV2Factory: "0xF85aD5f14cC903533FC409B8098B58b4C2f36697",
|
|
618
|
+
morphoVaultV1AdapterFactory: "0x669771F03ab55CebF753E90C3c9D80ad9391cf25",
|
|
618
619
|
registryList: "0xB118227C728b5ce52445a5aAee48C8a281C429E0",
|
|
619
620
|
chainlinkOracleFactory: "0xc2c167BC5cBD833ce58239e85073258F10aD4DF6",
|
|
620
621
|
preLiquidationFactory: "0xB83d2D5CAE5Fc64a408cA82447445442Fe249fe3",
|
|
@@ -1165,6 +1166,7 @@ const _deployments = {
|
|
|
1165
1166
|
adaptiveCurveIrm: 2375313n,
|
|
1166
1167
|
vaultV2Factory: 2375650n,
|
|
1167
1168
|
morphoMarketV1AdapterV2Factory: 2375701n,
|
|
1169
|
+
morphoVaultV1AdapterFactory: 16475630n,
|
|
1168
1170
|
registryList: 2375601n,
|
|
1169
1171
|
chainlinkOracleFactory: 2375626n,
|
|
1170
1172
|
preLiquidationFactory: 2375010n,
|
|
@@ -1428,6 +1430,7 @@ export let unwrappedTokensMapping = deepFreeze(_unwrappedTokensMapping);
|
|
|
1428
1430
|
export function registerCustomAddresses({ unwrappedTokens, addresses: customAddresses, deployments: customDeployments, } = {}) {
|
|
1429
1431
|
const customizer = (type) =>
|
|
1430
1432
|
// biome-ignore lint/suspicious/noExplicitAny: type is not trivial and not important here
|
|
1433
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1431
1434
|
(objValue, srcValue, key) => {
|
|
1432
1435
|
if (objValue !== undefined &&
|
|
1433
1436
|
!isPlainObject(objValue) &&
|
package/lib/esm/errors.js
CHANGED
|
@@ -73,6 +73,7 @@ export var BlueErrors;
|
|
|
73
73
|
marketId;
|
|
74
74
|
timestamp;
|
|
75
75
|
lastUpdate;
|
|
76
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
76
77
|
constructor(marketId, timestamp, lastUpdate) {
|
|
77
78
|
super(`invalid interest accrual on market ${marketId}: accrual timestamp ${timestamp} can't be prior to last update ${lastUpdate}`);
|
|
78
79
|
this.marketId = marketId;
|
|
@@ -142,6 +143,7 @@ export var VaultV2Errors;
|
|
|
142
143
|
vault;
|
|
143
144
|
timestamp;
|
|
144
145
|
lastUpdate;
|
|
146
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
145
147
|
constructor(vault, timestamp, lastUpdate) {
|
|
146
148
|
super(`invalid interest accrual on vault ${vault}: accrual timestamp ${timestamp} can't be prior to last update ${lastUpdate}`);
|
|
147
149
|
this.vault = vault;
|
package/lib/esm/holding/index.js
CHANGED
package/lib/esm/index.d.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";
|
package/lib/esm/index.js
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";
|
package/lib/esm/market/Market.js
CHANGED
|
@@ -165,6 +165,7 @@ export class Market {
|
|
|
165
165
|
* Defaults to `Time.timestamp()` (returns the current accrual borrow rate).
|
|
166
166
|
*/
|
|
167
167
|
getAccrualBorrowRates(timestamp = Time.timestamp()) {
|
|
168
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
168
169
|
timestamp = BigInt(timestamp);
|
|
169
170
|
const elapsed = timestamp - this.lastUpdate;
|
|
170
171
|
if (elapsed < 0n)
|
|
@@ -241,6 +242,7 @@ export class Market {
|
|
|
241
242
|
* Defaults to `lastUpdate` (returns a copy of the market).
|
|
242
243
|
*/
|
|
243
244
|
accrueInterest(timestamp = this.lastUpdate) {
|
|
245
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
244
246
|
timestamp = BigInt(timestamp);
|
|
245
247
|
const { elapsed, avgBorrowRate, endRateAtTarget } = this.getAccrualBorrowRates(timestamp);
|
|
246
248
|
const { interest, feeShares } = MarketUtils.getAccruedInterest(avgBorrowRate, this, elapsed);
|
|
@@ -253,24 +255,30 @@ export class Market {
|
|
|
253
255
|
rateAtTarget: endRateAtTarget,
|
|
254
256
|
});
|
|
255
257
|
}
|
|
258
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
256
259
|
supply(assets, shares, timestamp) {
|
|
257
260
|
if ((assets === 0n) === (shares === 0n))
|
|
258
261
|
throw new BlueErrors.InconsistentInput(assets, shares);
|
|
259
262
|
const market = this.accrueInterest(timestamp);
|
|
263
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
260
264
|
if (shares === 0n)
|
|
261
265
|
shares = market.toSupplyShares(assets, "Down");
|
|
266
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
262
267
|
else
|
|
263
268
|
assets = market.toSupplyAssets(shares, "Up");
|
|
264
269
|
market.totalSupplyAssets += assets;
|
|
265
270
|
market.totalSupplyShares += shares;
|
|
266
271
|
return { market, assets, shares };
|
|
267
272
|
}
|
|
273
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
268
274
|
withdraw(assets, shares, timestamp) {
|
|
269
275
|
if ((assets === 0n) === (shares === 0n))
|
|
270
276
|
throw new BlueErrors.InconsistentInput(assets, shares);
|
|
271
277
|
const market = this.accrueInterest(timestamp);
|
|
278
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
272
279
|
if (shares === 0n)
|
|
273
280
|
shares = market.toSupplyShares(assets, "Up");
|
|
281
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
274
282
|
else
|
|
275
283
|
assets = market.toSupplyAssets(shares, "Down");
|
|
276
284
|
market.totalSupplyAssets -= assets;
|
|
@@ -279,12 +287,15 @@ export class Market {
|
|
|
279
287
|
throw new BlueErrors.InsufficientLiquidity(market.id);
|
|
280
288
|
return { market, assets, shares };
|
|
281
289
|
}
|
|
290
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
282
291
|
borrow(assets, shares, timestamp) {
|
|
283
292
|
if ((assets === 0n) === (shares === 0n))
|
|
284
293
|
throw new BlueErrors.InconsistentInput(assets, shares);
|
|
285
294
|
const market = this.accrueInterest(timestamp);
|
|
295
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
286
296
|
if (shares === 0n)
|
|
287
297
|
shares = market.toBorrowShares(assets, "Up");
|
|
298
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
288
299
|
else
|
|
289
300
|
assets = market.toBorrowAssets(shares, "Down");
|
|
290
301
|
market.totalBorrowAssets += assets;
|
|
@@ -293,12 +304,15 @@ export class Market {
|
|
|
293
304
|
throw new BlueErrors.InsufficientLiquidity(market.id);
|
|
294
305
|
return { market, assets, shares };
|
|
295
306
|
}
|
|
307
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
296
308
|
repay(assets, shares, timestamp) {
|
|
297
309
|
if ((assets === 0n) === (shares === 0n))
|
|
298
310
|
throw new BlueErrors.InconsistentInput(assets, shares);
|
|
299
311
|
const market = this.accrueInterest(timestamp);
|
|
312
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
300
313
|
if (shares === 0n)
|
|
301
314
|
shares = market.toBorrowShares(assets, "Down");
|
|
315
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
302
316
|
else
|
|
303
317
|
assets = market.toBorrowAssets(shares, "Up");
|
|
304
318
|
market.totalBorrowAssets -= assets;
|
|
@@ -557,6 +571,7 @@ export class Market {
|
|
|
557
571
|
* @param loanTokenBalance The balance of loan assets.
|
|
558
572
|
* @param collateralTokenBalance The balance of collateral assets.
|
|
559
573
|
*/
|
|
574
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
560
575
|
getMaxCapacities(position, loanTokenBalance, collateralTokenBalance, options) {
|
|
561
576
|
return {
|
|
562
577
|
supply: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ZERO_ADDRESS } from "@morpho-org/morpho-ts";
|
|
2
|
-
import { InvalidMarketParamsError, UnknownMarketParamsError, } from "../errors.js";
|
|
3
2
|
import { decodeAbiParameters } from "viem";
|
|
3
|
+
import { InvalidMarketParamsError, UnknownMarketParamsError, } from "../errors.js";
|
|
4
4
|
import { MarketUtils } from "./MarketUtils.js";
|
|
5
5
|
export const marketParamsAbi = {
|
|
6
6
|
type: "tuple",
|
|
@@ -63,6 +63,7 @@ export var MarketUtils;
|
|
|
63
63
|
* @param market The market state.
|
|
64
64
|
* @param elapsed The time elapsed since the last market update (in seconds).
|
|
65
65
|
*/
|
|
66
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
66
67
|
function getAccruedInterest(borrowRate, { totalSupplyAssets, totalBorrowAssets, totalSupplyShares, fee, }, elapsed = 0n) {
|
|
67
68
|
const interest = MathLib.wMulDown(totalBorrowAssets, MathLib.wTaylorCompounded(borrowRate, elapsed));
|
|
68
69
|
const feeAmount = MathLib.wMulDown(interest, fee);
|
|
@@ -79,6 +80,7 @@ export var MarketUtils;
|
|
|
79
80
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
80
81
|
*/
|
|
81
82
|
function getSupplyToUtilization(market, utilization) {
|
|
83
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
82
84
|
utilization = BigInt(utilization);
|
|
83
85
|
if (utilization === 0n) {
|
|
84
86
|
if (getUtilization(market) === 0n)
|
|
@@ -94,6 +96,7 @@ export var MarketUtils;
|
|
|
94
96
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
95
97
|
*/
|
|
96
98
|
function getWithdrawToUtilization({ totalSupplyAssets, totalBorrowAssets, }, utilization) {
|
|
99
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
97
100
|
utilization = BigInt(utilization);
|
|
98
101
|
totalSupplyAssets = BigInt(totalSupplyAssets);
|
|
99
102
|
totalBorrowAssets = BigInt(totalBorrowAssets);
|
|
@@ -142,6 +145,7 @@ export var MarketUtils;
|
|
|
142
145
|
* Return `undefined` iff the market's price is undefined.
|
|
143
146
|
* To calculate the amount of loan assets that can be borrowed, use `getMaxBorrowableAssets`.
|
|
144
147
|
*/
|
|
148
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
145
149
|
function getMaxBorrowAssets(collateral, market, { lltv }) {
|
|
146
150
|
const collateralValue = getCollateralValue(collateral, market);
|
|
147
151
|
if (collateralValue == null)
|
|
@@ -153,6 +157,7 @@ export var MarketUtils;
|
|
|
153
157
|
* Returns the maximum amount of loan assets that can be borrowed given a certain borrow position.
|
|
154
158
|
* Return `undefined` iff the market's price is undefined.
|
|
155
159
|
*/
|
|
160
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
156
161
|
function getMaxBorrowableAssets({ collateral, borrowShares, }, market, marketParams) {
|
|
157
162
|
const maxBorrowAssets = getMaxBorrowAssets(collateral, market, marketParams);
|
|
158
163
|
if (maxBorrowAssets == null)
|
|
@@ -164,6 +169,7 @@ export var MarketUtils;
|
|
|
164
169
|
* Returns the amount of collateral that would be seized in a liquidation given a certain amount of repaid shares.
|
|
165
170
|
* Return `undefined` iff the market's price is undefined.
|
|
166
171
|
*/
|
|
172
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
167
173
|
function getLiquidationSeizedAssets(repaidShares, market, config) {
|
|
168
174
|
if (market.price == null)
|
|
169
175
|
return;
|
|
@@ -177,6 +183,7 @@ export var MarketUtils;
|
|
|
177
183
|
* Returns the amount of borrow shares that would be repaid in a liquidation given a certain amount of seized collateral.
|
|
178
184
|
* Return `undefined` iff the market's price is undefined.
|
|
179
185
|
*/
|
|
186
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
180
187
|
function getLiquidationRepaidShares(seizedAssets, market, config) {
|
|
181
188
|
if (market.price == null)
|
|
182
189
|
return;
|
|
@@ -187,6 +194,7 @@ export var MarketUtils;
|
|
|
187
194
|
* Returns the maximum amount of collateral that is worth being seized in a liquidation given a certain borrow position.
|
|
188
195
|
* Return `undefined` iff the market's price is undefined.
|
|
189
196
|
*/
|
|
197
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
190
198
|
function getSeizableCollateral(position, market, config) {
|
|
191
199
|
if (market.price == null)
|
|
192
200
|
return; // Must be checked before calling `isHealthy`.
|
|
@@ -200,6 +208,7 @@ export var MarketUtils;
|
|
|
200
208
|
* Returns the amount of collateral that can be withdrawn given a certain borrow position.
|
|
201
209
|
* Return `undefined` iff the market's price is undefined.
|
|
202
210
|
*/
|
|
211
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
203
212
|
function getWithdrawableCollateral({ collateral, borrowShares, }, market, { lltv }) {
|
|
204
213
|
if (market.price == null)
|
|
205
214
|
return;
|
|
@@ -214,6 +223,7 @@ export var MarketUtils;
|
|
|
214
223
|
* Return `undefined` iff the market's price is undefined.
|
|
215
224
|
* @param position The borrow position to check.
|
|
216
225
|
*/
|
|
226
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
217
227
|
function isHealthy({ collateral, borrowShares, }, market, marketParams) {
|
|
218
228
|
const maxBorrowAssets = getMaxBorrowAssets(collateral, market, marketParams);
|
|
219
229
|
if (maxBorrowAssets == null)
|
|
@@ -226,6 +236,7 @@ export var MarketUtils;
|
|
|
226
236
|
* that set the user's position to be liquidatable.
|
|
227
237
|
* Returns null if the position is not a borrow.
|
|
228
238
|
*/
|
|
239
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
229
240
|
function getLiquidationPrice({ collateral, borrowShares, }, market, marketParams) {
|
|
230
241
|
borrowShares = BigInt(borrowShares);
|
|
231
242
|
market.totalBorrowShares = BigInt(market.totalBorrowShares);
|
|
@@ -244,6 +255,7 @@ export var MarketUtils;
|
|
|
244
255
|
* Returns `undefined` iff the market's price is undefined.
|
|
245
256
|
* Returns null if the position is not a borrow.
|
|
246
257
|
*/
|
|
258
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
247
259
|
function getPriceVariationToLiquidationPrice(position, market, marketParams) {
|
|
248
260
|
if (market.price == null)
|
|
249
261
|
return;
|
|
@@ -261,6 +273,7 @@ export var MarketUtils;
|
|
|
261
273
|
* If the debt is 0, health factor is `MaxUint256`.
|
|
262
274
|
* Returns `undefined` iff the market's price is undefined.
|
|
263
275
|
*/
|
|
276
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
264
277
|
function getHealthFactor({ collateral, borrowShares, }, market, marketParams) {
|
|
265
278
|
const borrowAssets = toBorrowAssets(borrowShares, market);
|
|
266
279
|
if (borrowAssets === 0n)
|
|
@@ -293,6 +306,7 @@ export var MarketUtils;
|
|
|
293
306
|
* Returns the usage ratio of the maximum borrow capacity given a certain borrow position (scaled by WAD).
|
|
294
307
|
* Returns `undefined` iff the market's price is undefined.
|
|
295
308
|
*/
|
|
309
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
296
310
|
function getBorrowCapacityUsage(position, market, marketParams) {
|
|
297
311
|
const hf = getHealthFactor(position, market, marketParams);
|
|
298
312
|
if (hf === undefined)
|
|
@@ -304,18 +318,22 @@ export var MarketUtils;
|
|
|
304
318
|
return MathLib.wDivUp(MathLib.WAD, hf);
|
|
305
319
|
}
|
|
306
320
|
MarketUtils.getBorrowCapacityUsage = getBorrowCapacityUsage;
|
|
321
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
307
322
|
function toSupplyAssets(shares, market, rounding = "Down") {
|
|
308
323
|
return SharesMath.toAssets(shares, market.totalSupplyAssets, market.totalSupplyShares, rounding);
|
|
309
324
|
}
|
|
310
325
|
MarketUtils.toSupplyAssets = toSupplyAssets;
|
|
326
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
311
327
|
function toSupplyShares(assets, market, rounding = "Up") {
|
|
312
328
|
return SharesMath.toShares(assets, market.totalSupplyAssets, market.totalSupplyShares, rounding);
|
|
313
329
|
}
|
|
314
330
|
MarketUtils.toSupplyShares = toSupplyShares;
|
|
331
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
315
332
|
function toBorrowAssets(shares, market, rounding = "Up") {
|
|
316
333
|
return SharesMath.toAssets(shares, market.totalBorrowAssets, market.totalBorrowShares, rounding);
|
|
317
334
|
}
|
|
318
335
|
MarketUtils.toBorrowAssets = toBorrowAssets;
|
|
336
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
319
337
|
function toBorrowShares(assets, market, rounding = "Down") {
|
|
320
338
|
return SharesMath.toShares(assets, market.totalBorrowAssets, market.totalBorrowShares, rounding);
|
|
321
339
|
}
|
package/lib/esm/market/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export var AdaptiveCurveIrmLib;
|
|
|
33
33
|
* @param x
|
|
34
34
|
*/
|
|
35
35
|
function wExp(x) {
|
|
36
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
36
37
|
x = BigInt(x);
|
|
37
38
|
// If x < ln(1e-18) then exp(x) < 1e-18 so it is rounded to zero.
|
|
38
39
|
if (x < AdaptiveCurveIrmLib.LN_WEI_INT)
|
|
@@ -53,9 +54,13 @@ export var AdaptiveCurveIrmLib;
|
|
|
53
54
|
return expR >> -q;
|
|
54
55
|
}
|
|
55
56
|
AdaptiveCurveIrmLib.wExp = wExp;
|
|
57
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
56
58
|
function getBorrowRate(startUtilization, startRateAtTarget, elapsed) {
|
|
59
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
57
60
|
startUtilization = BigInt(startUtilization);
|
|
61
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
58
62
|
startRateAtTarget = BigInt(startRateAtTarget);
|
|
63
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
59
64
|
elapsed = BigInt(elapsed);
|
|
60
65
|
const errNormFactor = startUtilization > AdaptiveCurveIrmLib.TARGET_UTILIZATION
|
|
61
66
|
? MathLib.WAD - AdaptiveCurveIrmLib.TARGET_UTILIZATION
|
|
@@ -80,6 +85,7 @@ export var AdaptiveCurveIrmLib;
|
|
|
80
85
|
}
|
|
81
86
|
else {
|
|
82
87
|
// Non negative because MIN_RATE_AT_TARGET > 0.
|
|
88
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
83
89
|
const _newRateAtTarget = (linearAdaptation) => MathLib.min(MathLib.max(MathLib.wMulDown(startRateAtTarget, wExp(linearAdaptation)), AdaptiveCurveIrmLib.MIN_RATE_AT_TARGET), AdaptiveCurveIrmLib.MAX_RATE_AT_TARGET);
|
|
84
90
|
// Formula of the average rate that should be returned to Morpho Blue:
|
|
85
91
|
// avg = 1/T * ∫_0^T curve(startRateAtTarget*exp(speed*x), err) dx
|
|
@@ -116,7 +122,9 @@ export var AdaptiveCurveIrmLib;
|
|
|
116
122
|
}
|
|
117
123
|
AdaptiveCurveIrmLib.getBorrowRate = getBorrowRate;
|
|
118
124
|
function getUtilizationAtBorrowRate(borrowRate, rateAtTarget) {
|
|
125
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
119
126
|
borrowRate = BigInt(borrowRate);
|
|
127
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
120
128
|
rateAtTarget = BigInt(rateAtTarget);
|
|
121
129
|
if (borrowRate >= rateAtTarget) {
|
|
122
130
|
const maxBorrowRate = MathLib.wMulDown(rateAtTarget, AdaptiveCurveIrmLib.CURVE_STEEPNESS);
|