impermax-sdk 2.1.468 → 2.1.470

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.
Files changed (49) hide show
  1. package/lib/config/private-api.d.ts +4 -2
  2. package/lib/config/private-api.js +9 -7
  3. package/lib/offchain/account/lendingPool/nftlp/offchainAccountNftlpAeroCL.js +1 -1
  4. package/lib/offchain/account/lendingPool/nftlp/offchainAccountNftlpGenericCL.js +1 -1
  5. package/lib/offchain/initializer/privateApi/index.d.ts +1 -2
  6. package/lib/offchain/initializer/privateApi/index.js +1 -3
  7. package/lib/offchain/initializer/privateApi/nftlpsApi/index.d.ts +3 -0
  8. package/lib/offchain/initializer/privateApi/{lendingPoolsApi/nftlp/aerodromeV3 → nftlpsApi}/index.js +3 -1
  9. package/lib/offchain/initializer/privateApi/{lendingPoolsApi/nftlp/tvl → nftlpsApi/positions}/nftlpTvl.d.ts +2 -2
  10. package/lib/offchain/initializer/privateApi/{lendingPoolsApi/nftlp/tvl → nftlpsApi/positions}/nftlpTvl.js +1 -2
  11. package/lib/offchain/initializer/privateApi/nftlpsApi/uniswapV3Pools/charts.d.ts +5 -0
  12. package/lib/offchain/initializer/privateApi/{lendingPoolsApi/nftlp/uniswapV3/uniswapV3Charts.js → nftlpsApi/uniswapV3Pools/charts.js} +12 -13
  13. package/lib/offchain/initializer/privateApi/nftlpsApi/uniswapV3Pools/index.d.ts +1 -0
  14. package/lib/offchain/initializer/privateApi/{lendingPoolsApi → nftlpsApi/uniswapV3Pools}/index.js +1 -1
  15. package/lib/offchain/initializer/privateApi/{userApi/nfltp → nftlpsApi/user/aeroCL}/index.d.ts +0 -1
  16. package/lib/offchain/initializer/privateApi/{userApi/nfltp/fees → nftlpsApi/user/aeroCL}/index.js +1 -1
  17. package/lib/offchain/initializer/privateApi/nftlpsApi/user/aeroCL/rewards.d.ts +5 -0
  18. package/lib/offchain/initializer/privateApi/{userApi/nfltp/rewards/aerodromeV3Rewards.js → nftlpsApi/user/aeroCL/rewards.js} +6 -6
  19. package/lib/offchain/initializer/privateApi/nftlpsApi/user/index.d.ts +2 -0
  20. package/lib/offchain/initializer/privateApi/{userApi/nfltp → nftlpsApi/user}/index.js +3 -3
  21. package/lib/offchain/initializer/privateApi/{userApi/nfltp/fees/uniswapV3Fees.js → nftlpsApi/user/uniswapv3/fees.js} +0 -2
  22. package/lib/offchain/initializer/privateApi/nftlpsApi/user/uniswapv3/index.d.ts +1 -0
  23. package/lib/offchain/initializer/privateApi/{userApi → nftlpsApi/user/uniswapv3}/index.js +1 -1
  24. package/lib/offchain/lendingPool/nftlp/offchainNftlpUniswapV3.js +1 -1
  25. package/lib/offchain/offchain.d.ts +10 -16
  26. package/lib/offchain/offchain.js +13 -27
  27. package/lib/offchain/offchainTypes.d.ts +6 -1
  28. package/package.json +1 -1
  29. package/lib/offchain/initializer/privateApi/lendingPoolsApi/index.d.ts +0 -1
  30. package/lib/offchain/initializer/privateApi/lendingPoolsApi/nftlp/aerodromeV3/aerodromeV3Charts.d.ts +0 -5
  31. package/lib/offchain/initializer/privateApi/lendingPoolsApi/nftlp/aerodromeV3/aerodromeV3Charts.js +0 -38
  32. package/lib/offchain/initializer/privateApi/lendingPoolsApi/nftlp/aerodromeV3/index.d.ts +0 -1
  33. package/lib/offchain/initializer/privateApi/lendingPoolsApi/nftlp/index.d.ts +0 -3
  34. package/lib/offchain/initializer/privateApi/lendingPoolsApi/nftlp/index.js +0 -19
  35. package/lib/offchain/initializer/privateApi/lendingPoolsApi/nftlp/uniswapV3/index.d.ts +0 -1
  36. package/lib/offchain/initializer/privateApi/lendingPoolsApi/nftlp/uniswapV3/index.js +0 -17
  37. package/lib/offchain/initializer/privateApi/lendingPoolsApi/nftlp/uniswapV3/uniswapV3Charts.d.ts +0 -5
  38. package/lib/offchain/initializer/privateApi/userApi/index.d.ts +0 -1
  39. package/lib/offchain/initializer/privateApi/userApi/nfltp/fees/index.d.ts +0 -1
  40. package/lib/offchain/initializer/privateApi/userApi/nfltp/rewards/aerodromeV3Rewards.d.ts +0 -5
  41. package/lib/offchain/initializer/privateApi/userApi/nfltp/rewards/index.d.ts +0 -1
  42. package/lib/offchain/initializer/privateApi/userApi/nfltp/rewards/index.js +0 -17
  43. package/lib/offchain/initializer/privateApi/vaultsApi/index.d.ts +0 -0
  44. package/lib/offchain/initializer/privateApi/vaultsApi/index.js +0 -1
  45. package/lib/offchain/initializer/privateApi/vaultsApi/vaultBorrowables.d.ts +0 -0
  46. package/lib/offchain/initializer/privateApi/vaultsApi/vaultBorrowables.js +0 -54
  47. /package/lib/offchain/initializer/privateApi/{lendingPoolsApi/nftlp/tvl → nftlpsApi/positions}/index.d.ts +0 -0
  48. /package/lib/offchain/initializer/privateApi/{lendingPoolsApi/nftlp/tvl → nftlpsApi/positions}/index.js +0 -0
  49. /package/lib/offchain/initializer/privateApi/{userApi/nfltp/fees/uniswapV3Fees.d.ts → nftlpsApi/user/uniswapv3/fees.d.ts} +0 -0
