impermax-sdk 2.1.416 → 2.1.418

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.
@@ -36,12 +36,8 @@ class OnchainLendingPoolV2 extends onchainLendingPool_1.default {
36
36
  }
37
37
  // Lending Pool V2 functions
38
38
  async initializeIsStakedLPToken() {
39
- try {
40
- return await this.impermaxFactory.getRouter().methods.isStakedLPToken(this.id).call();
41
- }
42
- catch (e) {
43
- return false;
44
- }
39
+ const offchainLendingPool = await this.getOffchainLendingPool();
40
+ return offchainLendingPool.isStakedLPToken();
45
41
  }
46
42
  async getIsStakedLPToken() {
47
43
  if (!this.cache.isStakedLPToken)
@@ -59,10 +55,9 @@ class OnchainLendingPoolV2 extends onchainLendingPool_1.default {
59
55
  return this.cache.stakedLPToken;
60
56
  }
61
57
  async initializeUniswapV2Pair() {
62
- const stakedLPToken = await this.getOffchainLendingPool();
63
- return this.getContractHelper().newUniswapV2Pair(stakedLPToken
64
- ? await stakedLPToken.getUniswapV2PairAddress()
65
- : this.id);
58
+ const offchainLendingPool = await this.getOffchainLendingPool();
59
+ const isStakedLPToken = await this.getStakedLPToken();
60
+ return this.getContractHelper().newUniswapV2Pair(isStakedLPToken ? await offchainLendingPool.getUniswapV2PairAddress() : this.id);
66
61
  }
67
62
  async getUniswapV2Pair() {
68
63
  if (!this.cache.uniswapV2Pair)
@@ -37,18 +37,10 @@ export declare class UniswapV3Position extends GenericPosition {
37
37
  protected getVirtualY(liquidity: number, price: number): number;
38
38
  protected getRealXGivenLiquidityAndPrice(liquidity: number, price: number): number;
39
39
  protected getRealYGivenLiquidityAndPrice(liquidity: number, price: number): number;
40
- protected getInitialCollateralValue(): number;
41
- protected getCollateralValueGivenPrice(price: number): number;
42
- protected getUsableCollateralValueGivenPrice(price: number): number;
43
- protected getUsableCollateralValueGivenPriceAndDeltaLeverage(price: number, deltaX: number, deltaY: number): number;
44
40
  protected getLiquidityGivenAmounts(amountX: number, amountY: number): number;
45
41
  /**
46
42
  * PUBLIC GETTERS
47
43
  */
48
- getInitialDepositedX(): any;
49
- getInitialDepositedY(): any;
50
- getDepositedX(): any;
51
- getDepositedY(): any;
52
44
  getBaseRate(): number;
53
45
  getOptimalLiquidity(maxAmountX: number, maxAmountY: number): {
54
46
  liquidity: number;
@@ -25,9 +25,6 @@ class UniswapV3Position extends genericPosition_1.default {
25
25
  if (Number.isNaN(liquidity) || liquidity === Infinity)
26
26
  return;
27
27
  this.liquidity = Math.max(liquidity, 0);
28
- const percentageOfInitial = this.initialLiquidity > 0 ? Math.min(liquidity / this.initialLiquidity, 1) : 0;
29
- this.unclaimedFeesX = this.initialUnclaimedFeesX * percentageOfInitial;
30
- this.unclaimedFeesY = this.initialUnclaimedFeesY * percentageOfInitial;
31
28
  }
32
29
  /**
33
30
  * protected GETTERS
@@ -48,19 +45,6 @@ class UniswapV3Position extends genericPosition_1.default {
48
45
  const virtualY = this.getVirtualY(liquidity, Math.min(price, this.priceB));
49
46
  return Math.max(virtualY - surplusY, 0);
50
47
  }
51
- getInitialCollateralValue() {
52
- return this.getValueGivenAmounts(this.getInitialRealX() + this.initialUnclaimedFeesX, this.getInitialRealY() + this.initialUnclaimedFeesY);
53
- }
54
- getCollateralValueGivenPrice(price) {
55
- return this.getValueGivenPriceAndAmounts(price, this.getRealXGivenPrice(price) + this.unclaimedFeesX, this.getRealYGivenPrice(price) + this.unclaimedFeesY);
56
- }
57
- getUsableCollateralValueGivenPrice(price) {
58
- return this.getValueGivenPriceAndAmounts(price, this.getRealXGivenPrice(price) + this.unclaimedFeesX * FEE_COLLECTED_WEIGHT, this.getRealYGivenPrice(price) + this.unclaimedFeesY * FEE_COLLECTED_WEIGHT);
59
- }
60
- getUsableCollateralValueGivenPriceAndDeltaLeverage(price, deltaX, deltaY) {
61
- const liquidity = this.getLiquidityGivenAmounts(deltaX, deltaY);
62
- return this.getValueGivenPriceAndAmounts(price, this.getRealXGivenLiquidityAndPrice(this.liquidity + liquidity, price) + this.unclaimedFeesX * FEE_COLLECTED_WEIGHT, this.getRealYGivenLiquidityAndPrice(this.liquidity + liquidity, price) + this.unclaimedFeesY * FEE_COLLECTED_WEIGHT);
63
- }
64
48
  getLiquidityGivenAmounts(amountX, amountY) {
65
49
  if (amountX == 0) {
66
50
  return amountY / Math.sqrt(this.priceB);
@@ -73,18 +57,6 @@ class UniswapV3Position extends genericPosition_1.default {
73
57
  /**
74
58
  * PUBLIC GETTERS
75
59
  */
76
- getInitialDepositedX() {
77
- return this.getInitialRealX() + this.initialUnclaimedFeesX;
78
- }
79
- getInitialDepositedY() {
80
- return this.getInitialRealY() + this.initialUnclaimedFeesY;
81
- }
82
- getDepositedX() {
83
- return this.getRealX() + this.unclaimedFeesX;
84
- }
85
- getDepositedY() {
86
- return this.getRealY() + this.unclaimedFeesY;
87
- }
88
60
  getBaseRate() {
89
61
  // return 0 if out of range
90
62
  if (this.priceA > this.marketPrice)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.416",
3
+ "version": "2.1.418",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",