impermax-sdk 2.1.422 → 2.1.423

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.
@@ -12,6 +12,7 @@ export default abstract class OffchainAccountLendingPool {
12
12
  [Borrowable.A]: OffchainAccountBorrowable;
13
13
  [Borrowable.B]: OffchainAccountBorrowable;
14
14
  };
15
+ cleanCache(): void;
15
16
  protected abstract getNewCollateralObject(): OffchainAccountCollateral;
16
17
  protected abstract getNewBorrowableObject(borrowable: Borrowable): OffchainAccountBorrowable;
17
18
  constructor(account: OffchainAccount, lendingPool: OffchainLendingPool);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const types_1 = require("../../../config/types");
4
4
  class OffchainAccountLendingPool {
5
+ cleanCache() { }
5
6
  constructor(account, lendingPool) {
6
7
  // Shortcuts
7
8
  this.getAccount = () => this.account;
@@ -14,6 +14,7 @@ export default class OffchainAccountLendingPoolV3 extends OffchainAccountLending
14
14
  [Borrowable.A]: OffchainAccountBorrowableV3;
15
15
  [Borrowable.B]: OffchainAccountBorrowableV3;
16
16
  };
17
+ cleanCache(): void;
17
18
  protected getNewCollateralObject(): OffchainAccountCollateralV3;
18
19
  protected getNewBorrowableObject(borrowable: Borrowable): OffchainAccountBorrowableV3;
19
20
  protected getId: () => any;
@@ -8,6 +8,10 @@ const offchainAccountLendingPool_1 = __importDefault(require("./offchainAccountL
8
8
  const offchainAccountCollateralV3_1 = __importDefault(require("./offchainAccountCollateralV3"));
9
9
  const offchainAccountBorrowableV3_1 = __importDefault(require("./offchainAccountBorrowableV3"));
10
10
  class OffchainAccountLendingPoolV3 extends offchainAccountLendingPool_1.default {
11
+ cleanCache() {
12
+ super.cleanCache();
13
+ this.collateral.getNftlp().cleanCache();
14
+ }
11
15
  getNewCollateralObject() {
12
16
  return new offchainAccountCollateralV3_1.default(this);
13
17
  }
@@ -28,6 +28,7 @@ export default class OffchainAccount {
28
28
  constructor(offchain: Offchain, account: Address);
29
29
  getOffchain: () => Offchain;
30
30
  getAccountAddress: () => string;
31
+ cleanCache(): Promise<void>;
31
32
  private initializeLendingPool;
32
33
  getLendingPool(factory: Factory, pair: Address): Promise<OffchainAccountLendingPool | null>;
33
34
  private initializeVault;
@@ -16,6 +16,16 @@ class OffchainAccount {
16
16
  this.lendingPools = {};
17
17
  this.vaults = {};
18
18
  }
19
+ async cleanCache() {
20
+ for (const factory in this.lendingPools) {
21
+ for (const address in this.lendingPools[factory]) {
22
+ (await this.getLendingPool(factory, address))?.cleanCache();
23
+ }
24
+ }
25
+ for (const address in this.vaults) {
26
+ (await this.getVault(address)).cleanCache();
27
+ }
28
+ }
19
29
  async initializeLendingPool(factory, pair) {
20
30
  const lendingPool = await this.offchain.getLendingPool(factory, pair);
21
31
  if (!lendingPool) {
@@ -6,6 +6,7 @@ export default class OffchainAccountVault extends OffchainAccountPoolToken {
6
6
  private readonly account;
7
7
  protected readonly poolToken: OffchainVault;
8
8
  constructor(account: OffchainAccount, vault: OffchainVault);
9
+ cleanCache(): void;
9
10
  getAccount: () => OffchainAccount;
10
11
  getPoolToken: () => OffchainVault;
11
12
  private getVaultAddress;
@@ -13,6 +13,7 @@ class OffchainAccountVault extends offchainAccountPoolToken_1.default {
13
13
  this.account = account;
14
14
  this.poolToken = vault;
15
15
  }
16
+ cleanCache() { }
16
17
  async getVaultPosition() {
17
18
  const vaultsUserData = await this.account.getVaultsUserData();
18
19
  if (!vaultsUserData)
@@ -62,7 +62,7 @@ export default class Offchain {
62
62
  };
63
63
  };
64
64
  constructor(offchainMultichain: OffchainMultichain, network: Networks);
65
- cleanCache(): void;
65
+ cleanCache(): Promise<void>;
66
66
  getLendingPool(factory: Factory, pairAddress: Address): Promise<OffchainLendingPool | null>;
67
67
  getVault(vaultAddress: Address): Promise<OffchainVault>;
68
68
  getAccount(accountAddress: Address): OffchainAccount;
@@ -137,13 +137,14 @@ class Offchain {
137
137
  this.extensionChartsData[types_1.Extension.UniswapV3] = this.fetchUniswapV3Charts();
138
138
  this.extensionStatsData[types_1.Extension.UniswapV3] = this.fetchNftlpTvls();
139
139
  }
140
- cleanCache() {
140
+ async cleanCache() {
141
141
  this.lendingPoolsData = null;
142
142
  this.nftlpsData = null;
143
143
  this.usersData = {};
144
144
  this.vaultsData = null;
145
145
  this.lendingVaultsUsersData = {};
146
146
  this.vaultsUsersData = {};
147
+ this.vaultBorrowablesData = {};
147
148
  this.tvlData = null;
148
149
  this.whitelistData = null;
149
150
  this.solidexHelper.cleanCache();
@@ -152,6 +153,9 @@ class Offchain {
152
153
  this.userNewlyEarnedFeesData = {};
153
154
  this.xibexUsersData = {};
154
155
  this.stakingModule?.cleanCache();
156
+ for (const address in this.accounts) {
157
+ await this.accounts[address].cleanCache();
158
+ }
155
159
  }
156
160
  async getLendingPool(factory, pairAddress) {
157
161
  await this.getLendingPoolsData(); // make sure that lending pools are initialized
@@ -65,12 +65,8 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
65
65
  else if (depositADelta < 0 || depositBDelta < 0) {
66
66
  const currentDepositA = positionObject.getDepositedX();
67
67
  const currentDepositB = positionObject.getDepositedY();
68
- console.log("currentDepositA", currentDepositA);
69
- console.log("depositADelta", depositADelta);
70
68
  percentageToRemove = currentDepositA == 0 ? -depositBDelta / currentDepositB : -depositADelta / currentDepositA;
71
- console.log("percentageToRemove", percentageToRemove);
72
69
  percentageToRemove = Math.min(percentageToRemove * 1.0001, 1);
73
- console.log("percentageToRemove", percentageToRemove);
74
70
  depositADelta = -currentDepositA * percentageToRemove;
75
71
  depositBDelta = -currentDepositB * percentageToRemove;
76
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.422",
3
+ "version": "2.1.423",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",