@@ -1,12 +1,14 @@
1
1
  import { NetworkVaultTypeIndex, NetworkFactoryIndex, NetworkExtensionIndex } from "./types";
2
+ /**
3
+ * Single endpoint for all factory subgraph token prices
4
+ */
5
+ export declare const PRICE_AGGREGATOR_API_URL = "https://price-aggregator-production.up.railway.app/api/tokens";
2
6
  /**
3
7
  * Private API Endpoints which we might need to use in future for non-core
4
8
  * things (ie. charts, leaderboards, etc.). The app must function well
5
9
  * without any of these endpoints, so just nice to haves.
6
- * TODO: make sure that the app still works when one of these endpoints is down
7
10
  */
8
11
  export declare const IMPERMAX_POOLS_API: NetworkFactoryIndex<string>;
9
12
  export declare const IMPERMAX_VAULT_API: NetworkVaultTypeIndex<string>;
10
13
  export declare const NFTLP_API: NetworkExtensionIndex<string>;
11
- export declare const PRICE_AGGREGATOR_API_URL = "https://price-aggregator-production.up.railway.app/api/tokens";
12
14
  export declare const NFTLP_POSITIONS_API: NetworkExtensionIndex<string>;
@@ -1,14 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NFTLP_POSITIONS_API = exports.PRICE_AGGREGATOR_API_URL = exports.NFTLP_API = exports.IMPERMAX_VAULT_API = exports.IMPERMAX_POOLS_API = void 0;
3
+ exports.NFTLP_POSITIONS_API = exports.NFTLP_API = exports.IMPERMAX_VAULT_API = exports.IMPERMAX_POOLS_API = exports.PRICE_AGGREGATOR_API_URL = void 0;
4
4
  const types_1 = require("./types");
5
+ /**
6
+ * Single endpoint for all factory subgraph token prices
7
+ */
8
+ exports.PRICE_AGGREGATOR_API_URL = "https://price-aggregator-production.up.railway.app/api/tokens";
5
9
  /**
6
10
  * Private API Endpoints which we might need to use in future for non-core
7
11
  * things (ie. charts, leaderboards, etc.). The app must function well
8
12
  * without any of these endpoints, so just nice to haves.
9
- * TODO: make sure that the app still works when one of these endpoints is down
10
13
  */
11
- // For lending pools
14
+ // API: Lending pools
12
15
  exports.IMPERMAX_POOLS_API = {
13
16
  [types_1.Networks.Ropsten]: {},
14
17
  [types_1.Networks.Mainnet]: {},
@@ -34,7 +37,7 @@ exports.IMPERMAX_POOLS_API = {
34
37
  [types_1.Networks.Linea]: {},
35
38
  [types_1.Networks.Unichain]: {},
36
39
  };
37
- // For lending pools
40
+ // API: Lending vaults
38
41
  exports.IMPERMAX_VAULT_API = {
39
42
  [types_1.Networks.Ropsten]: {},
40
43
  [types_1.Networks.Mainnet]: {},
@@ -76,6 +79,7 @@ exports.IMPERMAX_VAULT_API = {
76
79
  [types_1.VaultType.LENDING]: "https://unichain-lendingvaults-production.up.railway.app/"
77
80
  },
78
81
  };
82
+ // API: NFTLP
79
83
  exports.NFTLP_API = {
80
84
  [types_1.Networks.Ropsten]: {},
81
85
  [types_1.Networks.Mainnet]: {},
@@ -108,9 +112,7 @@ exports.NFTLP_API = {
108
112
  [types_1.Extension.UniswapV3]: "https://unichain-nftlp-uniswapv3.up.railway.app/"
109
113
  },
110
114
  };
111
- // Single endpoint for all factory subgraph token prices
112
- exports.PRICE_AGGREGATOR_API_URL = "https://price-aggregator-production.up.railway.app/api/tokens";
113
- // TODO: This properly
115
+ // API: Positions/NFTLP TVL
114
116
  exports.NFTLP_POSITIONS_API = {
115
117
  [types_1.Networks.Ropsten]: {},
116
118
  [types_1.Networks.Mainnet]: {},
@@ -26,7 +26,7 @@ class OffchainAccountNftlpAeroCL extends offchainAccountNftlpGenericCL_1.default
26
26
  const positionId = `${lendingPoolId}-${tokenId}`;
27
27
  try {
28
28
  const account = this.getLendingPool().getAccount().getAccountAddress();
29
- const newlyEarnedRewards = await this.getLendingPool().getLendingPool().getOffchain().getAerodromeV3NewlyEarnedRewards(account, positionId);
29
+ const newlyEarnedRewards = await this.getLendingPool().getLendingPool().getOffchain().getAeroCLNewlyEarnedRewards(account, positionId);
30
30
  this.cache.newlyEarnedReward[tokenId] = Number(newlyEarnedRewards?.newlyEarnedReward) ?? 0;
31
31
  return this.cache.newlyEarnedReward[tokenId];
32
32
  }
@@ -75,7 +75,7 @@ class OffchainAccountNftlpGenericCL extends offchainAccountNftlp_1.default {
75
75
  liquidationPenalty: await this.getLendingPool().getLiquidationPenalty(),
76
76
  borrowableX: await this.getNftlp().getLendingPool().getBorrowableA().createBorrowableObject(),
77
77
  borrowableY: await this.getNftlp().getLendingPool().getBorrowableB().createBorrowableObject(),
78
- fullRangeRate: await this.getNftlp().getFullRangeRate(await this.getFee(tokenId)),
78
+ fullRangeRate: await this.getNftlp().getFullRangeRate(await this.getTickSpacing(tokenId)),
79
79
  });
80
80
  }
