@morpho-org/blue-sdk 5.23.1 → 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 +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 +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 +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 +2 -2
- package/src/index.ts +6 -6
package/README.md
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
<br />
|
|
22
22
|
<br />
|
|
23
23
|
|
|
24
|
+
## Overview
|
|
25
|
+
|
|
24
26
|
Framework-agnostic package that defines Morpho-related entity classes:
|
|
25
27
|
|
|
26
28
|
- [**`MarketParams`**](./src/market/MarketParams.ts): represents the immutable configuration of a market on Morpho
|
|
@@ -42,7 +44,7 @@ npm install @morpho-org/blue-sdk
|
|
|
42
44
|
yarn add @morpho-org/blue-sdk
|
|
43
45
|
```
|
|
44
46
|
|
|
45
|
-
##
|
|
47
|
+
## Usage
|
|
46
48
|
|
|
47
49
|
### Instance of the immutable configuration of a specific market
|
|
48
50
|
|
|
@@ -197,4 +199,11 @@ registerCustomAddresses({
|
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
201
|
});
|
|
200
|
-
```
|
|
202
|
+
```
|
|
203
|
+
## Development
|
|
204
|
+
|
|
205
|
+
Contribute from the monorepo root. See [CONTRIBUTING.md](../../CONTRIBUTING.md) for setup, checks, and package workflow. Report vulnerabilities through [SECURITY.md](../../SECURITY.md).
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
MIT. See [LICENSE](./LICENSE).
|
package/lib/cjs/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/cjs/addresses.js
CHANGED
|
@@ -623,6 +623,7 @@ const _addressesRegistry = {
|
|
|
623
623
|
adaptiveCurveIrm: "0x112fd4042E442C3C12C67AD23587b0afe36eB74E",
|
|
624
624
|
vaultV2Factory: "0x3DE400E3F79113194fa5AF6Ae5C474947E0C82Db",
|
|
625
625
|
morphoMarketV1AdapterV2Factory: "0xF85aD5f14cC903533FC409B8098B58b4C2f36697",
|
|
626
|
+
morphoVaultV1AdapterFactory: "0x669771F03ab55CebF753E90C3c9D80ad9391cf25",
|
|
626
627
|
registryList: "0xB118227C728b5ce52445a5aAee48C8a281C429E0",
|
|
627
628
|
chainlinkOracleFactory: "0xc2c167BC5cBD833ce58239e85073258F10aD4DF6",
|
|
628
629
|
preLiquidationFactory: "0xB83d2D5CAE5Fc64a408cA82447445442Fe249fe3",
|
|
@@ -1173,6 +1174,7 @@ const _deployments = {
|
|
|
1173
1174
|
adaptiveCurveIrm: 2375313n,
|
|
1174
1175
|
vaultV2Factory: 2375650n,
|
|
1175
1176
|
morphoMarketV1AdapterV2Factory: 2375701n,
|
|
1177
|
+
morphoVaultV1AdapterFactory: 16475630n,
|
|
1176
1178
|
registryList: 2375601n,
|
|
1177
1179
|
chainlinkOracleFactory: 2375626n,
|
|
1178
1180
|
preLiquidationFactory: 2375010n,
|
|
@@ -1438,6 +1440,7 @@ exports.unwrappedTokensMapping = (0, morpho_ts_1.deepFreeze)(_unwrappedTokensMap
|
|
|
1438
1440
|
function registerCustomAddresses({ unwrappedTokens, addresses: customAddresses, deployments: customDeployments, } = {}) {
|
|
1439
1441
|
const customizer = (type) =>
|
|
1440
1442
|
// biome-ignore lint/suspicious/noExplicitAny: type is not trivial and not important here
|
|
1443
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
1441
1444
|
(objValue, srcValue, key) => {
|
|
1442
1445
|
if (objValue !== undefined &&
|
|
1443
1446
|
!(0, lodash_isplainobject_1.default)(objValue) &&
|
package/lib/cjs/errors.js
CHANGED
|
@@ -86,6 +86,7 @@ var BlueErrors;
|
|
|
86
86
|
marketId;
|
|
87
87
|
timestamp;
|
|
88
88
|
lastUpdate;
|
|
89
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
89
90
|
constructor(marketId, timestamp, lastUpdate) {
|
|
90
91
|
super(`invalid interest accrual on market ${marketId}: accrual timestamp ${timestamp} can't be prior to last update ${lastUpdate}`);
|
|
91
92
|
this.marketId = marketId;
|
|
@@ -155,6 +156,7 @@ var VaultV2Errors;
|
|
|
155
156
|
vault;
|
|
156
157
|
timestamp;
|
|
157
158
|
lastUpdate;
|
|
159
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
158
160
|
constructor(vault, timestamp, lastUpdate) {
|
|
159
161
|
super(`invalid interest accrual on vault ${vault}: accrual timestamp ${timestamp} can't be prior to last update ${lastUpdate}`);
|
|
160
162
|
this.vault = vault;
|
package/lib/cjs/holding/index.js
CHANGED
|
@@ -14,5 +14,5 @@ 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("./Holding.js"), exports);
|
|
18
17
|
__exportStar(require("./AssetBalances.js"), exports);
|
|
18
|
+
__exportStar(require("./Holding.js"), exports);
|
package/lib/cjs/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/cjs/index.js
CHANGED
|
@@ -15,16 +15,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./addresses.js"), exports);
|
|
18
|
+
__exportStar(require("./chain.js"), exports);
|
|
18
19
|
__exportStar(require("./constants.js"), exports);
|
|
19
20
|
__exportStar(require("./errors.js"), exports);
|
|
21
|
+
__exportStar(require("./holding/index.js"), exports);
|
|
20
22
|
__exportStar(require("./market/index.js"), exports);
|
|
21
|
-
__exportStar(require("./chain.js"), exports);
|
|
22
|
-
__exportStar(require("./token/index.js"), exports);
|
|
23
|
-
__exportStar(require("./types.js"), exports);
|
|
24
23
|
__exportStar(require("./math/index.js"), exports);
|
|
25
|
-
__exportStar(require("./user/index.js"), exports);
|
|
26
|
-
__exportStar(require("./holding/index.js"), exports);
|
|
27
24
|
__exportStar(require("./position/index.js"), exports);
|
|
28
|
-
__exportStar(require("./vault/index.js"), exports);
|
|
29
25
|
__exportStar(require("./preLiquidation.js"), exports);
|
|
26
|
+
__exportStar(require("./token/index.js"), exports);
|
|
27
|
+
__exportStar(require("./types.js"), exports);
|
|
28
|
+
__exportStar(require("./user/index.js"), exports);
|
|
30
29
|
__exportStar(require("./utils.js"), exports);
|
|
30
|
+
__exportStar(require("./vault/index.js"), exports);
|
package/lib/cjs/market/Market.js
CHANGED
|
@@ -168,6 +168,7 @@ class Market {
|
|
|
168
168
|
* Defaults to `Time.timestamp()` (returns the current accrual borrow rate).
|
|
169
169
|
*/
|
|
170
170
|
getAccrualBorrowRates(timestamp = morpho_ts_1.Time.timestamp()) {
|
|
171
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
171
172
|
timestamp = BigInt(timestamp);
|
|
172
173
|
const elapsed = timestamp - this.lastUpdate;
|
|
173
174
|
if (elapsed < 0n)
|
|
@@ -244,6 +245,7 @@ class Market {
|
|
|
244
245
|
* Defaults to `lastUpdate` (returns a copy of the market).
|
|
245
246
|
*/
|
|
246
247
|
accrueInterest(timestamp = this.lastUpdate) {
|
|
248
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
247
249
|
timestamp = BigInt(timestamp);
|
|
248
250
|
const { elapsed, avgBorrowRate, endRateAtTarget } = this.getAccrualBorrowRates(timestamp);
|
|
249
251
|
const { interest, feeShares } = MarketUtils_js_1.MarketUtils.getAccruedInterest(avgBorrowRate, this, elapsed);
|
|
@@ -256,24 +258,30 @@ class Market {
|
|
|
256
258
|
rateAtTarget: endRateAtTarget,
|
|
257
259
|
});
|
|
258
260
|
}
|
|
261
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
259
262
|
supply(assets, shares, timestamp) {
|
|
260
263
|
if ((assets === 0n) === (shares === 0n))
|
|
261
264
|
throw new errors_js_1.BlueErrors.InconsistentInput(assets, shares);
|
|
262
265
|
const market = this.accrueInterest(timestamp);
|
|
266
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
263
267
|
if (shares === 0n)
|
|
264
268
|
shares = market.toSupplyShares(assets, "Down");
|
|
269
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
265
270
|
else
|
|
266
271
|
assets = market.toSupplyAssets(shares, "Up");
|
|
267
272
|
market.totalSupplyAssets += assets;
|
|
268
273
|
market.totalSupplyShares += shares;
|
|
269
274
|
return { market, assets, shares };
|
|
270
275
|
}
|
|
276
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
271
277
|
withdraw(assets, shares, timestamp) {
|
|
272
278
|
if ((assets === 0n) === (shares === 0n))
|
|
273
279
|
throw new errors_js_1.BlueErrors.InconsistentInput(assets, shares);
|
|
274
280
|
const market = this.accrueInterest(timestamp);
|
|
281
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
275
282
|
if (shares === 0n)
|
|
276
283
|
shares = market.toSupplyShares(assets, "Up");
|
|
284
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
277
285
|
else
|
|
278
286
|
assets = market.toSupplyAssets(shares, "Down");
|
|
279
287
|
market.totalSupplyAssets -= assets;
|
|
@@ -282,12 +290,15 @@ class Market {
|
|
|
282
290
|
throw new errors_js_1.BlueErrors.InsufficientLiquidity(market.id);
|
|
283
291
|
return { market, assets, shares };
|
|
284
292
|
}
|
|
293
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
285
294
|
borrow(assets, shares, timestamp) {
|
|
286
295
|
if ((assets === 0n) === (shares === 0n))
|
|
287
296
|
throw new errors_js_1.BlueErrors.InconsistentInput(assets, shares);
|
|
288
297
|
const market = this.accrueInterest(timestamp);
|
|
298
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
289
299
|
if (shares === 0n)
|
|
290
300
|
shares = market.toBorrowShares(assets, "Up");
|
|
301
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
291
302
|
else
|
|
292
303
|
assets = market.toBorrowAssets(shares, "Down");
|
|
293
304
|
market.totalBorrowAssets += assets;
|
|
@@ -296,12 +307,15 @@ class Market {
|
|
|
296
307
|
throw new errors_js_1.BlueErrors.InsufficientLiquidity(market.id);
|
|
297
308
|
return { market, assets, shares };
|
|
298
309
|
}
|
|
310
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
299
311
|
repay(assets, shares, timestamp) {
|
|
300
312
|
if ((assets === 0n) === (shares === 0n))
|
|
301
313
|
throw new errors_js_1.BlueErrors.InconsistentInput(assets, shares);
|
|
302
314
|
const market = this.accrueInterest(timestamp);
|
|
315
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
303
316
|
if (shares === 0n)
|
|
304
317
|
shares = market.toBorrowShares(assets, "Down");
|
|
318
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
305
319
|
else
|
|
306
320
|
assets = market.toBorrowAssets(shares, "Up");
|
|
307
321
|
market.totalBorrowAssets -= assets;
|
|
@@ -560,6 +574,7 @@ class Market {
|
|
|
560
574
|
* @param loanTokenBalance The balance of loan assets.
|
|
561
575
|
* @param collateralTokenBalance The balance of collateral assets.
|
|
562
576
|
*/
|
|
577
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
563
578
|
getMaxCapacities(position, loanTokenBalance, collateralTokenBalance, options) {
|
|
564
579
|
return {
|
|
565
580
|
supply: {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MarketParams = exports.marketParamsAbi = void 0;
|
|
4
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
|
-
const errors_js_1 = require("../errors.js");
|
|
6
5
|
const viem_1 = require("viem");
|
|
6
|
+
const errors_js_1 = require("../errors.js");
|
|
7
7
|
const MarketUtils_js_1 = require("./MarketUtils.js");
|
|
8
8
|
exports.marketParamsAbi = {
|
|
9
9
|
type: "tuple",
|
|
@@ -66,6 +66,7 @@ var MarketUtils;
|
|
|
66
66
|
* @param market The market state.
|
|
67
67
|
* @param elapsed The time elapsed since the last market update (in seconds).
|
|
68
68
|
*/
|
|
69
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
69
70
|
function getAccruedInterest(borrowRate, { totalSupplyAssets, totalBorrowAssets, totalSupplyShares, fee, }, elapsed = 0n) {
|
|
70
71
|
const interest = index_js_1.MathLib.wMulDown(totalBorrowAssets, index_js_1.MathLib.wTaylorCompounded(borrowRate, elapsed));
|
|
71
72
|
const feeAmount = index_js_1.MathLib.wMulDown(interest, fee);
|
|
@@ -82,6 +83,7 @@ var MarketUtils;
|
|
|
82
83
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
83
84
|
*/
|
|
84
85
|
function getSupplyToUtilization(market, utilization) {
|
|
86
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
85
87
|
utilization = BigInt(utilization);
|
|
86
88
|
if (utilization === 0n) {
|
|
87
89
|
if (getUtilization(market) === 0n)
|
|
@@ -97,6 +99,7 @@ var MarketUtils;
|
|
|
97
99
|
* @param utilization The target utilization rate (scaled by WAD).
|
|
98
100
|
*/
|
|
99
101
|
function getWithdrawToUtilization({ totalSupplyAssets, totalBorrowAssets, }, utilization) {
|
|
102
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
100
103
|
utilization = BigInt(utilization);
|
|
101
104
|
totalSupplyAssets = BigInt(totalSupplyAssets);
|
|
102
105
|
totalBorrowAssets = BigInt(totalBorrowAssets);
|
|
@@ -145,6 +148,7 @@ var MarketUtils;
|
|
|
145
148
|
* Return `undefined` iff the market's price is undefined.
|
|
146
149
|
* To calculate the amount of loan assets that can be borrowed, use `getMaxBorrowableAssets`.
|
|
147
150
|
*/
|
|
151
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
148
152
|
function getMaxBorrowAssets(collateral, market, { lltv }) {
|
|
149
153
|
const collateralValue = getCollateralValue(collateral, market);
|
|
150
154
|
if (collateralValue == null)
|
|
@@ -156,6 +160,7 @@ var MarketUtils;
|
|
|
156
160
|
* Returns the maximum amount of loan assets that can be borrowed given a certain borrow position.
|
|
157
161
|
* Return `undefined` iff the market's price is undefined.
|
|
158
162
|
*/
|
|
163
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
159
164
|
function getMaxBorrowableAssets({ collateral, borrowShares, }, market, marketParams) {
|
|
160
165
|
const maxBorrowAssets = getMaxBorrowAssets(collateral, market, marketParams);
|
|
161
166
|
if (maxBorrowAssets == null)
|
|
@@ -167,6 +172,7 @@ var MarketUtils;
|
|
|
167
172
|
* Returns the amount of collateral that would be seized in a liquidation given a certain amount of repaid shares.
|
|
168
173
|
* Return `undefined` iff the market's price is undefined.
|
|
169
174
|
*/
|
|
175
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
170
176
|
function getLiquidationSeizedAssets(repaidShares, market, config) {
|
|
171
177
|
if (market.price == null)
|
|
172
178
|
return;
|
|
@@ -180,6 +186,7 @@ var MarketUtils;
|
|
|
180
186
|
* Returns the amount of borrow shares that would be repaid in a liquidation given a certain amount of seized collateral.
|
|
181
187
|
* Return `undefined` iff the market's price is undefined.
|
|
182
188
|
*/
|
|
189
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
183
190
|
function getLiquidationRepaidShares(seizedAssets, market, config) {
|
|
184
191
|
if (market.price == null)
|
|
185
192
|
return;
|
|
@@ -190,6 +197,7 @@ var MarketUtils;
|
|
|
190
197
|
* Returns the maximum amount of collateral that is worth being seized in a liquidation given a certain borrow position.
|
|
191
198
|
* Return `undefined` iff the market's price is undefined.
|
|
192
199
|
*/
|
|
200
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
193
201
|
function getSeizableCollateral(position, market, config) {
|
|
194
202
|
if (market.price == null)
|
|
195
203
|
return; // Must be checked before calling `isHealthy`.
|
|
@@ -203,6 +211,7 @@ var MarketUtils;
|
|
|
203
211
|
* Returns the amount of collateral that can be withdrawn given a certain borrow position.
|
|
204
212
|
* Return `undefined` iff the market's price is undefined.
|
|
205
213
|
*/
|
|
214
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
206
215
|
function getWithdrawableCollateral({ collateral, borrowShares, }, market, { lltv }) {
|
|
207
216
|
if (market.price == null)
|
|
208
217
|
return;
|
|
@@ -217,6 +226,7 @@ var MarketUtils;
|
|
|
217
226
|
* Return `undefined` iff the market's price is undefined.
|
|
218
227
|
* @param position The borrow position to check.
|
|
219
228
|
*/
|
|
229
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
220
230
|
function isHealthy({ collateral, borrowShares, }, market, marketParams) {
|
|
221
231
|
const maxBorrowAssets = getMaxBorrowAssets(collateral, market, marketParams);
|
|
222
232
|
if (maxBorrowAssets == null)
|
|
@@ -229,6 +239,7 @@ var MarketUtils;
|
|
|
229
239
|
* that set the user's position to be liquidatable.
|
|
230
240
|
* Returns null if the position is not a borrow.
|
|
231
241
|
*/
|
|
242
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
232
243
|
function getLiquidationPrice({ collateral, borrowShares, }, market, marketParams) {
|
|
233
244
|
borrowShares = BigInt(borrowShares);
|
|
234
245
|
market.totalBorrowShares = BigInt(market.totalBorrowShares);
|
|
@@ -247,6 +258,7 @@ var MarketUtils;
|
|
|
247
258
|
* Returns `undefined` iff the market's price is undefined.
|
|
248
259
|
* Returns null if the position is not a borrow.
|
|
249
260
|
*/
|
|
261
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
250
262
|
function getPriceVariationToLiquidationPrice(position, market, marketParams) {
|
|
251
263
|
if (market.price == null)
|
|
252
264
|
return;
|
|
@@ -264,6 +276,7 @@ var MarketUtils;
|
|
|
264
276
|
* If the debt is 0, health factor is `MaxUint256`.
|
|
265
277
|
* Returns `undefined` iff the market's price is undefined.
|
|
266
278
|
*/
|
|
279
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
267
280
|
function getHealthFactor({ collateral, borrowShares, }, market, marketParams) {
|
|
268
281
|
const borrowAssets = toBorrowAssets(borrowShares, market);
|
|
269
282
|
if (borrowAssets === 0n)
|
|
@@ -296,6 +309,7 @@ var MarketUtils;
|
|
|
296
309
|
* Returns the usage ratio of the maximum borrow capacity given a certain borrow position (scaled by WAD).
|
|
297
310
|
* Returns `undefined` iff the market's price is undefined.
|
|
298
311
|
*/
|
|
312
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
299
313
|
function getBorrowCapacityUsage(position, market, marketParams) {
|
|
300
314
|
const hf = getHealthFactor(position, market, marketParams);
|
|
301
315
|
if (hf === undefined)
|
|
@@ -307,18 +321,22 @@ var MarketUtils;
|
|
|
307
321
|
return index_js_1.MathLib.wDivUp(index_js_1.MathLib.WAD, hf);
|
|
308
322
|
}
|
|
309
323
|
MarketUtils.getBorrowCapacityUsage = getBorrowCapacityUsage;
|
|
324
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
310
325
|
function toSupplyAssets(shares, market, rounding = "Down") {
|
|
311
326
|
return index_js_1.SharesMath.toAssets(shares, market.totalSupplyAssets, market.totalSupplyShares, rounding);
|
|
312
327
|
}
|
|
313
328
|
MarketUtils.toSupplyAssets = toSupplyAssets;
|
|
329
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
314
330
|
function toSupplyShares(assets, market, rounding = "Up") {
|
|
315
331
|
return index_js_1.SharesMath.toShares(assets, market.totalSupplyAssets, market.totalSupplyShares, rounding);
|
|
316
332
|
}
|
|
317
333
|
MarketUtils.toSupplyShares = toSupplyShares;
|
|
334
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
318
335
|
function toBorrowAssets(shares, market, rounding = "Up") {
|
|
319
336
|
return index_js_1.SharesMath.toAssets(shares, market.totalBorrowAssets, market.totalBorrowShares, rounding);
|
|
320
337
|
}
|
|
321
338
|
MarketUtils.toBorrowAssets = toBorrowAssets;
|
|
339
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
322
340
|
function toBorrowShares(assets, market, rounding = "Down") {
|
|
323
341
|
return index_js_1.SharesMath.toShares(assets, market.totalBorrowAssets, market.totalBorrowShares, rounding);
|
|
324
342
|
}
|
package/lib/cjs/market/index.js
CHANGED
|
@@ -14,6 +14,6 @@ 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("./MarketUtils.js"), exports);
|
|
18
|
-
__exportStar(require("./MarketParams.js"), exports);
|
|
19
17
|
__exportStar(require("./Market.js"), exports);
|
|
18
|
+
__exportStar(require("./MarketParams.js"), exports);
|
|
19
|
+
__exportStar(require("./MarketUtils.js"), exports);
|
|
@@ -36,6 +36,7 @@ var AdaptiveCurveIrmLib;
|
|
|
36
36
|
* @param x
|
|
37
37
|
*/
|
|
38
38
|
function wExp(x) {
|
|
39
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
39
40
|
x = BigInt(x);
|
|
40
41
|
// If x < ln(1e-18) then exp(x) < 1e-18 so it is rounded to zero.
|
|
41
42
|
if (x < AdaptiveCurveIrmLib.LN_WEI_INT)
|
|
@@ -56,9 +57,13 @@ var AdaptiveCurveIrmLib;
|
|
|
56
57
|
return expR >> -q;
|
|
57
58
|
}
|
|
58
59
|
AdaptiveCurveIrmLib.wExp = wExp;
|
|
60
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
59
61
|
function getBorrowRate(startUtilization, startRateAtTarget, elapsed) {
|
|
62
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
60
63
|
startUtilization = BigInt(startUtilization);
|
|
64
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
61
65
|
startRateAtTarget = BigInt(startRateAtTarget);
|
|
66
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
62
67
|
elapsed = BigInt(elapsed);
|
|
63
68
|
const errNormFactor = startUtilization > AdaptiveCurveIrmLib.TARGET_UTILIZATION
|
|
64
69
|
? MathLib_js_1.MathLib.WAD - AdaptiveCurveIrmLib.TARGET_UTILIZATION
|
|
@@ -83,6 +88,7 @@ var AdaptiveCurveIrmLib;
|
|
|
83
88
|
}
|
|
84
89
|
else {
|
|
85
90
|
// Non negative because MIN_RATE_AT_TARGET > 0.
|
|
91
|
+
// biome-ignore lint/nursery/noShadow: TODO rename to avoid shadowing
|
|
86
92
|
const _newRateAtTarget = (linearAdaptation) => MathLib_js_1.MathLib.min(MathLib_js_1.MathLib.max(MathLib_js_1.MathLib.wMulDown(startRateAtTarget, wExp(linearAdaptation)), AdaptiveCurveIrmLib.MIN_RATE_AT_TARGET), AdaptiveCurveIrmLib.MAX_RATE_AT_TARGET);
|
|
87
93
|
// Formula of the average rate that should be returned to Morpho Blue:
|
|
88
94
|
// avg = 1/T * ∫_0^T curve(startRateAtTarget*exp(speed*x), err) dx
|
|
@@ -119,7 +125,9 @@ var AdaptiveCurveIrmLib;
|
|
|
119
125
|
}
|
|
120
126
|
AdaptiveCurveIrmLib.getBorrowRate = getBorrowRate;
|
|
121
127
|
function getUtilizationAtBorrowRate(borrowRate, rateAtTarget) {
|
|
128
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
122
129
|
borrowRate = BigInt(borrowRate);
|
|
130
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
123
131
|
rateAtTarget = BigInt(rateAtTarget);
|
|
124
132
|
if (borrowRate >= rateAtTarget) {
|
|
125
133
|
const maxBorrowRate = MathLib_js_1.MathLib.wMulDown(rateAtTarget, AdaptiveCurveIrmLib.CURVE_STEEPNESS);
|
package/lib/cjs/math/MathLib.js
CHANGED
|
@@ -24,6 +24,7 @@ var MathLib;
|
|
|
24
24
|
* @param a The number
|
|
25
25
|
*/
|
|
26
26
|
function abs(a) {
|
|
27
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
27
28
|
a = BigInt(a);
|
|
28
29
|
return a >= 0 ? a : -a;
|
|
29
30
|
}
|
|
@@ -52,7 +53,9 @@ var MathLib;
|
|
|
52
53
|
* @param y The second number
|
|
53
54
|
*/
|
|
54
55
|
function zeroFloorSub(x, y) {
|
|
56
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
55
57
|
x = BigInt(x);
|
|
58
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
56
59
|
y = BigInt(y);
|
|
57
60
|
return x <= y ? 0n : x - y;
|
|
58
61
|
}
|
|
@@ -80,6 +83,7 @@ var MathLib;
|
|
|
80
83
|
* @param x The first number
|
|
81
84
|
* @param y The second number
|
|
82
85
|
*/
|
|
86
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
83
87
|
function wMul(x, y, rounding) {
|
|
84
88
|
return MathLib.mulDiv(x, y, MathLib.WAD, rounding);
|
|
85
89
|
}
|
|
@@ -107,6 +111,7 @@ var MathLib;
|
|
|
107
111
|
* @param x The first number
|
|
108
112
|
* @param y The second number
|
|
109
113
|
*/
|
|
114
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
110
115
|
function wDiv(x, y, rounding) {
|
|
111
116
|
return MathLib.mulDiv(x, MathLib.WAD, y, rounding);
|
|
112
117
|
}
|
|
@@ -117,9 +122,13 @@ var MathLib;
|
|
|
117
122
|
* @param y The second number
|
|
118
123
|
* @param denominator The denominator
|
|
119
124
|
*/
|
|
125
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
120
126
|
function mulDivDown(x, y, denominator) {
|
|
127
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
121
128
|
x = BigInt(x);
|
|
129
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
122
130
|
y = BigInt(y);
|
|
131
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
123
132
|
denominator = BigInt(denominator);
|
|
124
133
|
if (denominator === 0n)
|
|
125
134
|
throw Error("MathLib: DIVISION_BY_ZERO");
|
|
@@ -132,9 +141,13 @@ var MathLib;
|
|
|
132
141
|
* @param y The second number
|
|
133
142
|
* @param denominator The denominator
|
|
134
143
|
*/
|
|
144
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
135
145
|
function mulDivUp(x, y, denominator) {
|
|
146
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
136
147
|
x = BigInt(x);
|
|
148
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
137
149
|
y = BigInt(y);
|
|
150
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
138
151
|
denominator = BigInt(denominator);
|
|
139
152
|
if (denominator === 0n)
|
|
140
153
|
throw Error("MathLib: DIVISION_BY_ZERO");
|
|
@@ -142,6 +155,7 @@ var MathLib;
|
|
|
142
155
|
return (x * y) / denominator + roundup;
|
|
143
156
|
}
|
|
144
157
|
MathLib.mulDivUp = mulDivUp;
|
|
158
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
145
159
|
function mulDiv(x, y, denominator, rounding) {
|
|
146
160
|
return MathLib[`mulDiv${rounding}`](x, y, denominator);
|
|
147
161
|
}
|
|
@@ -10,10 +10,12 @@ var SharesMath;
|
|
|
10
10
|
(function (SharesMath) {
|
|
11
11
|
SharesMath.VIRTUAL_SHARES = 1000000n;
|
|
12
12
|
SharesMath.VIRTUAL_ASSETS = 1n;
|
|
13
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
13
14
|
function toAssets(shares, totalAssets, totalShares, rounding) {
|
|
14
15
|
return MathLib_js_1.MathLib.mulDiv(shares, BigInt(totalAssets) + SharesMath.VIRTUAL_ASSETS, BigInt(totalShares) + SharesMath.VIRTUAL_SHARES, rounding);
|
|
15
16
|
}
|
|
16
17
|
SharesMath.toAssets = toAssets;
|
|
18
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
17
19
|
function toShares(assets, totalAssets, totalShares, rounding) {
|
|
18
20
|
return MathLib_js_1.MathLib.mulDiv(assets, BigInt(totalShares) + SharesMath.VIRTUAL_SHARES, BigInt(totalAssets) + SharesMath.VIRTUAL_ASSETS, rounding);
|
|
19
21
|
}
|
package/lib/cjs/math/index.d.ts
CHANGED
package/lib/cjs/math/index.js
CHANGED
|
@@ -14,6 +14,6 @@ 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("./AdaptiveCurveIrmLib.js"), exports);
|
|
17
18
|
__exportStar(require("./MathLib.js"), exports);
|
|
18
19
|
__exportStar(require("./SharesMath.js"), exports);
|
|
19
|
-
__exportStar(require("./AdaptiveCurveIrmLib.js"), exports);
|
|
@@ -162,15 +162,19 @@ class AccrualPosition extends Position {
|
|
|
162
162
|
accrueInterest(timestamp) {
|
|
163
163
|
return new AccrualPosition(this, this._market.accrueInterest(timestamp));
|
|
164
164
|
}
|
|
165
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
165
166
|
supply(assets, shares, timestamp) {
|
|
166
167
|
let { _market: market } = this;
|
|
168
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
167
169
|
({ market, assets, shares } = market.supply(assets, shares, timestamp));
|
|
168
170
|
const position = new AccrualPosition(this, market);
|
|
169
171
|
position.supplyShares += shares;
|
|
170
172
|
return { position, assets, shares };
|
|
171
173
|
}
|
|
174
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
172
175
|
withdraw(assets, shares, timestamp) {
|
|
173
176
|
let { _market: market } = this;
|
|
177
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
174
178
|
({ market, assets, shares } = market.withdraw(assets, shares, timestamp));
|
|
175
179
|
const position = new AccrualPosition(this, market);
|
|
176
180
|
position.supplyShares -= shares;
|
|
@@ -193,10 +197,12 @@ class AccrualPosition extends Position {
|
|
|
193
197
|
throw new errors_js_1.BlueErrors.InsufficientCollateral(position.user, position.marketId);
|
|
194
198
|
return position;
|
|
195
199
|
}
|
|
200
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
196
201
|
borrow(assets, shares, timestamp) {
|
|
197
202
|
let { _market: market } = this;
|
|
198
203
|
if (market.price == null)
|
|
199
204
|
throw new errors_js_1.BlueErrors.UnknownOraclePrice(market.id);
|
|
205
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
200
206
|
({ market, assets, shares } = market.borrow(assets, shares, timestamp));
|
|
201
207
|
const position = new AccrualPosition(this, market);
|
|
202
208
|
position.borrowShares += shares;
|
|
@@ -204,8 +210,10 @@ class AccrualPosition extends Position {
|
|
|
204
210
|
throw new errors_js_1.BlueErrors.InsufficientCollateral(this.user, this.marketId);
|
|
205
211
|
return { position, assets, shares };
|
|
206
212
|
}
|
|
213
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
207
214
|
repay(assets, shares, timestamp) {
|
|
208
215
|
let { _market: market } = this;
|
|
216
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
209
217
|
({ market, assets, shares } = market.repay(assets, shares, timestamp));
|
|
210
218
|
const position = new AccrualPosition(this, market);
|
|
211
219
|
position.borrowShares -= shares;
|
|
@@ -222,6 +230,7 @@ class AccrualPosition extends Position {
|
|
|
222
230
|
getRepayCapacityLimit(loanTokenBalance) {
|
|
223
231
|
return this._market.getRepayCapacityLimit(this.borrowShares, loanTokenBalance);
|
|
224
232
|
}
|
|
233
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
225
234
|
getMaxCapacities(loanTokenBalance, collateralTokenBalance, options) {
|
|
226
235
|
return {
|
|
227
236
|
supply: {
|
|
@@ -86,6 +86,7 @@ exports.defaultPreLiquidationParamsRegistry = new Map([
|
|
|
86
86
|
],
|
|
87
87
|
]);
|
|
88
88
|
const getDefaultPreLiquidationParams = (lltv) => {
|
|
89
|
+
// biome-ignore lint/style/noParameterAssign: TODO refactor to avoid mutating parameter
|
|
89
90
|
lltv = BigInt(lltv);
|
|
90
91
|
const defaultParams = exports.defaultPreLiquidationParamsRegistry.get(lltv);
|
|
91
92
|
if (defaultParams == null)
|
|
@@ -5,22 +5,27 @@ const index_js_1 = require("../math/index.js");
|
|
|
5
5
|
const WrappedToken_js_1 = require("./WrappedToken.js");
|
|
6
6
|
class ConstantWrappedToken extends WrappedToken_js_1.WrappedToken {
|
|
7
7
|
underlyingDecimals;
|
|
8
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
8
9
|
constructor(token, underlying, underlyingDecimals = 0) {
|
|
9
10
|
super(token, underlying);
|
|
10
11
|
this.underlyingDecimals = BigInt(underlyingDecimals);
|
|
11
12
|
}
|
|
13
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
12
14
|
toWrappedExactAmountIn(unwrappedAmount, _slippage, rounding = "Down") {
|
|
13
15
|
return super.toWrappedExactAmountIn(unwrappedAmount, 0n, rounding);
|
|
14
16
|
}
|
|
15
17
|
/** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
|
|
18
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
16
19
|
toWrappedExactAmountOut(wrappedAmount, _slippage, rounding = "Up") {
|
|
17
20
|
return super.toWrappedExactAmountOut(wrappedAmount, 0n, rounding);
|
|
18
21
|
}
|
|
19
22
|
/** The expected amount when unwrapping `wrappedAmount` */
|
|
23
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
20
24
|
toUnwrappedExactAmountIn(wrappedAmount, _slippage, rounding = "Down") {
|
|
21
25
|
return super.toUnwrappedExactAmountIn(wrappedAmount, 0n, rounding);
|
|
22
26
|
}
|
|
23
27
|
/** The amount of wrappedTokens that should be unwrapped to receive `unwrappedAmount` */
|
|
28
|
+
// biome-ignore lint/complexity/useMaxParams: TODO refactor to ≤2 params
|
|
24
29
|
toUnwrappedExactAmountOut(unwrappedAmount, _slippage, rounding = "Up") {
|
|
25
30
|
return super.toUnwrappedExactAmountOut(unwrappedAmount, 0n, rounding);
|
|
26
31
|
}
|