impermax-sdk 2.1.349 → 2.1.350

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.
@@ -9,3 +9,4 @@ export declare const IMPERMAX_POOLS_API: NetworkFactoryIndex<string>;
9
9
  export declare const IMPERMAX_VAULT_API: NetworkVaultTypeIndex<string>;
10
10
  export declare const NFTLP_API: NetworkExtensionIndex<string>;
11
11
  export declare const PRICE_AGGREGATOR_API_URL = "https://price-aggregator-production.up.railway.app/api/tokens";
12
+ export declare const POSITIONS_AGGREGATOR_API_URL = "https://positions-aggregator-production.up.railway.app/api/nftlps";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PRICE_AGGREGATOR_API_URL = exports.NFTLP_API = exports.IMPERMAX_VAULT_API = exports.IMPERMAX_POOLS_API = void 0;
3
+ exports.POSITIONS_AGGREGATOR_API_URL = exports.PRICE_AGGREGATOR_API_URL = exports.NFTLP_API = exports.IMPERMAX_VAULT_API = exports.IMPERMAX_POOLS_API = void 0;
4
4
  const types_1 = require("./types");
5
5
  /**
6
6
  * Private API Endpoints which we might need to use in future for non-core
@@ -100,3 +100,5 @@ exports.NFTLP_API = {
100
100
  };
101
101
  // Single endpoint for all factory subgraph token prices
102
102
  exports.PRICE_AGGREGATOR_API_URL = "https://price-aggregator-production.up.railway.app/api/tokens";
103
+ // Single endpoint for all NFTLP positions
104
+ exports.POSITIONS_AGGREGATOR_API_URL = "https://positions-aggregator-production.up.railway.app/api/nftlps";
@@ -1 +1,2 @@
1
1
  export * from './uniswapV3';
2
+ export * from './tvl';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./uniswapV3"), exports);
18
+ __exportStar(require("./tvl"), exports);
@@ -0,0 +1 @@
1
+ export * from './nftlpTvl';
@@ -0,0 +1,17 @@
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("./nftlpTvl"), exports);
@@ -0,0 +1,5 @@
1
+ import { AddressIndex, Address } from "../../../../../../config/types";
2
+ import Offchain from "../../../../../offchain";
3
+ import { NftlpStats } from "../../../../../offchainTypes";
4
+ export declare function fetchNftlpTvls(this: Offchain): Promise<AddressIndex<NftlpStats>>;
5
+ export declare function getNftlpTvl(this: Offchain, nftlpAddress: Address): Promise<NftlpStats>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNftlpTvl = exports.fetchNftlpTvls = void 0;
4
+ const types_1 = require("../../../../../../config/types");
5
+ const private_api_1 = require("../../../../../../config/private-api");
6
+ /*--------------------------------------------------------------------------*
7
+ * Fetchers *
8
+ *--------------------------------------------------------------------------*/
9
+ // Fetches all charts of all lending pools for an NFTLP factory (ie. Dex)
10
+ async function fetchNftlpTvls() {
11
+ try {
12
+ const response = await fetch(private_api_1.POSITIONS_AGGREGATOR_API_URL);
13
+ if (!response.ok)
14
+ throw new Error(`Positions aggregator API response error: ${response.status}`);
15
+ const res = await response.json();
16
+ return res;
17
+ }
18
+ catch (err) {
19
+ console.log(`Failed to fetch uniswapV3 TVL data on ${this.network}`);
20
+ console.log(err);
21
+ return {};
22
+ }
23
+ }
24
+ exports.fetchNftlpTvls = fetchNftlpTvls;
25
+ /*--------------------------------------------------------------------------*
26
+ * Getters *
27
+ *--------------------------------------------------------------------------*/
28
+ async function getNftlpTvl(nftlpAddress) {
29
+ if (!this.extensionStatsData[types_1.Extension.UniswapV3]) {
30
+ this.extensionStatsData[types_1.Extension.UniswapV3] = this.fetchNftlpTvls();
31
+ }
32
+ const nftlpTvlsData = await this.extensionStatsData[types_1.Extension.UniswapV3];
33
+ return nftlpTvlsData[nftlpAddress];
34
+ }
35
+ exports.getNftlpTvl = getNftlpTvl;
@@ -43,7 +43,8 @@ class OffchainCollateralV3 extends offchainCollateral_1.default {
43
43
  //
44
44
  // TODO
45
45
  async getTotalBalanceUSD() {
46
- return 0;
46
+ const nftlpStats = await this.getOffchain().getNftlpTvl(this.nftlp.getNftlpAddress());
47
+ return nftlpStats.tvlUSD;
47
48
  }
48
49
  }