81
81
  async getPositionObject(tokenId) {
@@ -1,2 +1 @@
1
- export * from './lendingPoolsApi';
2
- export * from './userApi';
1
+ export * from './nftlpsApi';
@@ -14,6 +14,4 @@ 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
- // export * from './vaultsApi'
18
- __exportStar(require("./lendingPoolsApi"), exports);
19
- __exportStar(require("./userApi"), exports);
17
+ __exportStar(require("./nftlpsApi"), exports);
@@ -0,0 +1,3 @@
1
+ export * from './positions';
2
+ export * from './uniswapV3Pools';
3
+ export * from './user';
@@ -14,4 +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("./aerodromeV3Charts"), exports);
17
+ __exportStar(require("./positions"), exports);
18
+ __exportStar(require("./uniswapV3Pools"), exports);
19
+ __exportStar(require("./user"), exports);
@@ -1,5 +1,5 @@
1
- import { AddressIndex, Extension, Address } from "../../../../../../config/types";
1
+ import { AddressIndex, Extension, Address } from "../../../../../config/types";
2
2
  import Offchain from "../../../../../offchain";
3
- import { NftlpStats } from "../../../../../offchainTypes";
3
+ import { NftlpStats } from "../../../../offchainTypes";
4
4
  export declare function fetchNftlpTvls(this: Offchain, extension: Extension): Promise<AddressIndex<NftlpStats>>;
5
5
  export declare function getNftlpTvl(this: Offchain, extension: Extension, nftlpAddress: Address): Promise<NftlpStats | undefined>;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNftlpTvl = exports.fetchNftlpTvls = void 0;
4
- const private_api_1 = require("../../../../../../config/private-api");
5
- // TODO: getNftlpTvl should be done by extension -> nftlpAddress
4
+ const private_api_1 = require("../../../../../config/private-api");
6
5
  /*--------------------------------------------------------------------------*
7
6
  * Fetchers *
8
7
  *--------------------------------------------------------------------------*/
@@ -0,0 +1,5 @@
1
+ import { AddressIndex, Extension, Address } from "../../../../../config/types";
2
+ import Offchain from "../../../../../offchain";
3
+ import { PoolChart } from "../../../../offchainTypes";
4
+ export declare function fetchUniswapV3PoolCharts(this: Offchain, extension: Extension): Promise<AddressIndex<PoolChart[]>>;
5
+ export declare function getUniswapV3PoolChart(this: Offchain, extension: Extension, uniswapV3Pool: Address): Promise<PoolChart[]>;
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  // private-api: uniswapv3 charts
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getUniswapV3Chart = exports.fetchUniswapV3Charts = void 0;
5
- const types_1 = require("../../../../../../config/types");
6
- const private_api_1 = require("../../../../../../config/private-api");
4
+ exports.getUniswapV3PoolChart = exports.fetchUniswapV3PoolCharts = void 0;
5
+ const private_api_1 = require("../../../../../config/private-api");
7
6
  /*--------------------------------------------------------------------------*
8
7
  * Fetchers *
9
8
  *--------------------------------------------------------------------------*/
10
9
  // Fetches all charts of all lending pools for an NFTLP factory (ie. Dex)
