impermax-sdk 2.1.467 → 2.1.468

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.
@@ -5,7 +5,6 @@ import OffchainNftlpGenericCL from "./offchainNftlpGenericCL";
5
5
  export default class OffchainNftlpAeroCL extends OffchainNftlpGenericCL {
6
6
  getExtension(): Extension;
7
7
  getNewAccountNftlpObject(accountCollateral: OffchainAccountCollateralV3): OffchainAccountNftlpAeroCL;
8
- protected tickSpacings: () => number[];
9
8
  initializeFullRangeRateAccurate(tickSpacing: number): Promise<number>;
10
9
  getRewardsToken(): Promise<string>;
11
10
  getRewardsTokenPrice(): Promise<number>;
@@ -6,12 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const offchainAccountNftlpAeroCL_1 = __importDefault(require("../../account/lendingPool/nftlp/offchainAccountNftlpAeroCL"));
7
7
  const types_1 = require("../../../config/types");
8
8
  const offchainNftlpGenericCL_1 = __importDefault(require("./offchainNftlpGenericCL"));
9
- const aeroCLGeneral_1 = require("../../../utils/nftlpMath/aeroCLGeneral");
10
9
  class OffchainNftlpAeroCL extends offchainNftlpGenericCL_1.default {
11
- constructor() {
12
- super(...arguments);
13
- this.tickSpacings = () => aeroCLGeneral_1.AERO_TICK_SPACINGS;
14
- }
15
10
  getExtension() {
16
11
  return types_1.Extension.AeroCL;
17
12
  }
@@ -14,7 +14,7 @@ export default abstract class OffchainNftlpGenericCL extends OffchainNftlp {
14
14
  [key in number]: Promise<number>;
15
15
  };
16
16
  };
17
- protected abstract tickSpacings(): Array<number>;
17
+ tickSpacings(): Promise<Array<number>>;
18
18
  private priceAdjustment;
19
19
  tickToPrice(tick: number): Promise<number>;
20
20
  protected initializeMarketPrice(): Promise<number>;
@@ -11,6 +11,13 @@ class OffchainNftlpGenericCL extends offchainNftlp_1.default {
11
11
  super(...arguments);
12
12
  this.cache = {};
13
13
  }
14
+ async tickSpacings() {
15
+ const tickSpacings = [];
16
+ const nftlpGenericCLData = await this.getNftlpData();
17
+ const pools = nftlpGenericCLData.uniswapV3Pools;
18
+ pools.map((pool) => tickSpacings.push(parseInt(pool.tickSpacing)));
19
+ return tickSpacings;
20
+ }
14
21
  async priceAdjustment() {
15
22
  const decimalsA = await this.getLendingPool().getBorrowableA().getDecimals();
16
23
  const decimalsB = await this.getLendingPool().getBorrowableB().getDecimals();
@@ -79,7 +86,7 @@ class OffchainNftlpGenericCL extends offchainNftlp_1.default {
79
86
  public async getWeightedAvgFullRangeRate() {
80
87
  let totalTvl = 0;
81
88
  let totalCompoundedRate = 0;
82
- for (const tickSpacing of this.tickSpacings()) {
89
+ for (const tickSpacing of await this.tickSpacings()) {
83
90
  const { fullRangeRate, tvlUsd } = await this.getFullRangeRateAndTvl(tickSpacing);
84
91
  totalTvl += tvlUsd;
85
92
  totalCompoundedRate += fullRangeRate * tvlUsd;
@@ -112,7 +119,7 @@ class OffchainNftlpGenericCL extends offchainNftlp_1.default {
112
119
  }
113
120
  async getBestFullRangeRate() {
114
121
  let bestRate = 0;
115
- for (const tickSpacing of this.tickSpacings()) {
122
+ for (const tickSpacing of await this.tickSpacings()) {
116
123
  const rate = await this.getFullRangeRateAccurate(tickSpacing);
117
124
  bestRate = Math.max(bestRate, rate);
118
125
  }
@@ -5,6 +5,5 @@ import OffchainNftlpGenericCL from "./offchainNftlpGenericCL";
5
5
  export default class OffchainNftlpUniswapV3 extends OffchainNftlpGenericCL {
6
6
  getExtension(): Extension;
7
7
  getNewAccountNftlpObject(accountCollateral: OffchainAccountCollateralV3): OffchainAccountNftlpUniswapV3;
8
- protected tickSpacings: () => number[];
9
8
  initializeFullRangeRateAccurate(tickSpacing: number): Promise<number>;
10
9
  }
@@ -5,15 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const offchainAccountNftlpUniswapV3_1 = __importDefault(require("../../account/lendingPool/nftlp/offchainAccountNftlpUniswapV3"));
7
7
  const types_1 = require("../../../config/types");
8
- const uniswapV3General_1 = require("../../../utils/nftlpMath/uniswapV3General");
9
8
  const offchainNftlpGenericCL_1 = __importDefault(require("./offchainNftlpGenericCL"));
10
9
  const Q128 = 2 ** 128;
11
10
  const Q256 = BigInt(2) ** BigInt(256);
12
11
  class OffchainNftlpUniswapV3 extends offchainNftlpGenericCL_1.default {
13
- constructor() {
14
- super(...arguments);
15
- this.tickSpacings = () => uniswapV3General_1.UNIV3_TICK_SPACINGS;
16
- }
17
12
  getExtension() {
18
13
  return types_1.Extension.UniswapV3;
19
14
  }
@@ -11,7 +11,6 @@ export default class OnchainNftlpAeroCL extends OnchainNftlpGenericCL {
11
11
  getNewAccountNftlpObject(accountCollateral: OnchainAccountCollateralV3): any;
12
12
  getNewInteractionsNftlpObject(interactionsCollateral: OnchainInteractionsCollateralV3): OnchainInteractionsNftlpAeroCL;
13
13
  getOffchainNftlp: () => Promise<OffchainNftlpAeroCL>;
14
- protected tickSpacings: () => number[];
15
14
  protected initializeNftlp(): any;
16
15
  protected initializeCLPool(tickSpacing: number): Promise<Contract | null>;
17
16
  protected initializeNfpm(): Promise<any>;
@@ -7,12 +7,10 @@ const types_1 = require("../../../../config/types");
7
7
  const onchainAccountNftlpAeroCL_1 = __importDefault(require("../../../account/lendingPool/nftlp/onchainAccountNftlpAeroCL"));
8
8
  const onchainInteractionsNftlpAeroCL_1 = __importDefault(require("../../../interactions/lendingPool/nftlp/onchainInteractionsNftlpAeroCL"));
9
9
  const onchainNftlpGenericCL_1 = __importDefault(require("./onchainNftlpGenericCL"));
10
- const aeroCLGeneral_1 = require("../../../../utils/nftlpMath/aeroCLGeneral");
11
10
  class OnchainNftlpAeroCL extends onchainNftlpGenericCL_1.default {
12
11
  constructor() {
13
12
  super(...arguments);
14
13
  this.getOffchainNftlp = async () => (await this.getLendingPool().getOffchainLendingPool()).getNftlp();
15
- this.tickSpacings = () => aeroCLGeneral_1.AERO_TICK_SPACINGS;
16
14
  }
17
15
  getExtension() {
18
16
  return types_1.Extension.AeroCL;
@@ -11,7 +11,7 @@ export default abstract class OnchainNftlpGenericCL extends OnchainNftlp {
11
11
  oraclePrice?: Promise<number>;
12
12
  };
13
13
  getOffchainNftlp: () => Promise<OffchainNftlpGenericCL>;
14
- protected abstract tickSpacings(): Array<number>;
14
+ protected tickSpacings(): Promise<Array<number>>;
15
15
  protected abstract initializeCLPool(tickSpacing: number): Promise<Contract | null>;
16
16
  getCLPool(tickSpacing: number): Promise<any>;
17
17
  protected priceAdjustment(): Promise<number>;
@@ -11,6 +11,9 @@ class OnchainNftlpGenericCL extends onchainNftlp_1.default {
11
11
  this.cache = {};
12
12
  this.getOffchainNftlp = async () => (await this.getLendingPool().getOffchainLendingPool()).getNftlp();
13
13
  }
14
+ async tickSpacings() {
15
+ return (await this.getOffchainNftlp()).tickSpacings();
16
+ }
14
17
  async getCLPool(tickSpacing) {
15
18
  if (!this.cache.clPools)
16
19
  this.cache.clPools = {};
@@ -27,7 +30,7 @@ class OnchainNftlpGenericCL extends onchainNftlp_1.default {
27
30
  let priceCumulative = 0;
28
31
  let liquidityCumulative = 0;
29
32
  const priceAdjustment = await this.priceAdjustment();
30
- await Promise.all(this.tickSpacings().map(async (tickSpacing) => {
33
+ await Promise.all((await this.tickSpacings()).map(async (tickSpacing) => {
31
34
  const pool = await this.getCLPool(tickSpacing);
32
35
  if (!pool)
33
36
  return;
@@ -11,7 +11,6 @@ export default class OnchainNftlpUniswapV3 extends OnchainNftlpGenericCL {
11
11
  getNewAccountNftlpObject(accountCollateral: OnchainAccountCollateralV3): OnchainAccountNftlpUniswapV3;
12
12
  getNewInteractionsNftlpObject(interactionsCollateral: OnchainInteractionsCollateralV3): OnchainInteractionsNftlpUniswapV3;
13
13
  getOffchainNftlp: () => Promise<OffchainNftlpUniswapV3>;
14
- protected tickSpacings: () => number[];
15
14
  protected initializeNftlp(): any;
16
15
  protected initializeCLPool(tickSpacing: number): Promise<Contract | null>;
17
16
  }
@@ -12,7 +12,6 @@ class OnchainNftlpUniswapV3 extends onchainNftlpGenericCL_1.default {
12
12
  constructor() {
13
13
  super(...arguments);
14
14
  this.getOffchainNftlp = async () => (await this.getLendingPool().getOffchainLendingPool()).getNftlp();
15
- this.tickSpacings = () => uniswapV3General_1.UNIV3_TICK_SPACINGS;
16
15
  }
17
16
  getExtension() {
18
17
  return types_1.Extension.UniswapV3;
@@ -1,3 +1,2 @@
1
- export declare const UNIV3_TICK_SPACINGS: number[];
2
1
  export declare function uniV3FeeToTickSpacing(fee: number): any;
3
2
  export declare function uniV3TickSpacingToFee(tickSpacing: number): any;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uniV3TickSpacingToFee = exports.uniV3FeeToTickSpacing = exports.UNIV3_TICK_SPACINGS = void 0;
3
+ exports.uniV3TickSpacingToFee = exports.uniV3FeeToTickSpacing = void 0;
4
4
  // https://support.uniswap.org/hc/en-us/articles/21069524840589-What-is-a-tick-when-providing-liquidity
5
5
  const UNIV3_FEE_TO_TICK_SPACING = {
6
6
  100: 1,
@@ -20,12 +20,6 @@ const UNIV3_TICK_SPACING_TO_FEE = {
20
20
  60: 3000,
21
21
  200: 10000,
22
22
  };
23
- exports.UNIV3_TICK_SPACINGS = [
24
- 1,
25
- 10,
26
- 60,
27
- 200,
28
- ];
29
23
  function uniV3FeeToTickSpacing(fee) {
30
24
  if (!UNIV3_FEE_TO_TICK_SPACING[fee])
31
25
  throw new Error("Unsupported Uniswap V3 fee!");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.467",
3
+ "version": "2.1.468",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -1 +0,0 @@
1
- export declare const AERO_TICK_SPACINGS: number[];
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AERO_TICK_SPACINGS = void 0;
4
- exports.AERO_TICK_SPACINGS = [
5
- 1,
6
- 50,
7
- 100,
8
- 200,
9
- 2000,
10
- ];