impermax-sdk 2.1.366 → 2.1.368

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.
@@ -82,7 +82,7 @@ class OffchainAccountNftlpUniswapV3 extends offchainAccountNftlp_1.default {
82
82
  try {
83
83
  const account = this.getLendingPool().getAccount().getAccountAddress();
84
84
  const positionFees = await this.getLendingPool().getLendingPool().getOffchain().getUniswapV3NewlyEarnedFees(account, positionId);
85
- this.cache.newlyEarnedFees[tokenId] = { amountX: Number(positionFees.newlyEarnedFees0), amountY: Number(positionFees.newlyEarnedFees1) };
85
+ this.cache.newlyEarnedFees[tokenId] = { amountX: Number(positionFees?.newlyEarnedFees0), amountY: Number(positionFees?.newlyEarnedFees1) };
86
86
  return this.cache.newlyEarnedFees[tokenId];
87
87
  }
88
88
  catch (err) {
@@ -2,4 +2,4 @@ import { AddressIndex, Address } from "../../../../../config/types";
2
2
  import Offchain from "../../../../../offchain";
3
3
  import { NewlyEarnedFees } from "../../../../offchainTypes";
4
4
  export declare function fetchUniswapV3NewlyEarnedFees(this: Offchain, account: Address): Promise<AddressIndex<NewlyEarnedFees>>;
5
- export declare function getUniswapV3NewlyEarnedFees(this: Offchain, account: Address, positionId: string): Promise<NewlyEarnedFees>;
5
+ export declare function getUniswapV3NewlyEarnedFees(this: Offchain, account: Address, positionId: string): Promise<NewlyEarnedFees | undefined>;
@@ -36,10 +36,12 @@ exports.fetchUniswapV3NewlyEarnedFees = fetchUniswapV3NewlyEarnedFees;
36
36
  * Getters *
37
37
  *--------------------------------------------------------------------------*/
38
38
  async function getUniswapV3NewlyEarnedFees(account, positionId) {
39
- if (!this.userNewlyEarnedFeesData[types_1.Extension.UniswapV3]) {
40
- this.userNewlyEarnedFeesData[types_1.Extension.UniswapV3] = this.fetchUniswapV3NewlyEarnedFees(account);
39
+ if (!this.userNewlyEarnedFeesData[account])
40
+ this.userNewlyEarnedFeesData[account] = {};
41
+ if (!this.userNewlyEarnedFeesData[account][types_1.Extension.UniswapV3]) {
42
+ this.userNewlyEarnedFeesData[account][types_1.Extension.UniswapV3] = this.fetchUniswapV3NewlyEarnedFees(account);
41
43
  }
42
- const feesData = await this.userNewlyEarnedFeesData[types_1.Extension.UniswapV3];
43
- return feesData[positionId];
44
+ const feesData = await this.userNewlyEarnedFeesData[account][types_1.Extension.UniswapV3];
45
+ return feesData?.[positionId];
44
46
  }
45
47
  exports.getUniswapV3NewlyEarnedFees = getUniswapV3NewlyEarnedFees;
@@ -55,7 +55,9 @@ export default class Offchain {
55
55
  [key in Extension]?: Promise<AddressIndex<NftlpStats>>;
56
56
  };
57
57
  protected userNewlyEarnedFeesData: {
58
- [key in Extension]?: Promise<AddressIndex<NewlyEarnedFees>>;
58
+ [address: Address]: {
59
+ [key in Extension]?: Promise<AddressIndex<NewlyEarnedFees>>;
60
+ };
59
61
  };
60
62
  constructor(offchainMultichain: OffchainMultichain, network: Networks);
61
63
  cleanCache(): void;
@@ -45,7 +45,6 @@ class Offchain {
45
45
  this.extensionChartsData = {};
46
46
  this.extensionStatsData = {};
47
47
  // ------ User API --------
48
- // TODO: Proper positionIndex type
49
48
  this.userNewlyEarnedFeesData = {};
50
49
  this.getSolidexHelper = () => this.solidexHelper;
51
50
  this.getConfigManager = () => this.configManager;
@@ -50,6 +50,8 @@ class OffchainAPRHelper {
50
50
  "extra-finance",
51
51
  "beefy",
52
52
  "impermax-finance",
53
+ "impermax-v2",
54
+ "impermax-v3",
53
55
  ]);
54
56
  this.offchainMultichain = offchainMultichain;
55
57
  }
@@ -136,7 +138,8 @@ class OffchainAPRHelper {
136
138
  async initializePoolsBorrow() {
137
139
  try {
138
140
  const response = await fetch("https://yields.llama.fi/poolsBorrow").then((i) => i.json());
139
- const impermaxPools = response.data.filter((i) => i.project === "impermax-finance");
141
+ // TODO: V3 yields, waiting on merge from llama
142
+ const impermaxPools = response.data.filter((i) => i.project === "impermax-v2");
140
143
  this.chainsTotalSupplied = impermaxPools.reduce((acc, pool) => {
141
144
  acc[pool.chain.toLowerCase()] =
142
145
  (acc[pool.chain.toLowerCase()] || 0) + pool.totalSupplyUsd;
@@ -4,13 +4,14 @@ import Offchain from "../offchain";
4
4
  export default class OffchainStakingModule {
5
5
  private readonly offchain;
6
6
  protected xIbexData: Promise<XIbexData> | null;
7
+ protected xibex: Address;
7
8
  protected ibex: Address;
8
9
  cleanCache(): void;
9
10
  constructor(offchain: Offchain);
10
11
  getOffchain: () => Offchain;
11
12
  getIbexAddress: () => string;
12
13
  getXIbexData: () => Promise<XIbexData>;
13
- getXIbexAddress(): Promise<Address>;
14
+ getXIbexAddress: () => string;
14
15
  getXIbexTotalSupply(): Promise<number>;
15
16
  getXIbexDailyAPR(): Promise<number>;
16
17
  getXIbexAPY(): Promise<number>;
@@ -6,25 +6,21 @@ class OffchainStakingModule {
6
6
  this.xIbexData = null;
7
7
  }
8
8
  constructor(offchain) {
9
+ this.xIbexData = null;
9
10
  this.getOffchain = () => this.offchain;
10
11
  this.getIbexAddress = () => this.ibex;
11
12
  this.getXIbexData = () => this.offchain.getXIbexData();
13
+ this.getXIbexAddress = () => this.xibex;
12
14
  // Check if available, only arbitrum atm
13
- const ibex = ibexes_1.XIBEX[offchain.network];
14
- if (!ibex)
15
+ const ibex = ibexes_1.IBEX[offchain.network];
16
+ const xibex = ibexes_1.XIBEX[offchain.network];
17
+ if (!ibex || !xibex)
15
18
  throw new Error(`Staking module is not available on ${offchain.network}`);
19
+ this.ibex = ibex;
20
+ this.xibex = xibex;
16
21
  this.offchain = offchain;
17
- this.xIbexData = null;
18
- this.ibex = ibexes_1.IBEX[offchain.network];
19
22
  }
20
23
  // Data
21
- // Views
22
- async getXIbexAddress() {
23
- const xIbexData = await this.getXIbexData();
24
- if (!xIbexData)
25
- return "";
26
- return xIbexData.id;
27
- }
28
24
  async getXIbexTotalSupply() {
29
25
  const xIbexData = await this.getXIbexData();
30
26
  if (!xIbexData)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.366",
3
+ "version": "2.1.368",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",