11
- async function fetchUniswapV3Charts() {
12
- const api = private_api_1.NFTLP_API[this.network][types_1.Extension.UniswapV3];
10
+ async function fetchUniswapV3PoolCharts(extension) {
11
+ const api = private_api_1.NFTLP_API[this.network][extension];
13
12
  if (!api) {
14
13
  // console.log(`Missing NFTLP cl subgraph on ${this.network}?`)
15
14
  return {};
@@ -19,19 +18,19 @@ async function fetchUniswapV3Charts() {
19
18
  return response;
20
19
  }
21
20
  catch (err) {
22
- console.log(`Failed to fetch uniswapV3 Pool data on ${this.network}`);
21
+ console.log(`Failed to fetch uniswapV3 Pool data on ${this.network} for extension ${extension}`);
23
22
  return {};
24
23
  }
25
24
  }
26
- exports.fetchUniswapV3Charts = fetchUniswapV3Charts;
25
+ exports.fetchUniswapV3PoolCharts = fetchUniswapV3PoolCharts;
27
26
  /*--------------------------------------------------------------------------*
28
27
  * Getters *
29
28
  *--------------------------------------------------------------------------*/
30
- async function getUniswapV3Chart(uniswapV3Pool) {
31
- if (!this.extensionChartsData[types_1.Extension.UniswapV3]) {
32
- this.extensionChartsData[types_1.Extension.UniswapV3] = this.fetchUniswapV3Charts();
29
+ async function getUniswapV3PoolChart(extension, uniswapV3Pool) {
30
+ if (!this.extensionChartsData[extension]) {
31
+ this.extensionChartsData[extension] = this.fetchUniswapV3PoolCharts(extension);
33
32
  }
34
- const poolChartData = await this.extensionChartsData[types_1.Extension.UniswapV3];
35
- return poolChartData[uniswapV3Pool];
33
+ const poolChartData = await this.extensionChartsData[extension];
34
+ return poolChartData?.[uniswapV3Pool] ?? [];
36
35
  }
37
- exports.getUniswapV3Chart = getUniswapV3Chart;
36
+ exports.getUniswapV3PoolChart = getUniswapV3PoolChart;
@@ -0,0 +1 @@
1
+ export * from './charts';
@@ -14,4 +14,4 @@ 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("./nftlp"), exports);
17
+ __exportStar(require("./charts"), exports);
@@ -1,2 +1 @@
1
- export * from "./fees";
2
1
  export * from "./rewards";
@@ -14,4 +14,4 @@ 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("./uniswapV3Fees"), exports);
17
+ __exportStar(require("./rewards"), exports);
@@ -0,0 +1,5 @@
1
+ import { AddressIndex, Address } from "../../../../../../config/types";
2
+ import Offchain from "../../../../../offchain";
3
+ import { NewlyEarnedReward } from "../../../../../offchainTypes";
4
+ export declare function fetchAeroCLNewlyEarnedRewards(this: Offchain, account: Address): Promise<AddressIndex<NewlyEarnedReward>>;
5
+ export declare function getAeroCLNewlyEarnedRewards(this: Offchain, account: Address, positionId: string): Promise<NewlyEarnedReward | undefined>;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  // private-api: aerodromeV3 reward
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getAerodromeV3NewlyEarnedRewards = exports.fetchAerodromeV3NewlyEarnedRewards = void 0;
4
+ exports.getAeroCLNewlyEarnedRewards = exports.fetchAeroCLNewlyEarnedRewards = void 0;
5
5
  const types_1 = require("../../../../../../config/types");
6
6
  const private_api_1 = require("../../../../../../config/private-api");
7
7
  /*--------------------------------------------------------------------------*
8
8
  * Fetchers *
9
9
  *--------------------------------------------------------------------------*/
10
- async function fetchAerodromeV3NewlyEarnedRewards(account) {
10
+ async function fetchAeroCLNewlyEarnedRewards(account) {
11
11
  const api = private_api_1.NFTLP_API[this.network][types_1.Extension.AeroCL];
12
12
  if (!api) {
13
13
  console.log(`Missing NFTLP aerodromeV3 reward api on ${this.network}?`);
@@ -29,17 +29,17 @@ async function fetchAerodromeV3NewlyEarnedRewards(account) {
29
29
  return {};
30
30
  }
31
31
  }
32
- exports.fetchAerodromeV3NewlyEarnedRewards = fetchAerodromeV3NewlyEarnedRewards;
32
+ exports.fetchAeroCLNewlyEarnedRewards = fetchAeroCLNewlyEarnedRewards;
33
33
  /*--------------------------------------------------------------------------*
34
34
  * Getters *
35
35
  *--------------------------------------------------------------------------*/
36
- async function getAerodromeV3NewlyEarnedRewards(account, positionId) {
36
+ async function getAeroCLNewlyEarnedRewards(account, positionId) {
37
37
  if (!this.userNewlyEarnedRewardData[account])
38
38
  this.userNewlyEarnedRewardData[account] = {};
39
39
  if (!this.userNewlyEarnedRewardData[account][types_1.Extension.AeroCL]) {
40
- this.userNewlyEarnedRewardData[account][types_1.Extension.AeroCL] = this.fetchAerodromeV3NewlyEarnedRewards(account);
40
+ this.userNewlyEarnedRewardData[account][types_1.Extension.AeroCL] = this.fetchAeroCLNewlyEarnedRewards(account);
41
41
  }
42
42
  const feesData = await this.userNewlyEarnedRewardData[account][types_1.Extension.AeroCL];
43
43
  return feesData?.[positionId];
44
44
  }
45
- exports.getAerodromeV3NewlyEarnedRewards = getAerodromeV3NewlyEarnedRewards;
45
+ exports.getAeroCLNewlyEarnedRewards = getAeroCLNewlyEarnedRewards;
@@ -0,0 +1,2 @@
1
+ export * from "./uniswapv3";
2
+ export * from "./aeroCL";
@@ -15,6 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // For UniswapV3 position new fees earned
18
- __exportStar(require("./fees"), exports);
19
- // For AerodromeV3 position new rewards earned
20
- __exportStar(require("./rewards"), exports);
18
+ __exportStar(require("./uniswapv3"), exports);
19
+ // For AeroCL position new rewards earned
20
+ __exportStar(require("./aeroCL"), exports);
@@ -7,8 +7,6 @@ const private_api_1 = require("../../../../../../config/private-api");
7
7
  /*--------------------------------------------------------------------------*
8
8
  * Fetchers *
9
9
  *--------------------------------------------------------------------------*/
10
- // TODO: Make this better by using getnftlppositions
11
- // const nftlpPositions = await this.offchainMultichain.getMultichainAccount(account).getNftlpPositions();
12
10
  async function fetchUniswapV3NewlyEarnedFees(account) {
13
11
  const api = private_api_1.NFTLP_API[this.network][types_1.Extension.UniswapV3];
14
12
  if (!api) {
@@ -14,4 +14,4 @@ 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("./nfltp"), exports);
17
+ __exportStar(require("./fees"), exports);
@@ -72,7 +72,7 @@ class OffchainNftlpUniswapV3 extends offchainNftlpGenericCL_1.default {
72
72
  return 0;
73
73
  let feeGrowthData = [];
74
74
  try {
75
- feeGrowthData = await this.getLendingPool().getOffchain().getUniswapV3Charts(address.toLowerCase());
75
+ feeGrowthData = await this.getLendingPool().getOffchain().getUniswapV3PoolChart(this.getExtension(), address.toLowerCase());
76
76
  }
77
77
  catch (err) { }
78
78
  if (!feeGrowthData || feeGrowthData.length < 2) {
@@ -2,8 +2,8 @@ import * as initializer from './initializer';
2
2
  import OffchainLendingPool from './lendingPool';
3
3
  import OffchainSolidexHelper from './offchainSolidexHelper';
4
4
  import OffchainAccount from './account';
5
- import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex, Networks, WhitelistState, VaultType, Extension } from '../config/types';
6
- import { LendingPoolData, VaultData, VaultPosition, TvlData, UserData, XIbexData, VaultBorrowable, NftlpData, PoolChart, NewlyEarnedFees, NftlpStats, XIbexUserData, NewlyEarnedReward } from './offchainTypes';
5
+ import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex, Networks, WhitelistState, Extension } from '../config/types';
6
+ import { LendingPoolData, VaultData, VaultPosition, TvlData, UserData, XIbexData, NftlpData, PoolChart, NewlyEarnedFees, NftlpStats, XIbexUserData, NewlyEarnedReward } from './offchainTypes';
7
7
  import OffchainVault from './vault/offchainVault';
8
8
  import OffchainConfigManager from './configManager';
9
9
  import { PairState } from '../config/whitelist';
@@ -47,25 +47,30 @@ export default class Offchain {
47
47
  protected xibexUsersData: {
48
48
  [key in Address]?: Promise<XIbexUserData | null>;
49
49
  };
50
- protected vaultBorrowablesData: {
51
- [key in VaultType]?: Promise<AddressIndex<VaultBorrowable[]>>;
52
- };
53
50
  protected extensionChartsData: {
54
51
  [key in Extension]?: Promise<AddressIndex<PoolChart[]>>;
55
52
  };
53
+ protected fetchUniswapV3PoolCharts: typeof initializer.fetchUniswapV3PoolCharts;
54
+ getUniswapV3PoolChart: typeof initializer.getUniswapV3PoolChart;
56
55
  protected extensionStatsData: {
57
56
  [key in Extension]?: Promise<AddressIndex<NftlpStats>>;
58
57
  };
58
+ protected fetchNftlpTvls: typeof initializer.fetchNftlpTvls;
59
+ getNftlpTvl: typeof initializer.getNftlpTvl;
59
60
  protected userNewlyEarnedFeesData: {
60
61
  [address: Address]: {
61
62
  [key in Extension]?: Promise<AddressIndex<NewlyEarnedFees>>;
62
63
  };
63
64
  };
65
+ protected fetchUniswapV3NewlyEarnedFees: typeof initializer.fetchUniswapV3NewlyEarnedFees;
66
+ getUniswapV3NewlyEarnedFees: typeof initializer.getUniswapV3NewlyEarnedFees;
64
67
  protected userNewlyEarnedRewardData: {
65
68
  [address: Address]: {
66
69
  [key in Extension]?: Promise<AddressIndex<NewlyEarnedReward>>;
67
70
  };
68
71
  };
72
+ protected fetchAeroCLNewlyEarnedRewards: typeof initializer.fetchAeroCLNewlyEarnedRewards;
73
+ getAeroCLNewlyEarnedRewards: typeof initializer.getAeroCLNewlyEarnedRewards;
69
74
  constructor(offchainMultichain: OffchainMultichain, network: Networks);
70
75
  cleanCache(): Promise<void>;
71
76
  getLendingPool(factory: Factory, pairAddress: Address): Promise<OffchainLendingPool | null>;
@@ -108,8 +113,6 @@ export default class Offchain {
108
113
  protected fetchVaultsUserData: typeof initializer.fetchVaultsUserData;
109
114
  protected initializeVaultsUserData: typeof initializer.initializeVaultsUserData;
110
115
  protected initializeXIbexUserData: typeof initializer.initializeXIbexUserData;
111
- protected fetchNftlpTvls: typeof initializer.fetchNftlpTvls;
112
- getNftlpTvl: typeof initializer.getNftlpTvl;
113
116
  protected fetchBorrowersList: typeof initializer.fetchBorrowersList;
114
117
  protected initializeBorrowersList: typeof initializer.initializeBorrowersList;
115
118
  getBorrowersList: typeof initializer.getBorrowersList;
@@ -117,14 +120,5 @@ export default class Offchain {
117
120
  getNftlpsData: typeof initializer.getNftlpsData;
118
121
  protected fetchNftlpsData: typeof initializer.fetchNftlpsData;
119
122
  protected initializeNftlpsData: typeof initializer.initializeNftlpsData;
120
- getUniswapV3NewlyEarnedFees: typeof initializer.getUniswapV3NewlyEarnedFees;
121
- protected fetchUniswapV3NewlyEarnedFees: typeof initializer.fetchUniswapV3NewlyEarnedFees;
122
- getAerodromeV3NewlyEarnedRewards: typeof initializer.getAerodromeV3NewlyEarnedRewards;
123
- protected fetchAerodromeV3NewlyEarnedRewards: typeof initializer.fetchAerodromeV3NewlyEarnedRewards;
124
- getUniswapV3Charts: typeof initializer.getUniswapV3Chart;
125
- protected fetchUniswapV3Charts: typeof initializer.fetchUniswapV3Charts;
126
- getAerodromeV3Charts: typeof initializer.getAerodromeV3Chart;
127
- protected fetchAerodromeV3Charts: typeof initializer.fetchAerodromeV3Charts;
128
123
  getPairsList(factory: Factory, state?: PairState): Address[];
129
- getPoolChart(address: Address): Promise<import("./offchainTypes").UniswapV3PoolChart[]>;
130
124
  }
@@ -42,12 +42,24 @@ class Offchain {
42
42
  this.deprecatedPairs = {};
43
43
  this.blacklistedPairs = {};
44
44
  this.disabledBorrowsPairs = [];
45
- // ------ Pools API --------
45
+ /*--------------------------------------------------------------------------*
46
+ * Private API *
47
+ *--------------------------------------------------------------------------*/
48
+ // ------ UniswapV3Pool Charts --------
46
49
  this.extensionChartsData = {};
50
+ this.fetchUniswapV3PoolCharts = initializer.fetchUniswapV3PoolCharts;
51
+ this.getUniswapV3PoolChart = initializer.getUniswapV3PoolChart;
52
+ // ------ NFTLP TVLs --------
47
53
  this.extensionStatsData = {};
54
+ this.fetchNftlpTvls = initializer.fetchNftlpTvls;
55
+ this.getNftlpTvl = initializer.getNftlpTvl;
48
56
  // ------ User API --------
49
57
  this.userNewlyEarnedFeesData = {};
58
+ this.fetchUniswapV3NewlyEarnedFees = initializer.fetchUniswapV3NewlyEarnedFees;
59
+ this.getUniswapV3NewlyEarnedFees = initializer.getUniswapV3NewlyEarnedFees;
50
60
  this.userNewlyEarnedRewardData = {};
61
+ this.fetchAeroCLNewlyEarnedRewards = initializer.fetchAeroCLNewlyEarnedRewards;
62
+ this.getAeroCLNewlyEarnedRewards = initializer.getAeroCLNewlyEarnedRewards;
51
63
  this.getSolidexHelper = () => this.solidexHelper;
52
64
  this.getConfigManager = () => this.configManager;
53
65
  // Multichain, 1 instance
@@ -93,11 +105,6 @@ class Offchain {
93
105
  this.fetchVaultsUserData = initializer.fetchVaultsUserData;
94
106
  this.initializeVaultsUserData = initializer.initializeVaultsUserData;
95
107
  this.initializeXIbexUserData = initializer.initializeXIbexUserData;
96
- this.fetchNftlpTvls = initializer.fetchNftlpTvls;
97
- this.getNftlpTvl = initializer.getNftlpTvl;
98
- // NOTE: Not needed anymore since new vault subgraphs, delete?
99
- // protected fetchVaultBorrowables = initializer.fetchVaultBorrowables;
100
- // public getVaultBorrowables = initializer.getVaultBorrowables;
101
108
  // NOTE: This isn't needed as `fetchBorrowersList` below will fetch v2 and v3 positions.
102
109
  // Hidden atm in case we decide to add functions for v3 only.
103
110
  // protected fetchAllV3Positions = initializer.fetchAllV3Positions;
@@ -111,17 +118,6 @@ class Offchain {
111
118
  this.getNftlpsData = initializer.getNftlpsData;
112
119
  this.fetchNftlpsData = initializer.fetchNftlpsData;
113
120
  this.initializeNftlpsData = initializer.initializeNftlpsData;
114
- // Fees/Rewards
115
- this.getUniswapV3NewlyEarnedFees = initializer.getUniswapV3NewlyEarnedFees;
116
- this.fetchUniswapV3NewlyEarnedFees = initializer.fetchUniswapV3NewlyEarnedFees;
117
- this.getAerodromeV3NewlyEarnedRewards = initializer.getAerodromeV3NewlyEarnedRewards;
118
- this.fetchAerodromeV3NewlyEarnedRewards = initializer.fetchAerodromeV3NewlyEarnedRewards;
119
- // Charts
120
- // TODO: this better
121
- this.getUniswapV3Charts = initializer.getUniswapV3Chart;
122
- this.fetchUniswapV3Charts = initializer.fetchUniswapV3Charts;
123
- this.getAerodromeV3Charts = initializer.getAerodromeV3Chart;
124
- this.fetchAerodromeV3Charts = initializer.fetchAerodromeV3Charts;
125
121
  // Config
126
122
  this.offchainMultichain = offchainMultichain;
127
123
  this.network = network;
@@ -136,15 +132,11 @@ class Offchain {
136
132
  this.accounts = {};
137
133
  this.usersData = {};
138
134
  this.vaultsUsersData = {};
139
- this.vaultBorrowablesData = {};
140
135
  this.xibexUsersData = {};
141
136
  // Staking module is only available on Arbitrum atm,
142
137
  // so we initialize it once in the offchainMultichain.
143
138
  // this.stakingModule = new OffchainStakingModule(this);
144
- // TODO: make this better
145
- this.extensionChartsData[types_1.Extension.UniswapV3] = this.fetchUniswapV3Charts();
146
139
  this.extensionStatsData[types_1.Extension.UniswapV3] = this.fetchNftlpTvls(types_1.Extension.UniswapV3);
147
- this.extensionChartsData[types_1.Extension.AeroCL] = this.fetchAerodromeV3Charts();
148
140
  this.extensionStatsData[types_1.Extension.AeroCL] = this.fetchNftlpTvls(types_1.Extension.AeroCL);
149
141
  }
150
142
  async cleanCache() {
@@ -154,7 +146,6 @@ class Offchain {
154
146
  this.vaultsData = null;
155
147
  this.lendingVaultsUsersData = {};
156
148
  this.vaultsUsersData = {};
157
- this.vaultBorrowablesData = {};
158
149
  this.tvlData = null;
159
150
  this.whitelistData = null;
160
151
  this.solidexHelper.cleanCache();
@@ -213,10 +204,5 @@ class Offchain {
213
204
  pairs.push(...blacklisted);
214
205
  return pairs.map(i => i.toLowerCase());
215
206
  }
216
- // Charts?
217
- // TODO: This better
218
- async getPoolChart(address) {
219
- return this.getUniswapV3Charts(address.toLowerCase());
220
- }
221
207
  }
222
208
  exports.default = Offchain;
@@ -345,7 +345,12 @@ export type UniswapV3PoolChart = {
345
345
  token0Price: number;
346
346
  token1Price: number;
347
347
  };
348
- export type PoolChart = UniswapV3PoolChart;
348
+ export type AeroCLPoolChart = UniswapV3PoolChart & {
349
+ rewardRate: string;
350
+ stakedLiquidity: string;
351
+ rewardGrowthGlobalX128: string;
352
+ };
353
+ export type PoolChart = UniswapV3PoolChart | AeroCLPoolChart;
349
354
  export type NewlyEarnedFees = {
350
355
  newlyEarnedFees0: number;
351
356
  newlyEarnedFees1: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.468",
3
+ "version": "2.1.470",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -1 +0,0 @@
1
- export * from './nftlp';
@@ -1,5 +0,0 @@
1
- import { AddressIndex, Address } from "../../../../../../config/types";
2
- import Offchain from "../../../../../offchain";
3
- import { PoolChart } from "../../../../../offchainTypes";
4
- export declare function fetchAerodromeV3Charts(this: Offchain): Promise<AddressIndex<PoolChart[]>>;
5
- export declare function getAerodromeV3Chart(this: Offchain, aerodromeV3Pool: Address): Promise<PoolChart[]>;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- // private-api: aerodromeV3 charts
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getAerodromeV3Chart = exports.fetchAerodromeV3Charts = void 0;
5
- const types_1 = require("../../../../../../config/types");
6
- const private_api_1 = require("../../../../../../config/private-api");
7
- /*--------------------------------------------------------------------------*
8
- * Fetchers *
9
- *--------------------------------------------------------------------------*/
10
- // Fetches all charts of all lending pools for an NFTLP factory (ie. Dex)
11
- async function fetchAerodromeV3Charts() {
12
- const api = private_api_1.NFTLP_API[this.network][types_1.Extension.AeroCL];
13
- if (!api) {
14
- //console.log(`Missing NFTLP aerodromeV3 subgraph on ${this.network}?`)
15
- return {};
16
- }
17
- try {
18
- const response = await this.offchainMultichain.getEndpointManager().fetchAPI(api.concat('pools/charts'));
19
- return response;
20
- }
21
- catch (err) {
22
- console.log(`Failed to fetch aerodromeV3 Pool data on ${this.network}`);
23
- console.log(err);
24
- return {};
25
- }
26
- }
27
- exports.fetchAerodromeV3Charts = fetchAerodromeV3Charts;
28
- /*--------------------------------------------------------------------------*
29
- * Getters *
30
- *--------------------------------------------------------------------------*/
31
- async function getAerodromeV3Chart(aerodromeV3Pool) {
32
- if (!this.extensionChartsData[types_1.Extension.AeroCL]) {
33
- this.extensionChartsData[types_1.Extension.AeroCL] = this.fetchAerodromeV3Charts();
34
- }
35
- const poolChartData = await this.extensionChartsData[types_1.Extension.AeroCL];
36
- return poolChartData[aerodromeV3Pool];
37
- }
38
- exports.getAerodromeV3Chart = getAerodromeV3Chart;
@@ -1 +0,0 @@
1
- export * from './aerodromeV3Charts';
@@ -1,3 +0,0 @@
1
- export * from './uniswapV3';
2
- export * from './tvl';
3
- export * from './aerodromeV3';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./uniswapV3"), exports);
18
- __exportStar(require("./tvl"), exports);
19
- __exportStar(require("./aerodromeV3"), exports);
@@ -1 +0,0 @@
1
- export * from './uniswapV3Charts';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./uniswapV3Charts"), exports);
@@ -1,5 +0,0 @@
1
- import { AddressIndex, Address } from "../../../../../../config/types";
2
- import Offchain from "../../../../../offchain";
3
- import { PoolChart } from "../../../../../offchainTypes";
4
- export declare function fetchUniswapV3Charts(this: Offchain): Promise<AddressIndex<PoolChart[]>>;
5
- export declare function getUniswapV3Chart(this: Offchain, uniswapV3Pool: Address): Promise<PoolChart[]>;
@@ -1 +0,0 @@
1
- export * from "./nfltp";
@@ -1 +0,0 @@
1
- export * from './uniswapV3Fees';
@@ -1,5 +0,0 @@
1
- import { AddressIndex, Address } from "../../../../../../config/types";
2
- import Offchain from "../../../../../offchain";
3
- import { NewlyEarnedReward } from "../../../../../offchainTypes";
4
- export declare function fetchAerodromeV3NewlyEarnedRewards(this: Offchain, account: Address): Promise<AddressIndex<NewlyEarnedReward>>;
5
- export declare function getAerodromeV3NewlyEarnedRewards(this: Offchain, account: Address, positionId: string): Promise<NewlyEarnedReward | undefined>;
@@ -1 +0,0 @@
1
- export * from "./aerodromeV3Rewards";
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./aerodromeV3Rewards"), exports);
@@ -1 +0,0 @@
1
- //export * from './vaultBorrowables'
@@ -1,54 +0,0 @@
1
- // NOTE: Replaced API with query as new vault subgraphs includes borrowables
2
- // private-api: Vault borrowables
3
- //
4
- // import { AddressIndex, VaultType, Address } from "../../../../config/types";
5
- // import { VaultBorrowable } from "../../../offchainTypes";
6
- // import { IMPERMAX_VAULT_API } from "../../../../config/private-api";
7
- // import Offchain from "../../../offchain";
8
- //
9
- //
10
- // /*--------------------------------------------------------------------------*
11
- // * Fetchers *
12
- // *--------------------------------------------------------------------------*/
13
- //
14
- // export async function fetchVaultBorrowables(
15
- // this: Offchain,
16
- // vaultType: VaultType
17
- // ): Promise<AddressIndex<VaultBorrowable[]>> {
18
- // const api = IMPERMAX_VAULT_API[this.network][vaultType];
19
- // if (!api) {
20
- // console.log(`Missing API for ${vaultType} on ${this.network}?`);
21
- // return {};
22
- // }
23
- //
24
- // try {
25
- // const response = await fetch(api.concat('borrowables')).then(i => i.json());
26
- // return response.reduce((acc: AddressIndex<VaultBorrowable[]>, borrowable: any) => {
27
- // const vaultId = borrowable.lendingVaultId.toLowerCase();
28
- // if (!acc[vaultId]) acc[vaultId] = [];
29
- // acc[vaultId].push(borrowable);
30
- // return acc;
31
- // }, {});
32
- // } catch (err) {
33
- // console.log(`Failed to fetch vault borrowables for ${vaultType} on ${this.network}`);
34
- // return {};
35
- // }
36
- // }
37
- //
38
- // /*--------------------------------------------------------------------------*
39
- // * Getters *
40
- // *--------------------------------------------------------------------------*/
41
- //
42
- //
43
- // export async function getVaultBorrowables(
44
- // this: Offchain,
45
- // vaultType: VaultType,
46
- // vaultAddress: Address
47
- // ): Promise<VaultBorrowable[] | null> {
48
- // if (!this.vaultBorrowablesData[vaultType]) {
49
- // this.vaultBorrowablesData[vaultType] = this.fetchVaultBorrowables(vaultType);
50
- // }
51
- //
52
- // const borrowablesMap = await this.vaultBorrowablesData[vaultType];
53
- // return borrowablesMap?.[vaultAddress.toLowerCase()] || null;
54
- // }