impermax-sdk 2.1.317 → 2.1.319
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/offchain/account/offchainAccount.js +4 -3
- package/lib/offchain/lendingPool/nftlp/offchainNftlpUniswapV3.js +4 -0
- package/lib/offchain/lendingPool/offchainLendingPool.js +2 -2
- package/lib/utils/position/genericPosition.d.ts +1 -0
- package/lib/utils/position/genericPosition.js +1 -3
- package/lib/utils/position/interface.d.ts +1 -0
- package/package.json +1 -1
|
@@ -267,9 +267,10 @@ class OffchainAccount {
|
|
|
267
267
|
pool.getBorrowableA().getPoolToken().getSupplyAPR(),
|
|
268
268
|
pool.getBorrowableB().getPoolToken().getSupplyAPR()
|
|
269
269
|
]);
|
|
270
|
+
const totalBalanceUSD = valueA + valueB;
|
|
270
271
|
const lending = {
|
|
271
|
-
totalBalanceUSD
|
|
272
|
-
totalAPR: (valueA * aprA + valueB * aprB) /
|
|
272
|
+
totalBalanceUSD,
|
|
273
|
+
totalAPR: totalBalanceUSD > 0 ? (valueA * aprA + valueB * aprB) / totalBalanceUSD : 0
|
|
273
274
|
};
|
|
274
275
|
let collateralBalanceUSD = 0;
|
|
275
276
|
let collateralAPR = 0;
|
|
@@ -302,7 +303,7 @@ class OffchainAccount {
|
|
|
302
303
|
pool.getBorrowableB().getPoolToken().getTokenPriceAccurate(),
|
|
303
304
|
]);
|
|
304
305
|
collateralBalanceUSD += (position.getNetX() * priceX + position.getNetY() * priceY);
|
|
305
|
-
collateralAPR = position.getLeveragedApr();
|
|
306
|
+
collateralAPR = collateralBalanceUSD > 0 ? position.getLeveragedApr() : 0;
|
|
306
307
|
}
|
|
307
308
|
const borrowing = {
|
|
308
309
|
totalBalanceUSD: collateralBalanceUSD,
|
|
@@ -38,6 +38,10 @@ class OffchainNftlpUniswapV3 extends offchainNftlp_1.default {
|
|
|
38
38
|
lendingPool.getBorrowableA().getTokenPriceAccurate(),
|
|
39
39
|
lendingPool.getBorrowableB().getTokenPriceAccurate()
|
|
40
40
|
]);
|
|
41
|
+
if (!priceA || !priceB) {
|
|
42
|
+
console.warn("Can't calculate price for", await this.getLendingPool().getBorrowableA().getSymbol(), await this.getLendingPool().getBorrowableB().getSymbol());
|
|
43
|
+
return NaN;
|
|
44
|
+
}
|
|
41
45
|
return priceA / priceB;
|
|
42
46
|
}
|
|
43
47
|
// get basic UniswapV3Pool info given a fee
|
|
@@ -69,8 +69,8 @@ class OffchainLendingPool {
|
|
|
69
69
|
this.getBorrowableB().getTokenPriceAccurate()
|
|
70
70
|
]);
|
|
71
71
|
if (!priceA || !priceB) {
|
|
72
|
-
console.warn("Can't calculate price for", await this.getBorrowableA().getSymbol(), await this.
|
|
73
|
-
return
|
|
72
|
+
console.warn("Can't calculate price for", await this.getBorrowableA().getSymbol(), await this.getBorrowableB().getSymbol());
|
|
73
|
+
return NaN;
|
|
74
74
|
}
|
|
75
75
|
return priceA / priceB;
|
|
76
76
|
}
|
|
@@ -14,6 +14,7 @@ export interface GenericPositionParams {
|
|
|
14
14
|
}
|
|
15
15
|
export declare abstract class GenericPosition implements Position {
|
|
16
16
|
lockStateChange: boolean;
|
|
17
|
+
containsErrors: boolean;
|
|
17
18
|
state: number;
|
|
18
19
|
/**
|
|
19
20
|
* NOTICE all values inside this class are normalized (no decimals or mantissa to take into account)
|
|
@@ -6,9 +6,7 @@ const LOWEST_PRICE = 1 / 1e18;
|
|
|
6
6
|
const HIGHEST_PRICE = 1e18;
|
|
7
7
|
class GenericPosition {
|
|
8
8
|
constructor(params) {
|
|
9
|
-
|
|
10
|
-
console.log("Position initialization error: market price =", params.marketPrice);
|
|
11
|
-
}
|
|
9
|
+
this.containsErrors = isNaN(params.marketPrice);
|
|
12
10
|
this.liquidity = params.liquidity;
|
|
13
11
|
this.debtX = params.debtX;
|
|
14
12
|
this.debtY = params.debtY;
|