49
50
  exports.default = OffchainCollateralV3;
@@ -3,7 +3,7 @@ import OffchainLendingPool from './lendingPool';
3
3
  import OffchainSolidexHelper from './offchainSolidexHelper';
4
4
  import OffchainAccount from './account';
5
5
  import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex, Networks, WhitelistState, VaultType, Extension } from '../config/types';
6
- import { LendingPoolData, VaultData, VaultPosition, TvlData, UserData, XimxData, VaultBorrowable, NftlpData, PoolChart, NewlyEarnedFees } from './offchainTypes';
6
+ import { LendingPoolData, VaultData, VaultPosition, TvlData, UserData, XimxData, VaultBorrowable, NftlpData, PoolChart, NewlyEarnedFees, NftlpStats } from './offchainTypes';
7
7
  import OffchainVault from './vault/offchainVault';
8
8
  import OffchainConfigManager from './configManager';
9
9
  import { LlamaTvlChart } from './offchainAPRHelper';
@@ -49,6 +49,9 @@ export default class Offchain {
49
49
  protected extensionChartsData: {
50
50
  [key in Extension]?: Promise<AddressIndex<PoolChart[]>>;
51
51
  };
52
+ protected extensionStatsData: {
53
+ [key in Extension]?: Promise<AddressIndex<NftlpStats>>;
54
+ };
52
55
  protected userNewlyEarnedFeesData: {
53
56
  [key in Extension]?: Promise<AddressIndex<NewlyEarnedFees>>;
54
57
  };
@@ -91,6 +94,8 @@ export default class Offchain {
91
94
  getVaultData: typeof initializer.getVaultData;
92
95
  protected fetchVaultsUserData: typeof initializer.fetchVaultsUserData;
93
96
  protected initializeVaultsUserData: typeof initializer.initializeVaultsUserData;
97
+ protected fetchNftlpTvls: typeof initializer.fetchNftlpTvls;
98
+ getNftlpTvl: typeof initializer.getNftlpTvl;
94
99
  protected fetchBorrowersList: typeof initializer.fetchBorrowersList;
95
100
  protected initializeBorrowersList: typeof initializer.initializeBorrowersList;
96
101
  getBorrowersList: typeof initializer.getBorrowersList;
@@ -42,6 +42,7 @@ class Offchain {
42
42
  this.disabledBorrowsPairs = [];
43
43
  // ------ Pools API --------
44
44
  this.extensionChartsData = {};
45
+ this.extensionStatsData = {};
45
46
  // ------ User API --------
46
47
  // TODO: Proper positionIndex type
47
48
  this.userNewlyEarnedFeesData = {};
@@ -88,6 +89,8 @@ class Offchain {
88
89
  this.getVaultData = initializer.getVaultData;
89
90
  this.fetchVaultsUserData = initializer.fetchVaultsUserData;
90
91
  this.initializeVaultsUserData = initializer.initializeVaultsUserData;
92
+ this.fetchNftlpTvls = initializer.fetchNftlpTvls;
93
+ this.getNftlpTvl = initializer.getNftlpTvl;
91
94
  // NOTE: Not needed anymore since new vault subgraphs, delete?
92
95
  // protected fetchVaultBorrowables = initializer.fetchVaultBorrowables;
93
96
  // public getVaultBorrowables = initializer.getVaultBorrowables;
@@ -296,3 +296,8 @@ export type NewlyEarnedFees = {
296
296
  newlyEarnedFees0: number;
297
297
  newlyEarnedFees1: number;
298
298
  };
299
+ export type NftlpStats = {
300
+ tvlUSD: 0;
301
+ positionCount: 0;
302
+ chainId: number;
303
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.349",
3
+ "version": "2.1.350",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",