impermax-sdk 2.1.222 → 2.1.224

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.
@@ -58,6 +58,7 @@ export default abstract class OffchainLendingPool {
58
58
  getAmm(): Promise<Amms | null>;
59
59
  getFarm(): Promise<Farms | null>;
60
60
  getKinkMultiplier(): 2 | 5;
61
+ getTotalAPR(): Promise<number>;
61
62
  getTVL(): Promise<number>;
62
63
  isDeprecated(): Promise<boolean>;
63
64
  isBlacklisted(): Promise<boolean>;
@@ -121,6 +121,26 @@ class OffchainLendingPool {
121
121
  return 5;
122
122
  return 2;
123
123
  }
124
+ async getTotalAPR() {
125
+ const uniswapV2Pair = (await this.getLendingPoolData()).pair
126
+ .uniswapV2PairAddress;
127
+ // If llama fails/apr is 0 we get the uniswapAPR and stakingAPR through subgraph
128
+ const apr = await this.offchain
129
+ .getAPRHelper()
130
+ .getLlamaAPR(uniswapV2Pair, this.offchain.network);
131
+ if (apr > 0)
132
+ return apr;
133
+ // Try shadow on Sonic network
134
+ if (this.offchain.network === types_1.Networks.Sonic) {
135
+ const shadowAPR = await this.offchain
136
+ .getAPRHelper()
137
+ .getShadowAPR(uniswapV2Pair, this.offchain.network);
138
+ if (shadowAPR > 0)
139
+ return shadowAPR;
140
+ }
141
+ // TODO -> fallback for lending pools not supported by defillama
142
+ return 0;
143
+ }
124
144
  async getTVL() {
125
145
  const [supply0USD, supply1USD, lpUSD] = await Promise.all([
126
146
  this.getBorrowableA().getTotalBalanceUSD(),
@@ -7,7 +7,6 @@ export default abstract class OnchainAccountPoolToken {
7
7
  protected cache: {
8
8
  availableBalance?: Promise<number>;
9
9
  tokens?: Promise<number>;
10
- amount?: Promise<number>;
11
10
  };
12
11
  getPoolToken: () => OnchainPoolToken;
13
12
  abstract getAccount(): OnchainAccount;
@@ -26,7 +25,6 @@ export default abstract class OnchainAccountPoolToken {
26
25
  getAvailableBalanceUSD(): Promise<number>;
27
26
  private initializeTokens;
28
27
  getTokens(): Promise<number>;
29
- private initializeAmount;
30
28
  getAmount(): Promise<number>;
31
29
  getDeposited: () => Promise<number>;
32
30
  getDepositedUSD(): Promise<number>;
@@ -49,15 +49,10 @@ class OnchainAccountPoolToken {
49
49
  return this.cache.tokens;
50
50
  }
51
51
  // Deposited
52
- async initializeAmount() {
52
+ async getAmount() {
53
53
  const exchangeRate = await this.poolToken.getExchangeRate();
54
54
  const tokens = await this.getTokens();
55
- return (await this.poolToken.normalize(tokens)) * exchangeRate;
56
- }
57
- async getAmount() {
58
- if (!this.cache.amount)
59
- this.cache.amount = this.initializeAmount();
60
- return this.cache.amount;
55
+ return tokens * exchangeRate;
61
56
  }
62
57
  async getDepositedUSD() {
63
58
  const deposited = await this.getDeposited();
@@ -19,4 +19,5 @@ export default class OnchainInteractionsLendingPoolV2 extends OnchainInteraction
19
19
  getBorrowableB: () => OnchainInteractionsBorrowableV2;
20
20
  getCollateral: () => OnchainInteractionsCollateralV2;
21
21
  getAccountLendingPool(): OnchainAccountLendingPoolV2;
22
+ reinvest(onTransactionHash: Function): Promise<any>;
22
23
  }
@@ -26,5 +26,9 @@ class OnchainInteractionsLendingPoolV2 extends onchainInteractionsLendingPool_1.
26
26
  getAccountLendingPool() {
27
27
  return this.interactions.getAccount().getLendingPool(this.getFactory(), this.getId());
28
28
  }
29
+ async reinvest(onTransactionHash) {
30
+ const stakedLPToken = await this.lendingPool.getStakedLPToken();
31
+ return this.send(stakedLPToken.methods.reinvest(), onTransactionHash);
32
+ }
29
33
  }
30
34
  exports.default = OnchainInteractionsLendingPoolV2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.222",
3
+ "version": "2.1.224",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",