impermax-sdk 1.2.85 → 1.2.87

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.
@@ -41,6 +41,7 @@ export declare enum Amms {
41
41
  tokanStable = "tokanStable",
42
42
  scale = "scale",
43
43
  equalizer = "equalizer",
44
+ wigoswap = "wigoswap",
44
45
  velodrome = "velodrome"
45
46
  }
46
47
  export declare const hrAmms: {
@@ -85,6 +86,7 @@ export declare const hrAmms: {
85
86
  tokan1: string;
86
87
  tokanStable: string;
87
88
  equalizer: string;
89
+ wigoswap: string;
88
90
  velodrome: string;
89
91
  };
90
92
  export declare const AMM_FACTORY: AmmIndex;
@@ -45,6 +45,7 @@ var Amms;
45
45
  Amms["tokanStable"] = "tokanStable";
46
46
  Amms["scale"] = "scale";
47
47
  Amms["equalizer"] = "equalizer";
48
+ Amms["wigoswap"] = "wigoswap";
48
49
  Amms["velodrome"] = "velodrome";
49
50
  })(Amms = exports.Amms || (exports.Amms = {}));
50
51
  exports.hrAmms = {
@@ -89,6 +90,7 @@ exports.hrAmms = {
89
90
  [Amms.tokan1]: 'Tokan',
90
91
  [Amms.tokanStable]: 'Tokan Stable',
91
92
  [Amms.equalizer]: 'Equalizer',
93
+ [Amms.wigoswap]: 'Wigoswap',
92
94
  [Amms.velodrome]: 'Velodrome',
93
95
  };
94
96
  exports.AMM_FACTORY = {
@@ -139,6 +141,7 @@ exports.AMM_FACTORY = {
139
141
  [Amms.solidly091]: '0xdc4baf3b4b1df79083eedf3e46ec2c4ec1296f60',
140
142
  [Amms.solidlyOxd]: '0xB83D21F60B73B21506c69DEcdBcF7Ab5AB737eB2',
141
143
  [Amms.equalizer]: '0xc6366efd0af1d09171fe0ebf32c7943bb310832a',
144
+ [Amms.wigoswap]: '0x4FBb297156AD5d6F93b0CD9A1487b4a91996A22a', //NOTICE: this is actually the staked LP factory
142
145
  },
143
146
  [types_1.Networks.Canto]: {
144
147
  [Amms.velocimeter]: '0x1c813cdd6daece2cb83c52f0798504e42816e9c5', //NOTICE: this is actually the staked LP factory
@@ -291,6 +294,7 @@ exports.ADD_LIQUIDITY_URLS = {
291
294
  [Amms.solidly091]: 'https://solidly.exchange/liquidity/',
292
295
  [Amms.solidlyOxd]: 'https://solidly.exchange/liquidity/',
293
296
  [Amms.equalizer]: 'https://equalizer.exchange/liquidity/',
297
+ [Amms.wigoswap]: 'https://wigoswap.io/farms/',
294
298
  },
295
299
  [types_1.Networks.Canto]: {
296
300
  [Amms.velocimeter]: 'https://www.velocimeter.xyz/liquidity/',
@@ -372,6 +376,7 @@ exports.AMM_LP_FEE = {
372
376
  [Amms.solidly091]: 0,
373
377
  [Amms.solidlyOxd]: 0,
374
378
  [Amms.equalizer]: 0,
379
+ [Amms.wigoswap]: 0,
375
380
  },
376
381
  [types_1.Networks.Canto]: {
377
382
  [Amms.velocimeter]: 0,
@@ -31,6 +31,7 @@ exports.IMPERMAX_FACTORY = {
31
31
  [types_1.Networks.Fantom]: {
32
32
  [types_1.Factory.SOLV1_2]: '0x60aE5F446AE1575534A5F234D6EC743215624556',
33
33
  [types_1.Factory.SOLV2]: '0x9b4ae930255CB8695a9F525dA414F80C4C7a945B',
34
+ [types_1.Factory.V2V2]: '0x1E6B86C09fdBe02fEB228A585C487623Fc395D34'
34
35
  },
35
36
  [types_1.Networks.Canto]: {
36
37
  [types_1.Factory.SOLV2]: '0x9708E0B216a88D38d469B255cE78c1369ad898e6',
@@ -35,6 +35,7 @@ exports.ROUTER = {
35
35
  [types_1.Networks.Fantom]: {
36
36
  [types_1.Factory.SOLV1_2]: '0xF655C8567E0f213e6C634CD2A68d992152161dC6',
37
37
  [types_1.Factory.SOLV2]: '0xd9eA4A62C46Cb221F74314C21979Cfb2E020de87',
38
+ [types_1.Factory.V2V2]: '0xd4B557536c7d30463b9BEB470c117F8963Cee24a'
38
39
  },
39
40
  [types_1.Networks.Canto]: {
40
41
  [types_1.Factory.SOLV2]: '0x370D3eE40f1257fC432C33e387981CeDD15C7fac',
@@ -34,6 +34,7 @@ exports.IMPERMAX_SUBGRAPH_URL = {
34
34
  [types_1.Networks.Fantom]: {
35
35
  [types_1.Factory.SOLV1_2]: 'https://api.studio.thegraph.com/query/46041/impermax-fantom-solv1/v0.0.1',
36
36
  [types_1.Factory.SOLV2]: 'https://api.studio.thegraph.com/query/46041/impermax-fantom-solv2/v0.0.2',
37
+ [types_1.Factory.V2V2]: 'https://api.studio.thegraph.com/query/46041/impermax-fantom-v2/v0.0.1'
37
38
  },
38
39
  [types_1.Networks.Canto]: {
39
40
  [types_1.Factory.SOLV2]: 'https://api.impermax.finance/subgraphs/name/impermax-finance/impermax-canto-solv2',
@@ -197,19 +197,29 @@ class Offchain {
197
197
  const { tvl } = yield this.getAPRHelper().getLlamaTvlAndBorrows(this.network);
198
198
  if (tvl)
199
199
  return tvl;
200
- // Gallback to subgraph
200
+ // Fallback to subgraph
201
201
  const tvlData = yield this.getTvlData();
202
202
  return tvlData.totalBalanceUSD;
203
203
  });
204
204
  }
205
205
  getTotalValueSupplied() {
206
206
  return __awaiter(this, void 0, void 0, function* () {
207
+ // Try llama
208
+ const { totalSupplied } = yield this.getAPRHelper().getLlamaTvlAndBorrows(this.network);
209
+ if (totalSupplied)
210
+ return totalSupplied;
211
+ // Fallback to subgraph
207
212
  const tvlData = yield this.getTvlData();
208
213
  return tvlData.totalSupplyUSD;
209
214
  });
210
215
  }
211
216
  getTotalValueBorrowed() {
212
217
  return __awaiter(this, void 0, void 0, function* () {
218
+ // Try llama
219
+ const { borrowed } = yield this.getAPRHelper().getLlamaTvlAndBorrows(this.network);
220
+ if (borrowed)
221
+ return borrowed;
222
+ // Fallback to subgraph
213
223
  const tvlData = yield this.getTvlData();
214
224
  return tvlData.totalBorrowsUSD;
215
225
  });
@@ -5,6 +5,8 @@ export default class OffchainAPRHelper {
5
5
  private initialized;
6
6
  private chainTvls;
7
7
  private tvlInitialized;
8
+ private chainsTotalSupplied;
9
+ private totalSuppliedInitialized;
8
10
  private readonly blacklistedProjects;
9
11
  offchain: Offchain;
10
12
  constructor(offchain: Offchain);
@@ -12,12 +14,15 @@ export default class OffchainAPRHelper {
12
14
  private isBlacklisted;
13
15
  private initializeYields;
14
16
  private initializeTvls;
17
+ private initializePoolsBorrow;
15
18
  private getLlamaYields;
16
19
  private getLlamaTvls;
20
+ private getChainsTotalSupplied;
17
21
  getLlamaAPR(pool: Address, chain: Networks): Promise<number>;
18
22
  getLlamaTvlAndBorrows(chain: Networks): Promise<{
19
23
  tvl: number;
20
24
  borrowed: number;
25
+ totalSupplied: number;
21
26
  }>;
22
27
  getImpermaxBorrows(): Promise<number>;
23
28
  getImpermaxTvl(): Promise<number>;
@@ -39,6 +39,8 @@ class OffchainAPRHelper {
39
39
  this.initialized = null;
40
40
  this.chainTvls = {};
41
41
  this.tvlInitialized = null;
42
+ this.chainsTotalSupplied = {};
43
+ this.totalSuppliedInitialized = null;
42
44
  this.blacklistedProjects = new Set([
43
45
  "extra-finance",
44
46
  "beefy"
@@ -50,6 +52,8 @@ class OffchainAPRHelper {
50
52
  this.initialized = null;
51
53
  this.chainTvls = {};
52
54
  this.tvlInitialized = null;
55
+ this.chainsTotalSupplied = {};
56
+ this.totalSuppliedInitialized = null;
53
57
  }
54
58
  // Blacklist certain projects which might report same pool as dex (aggregators, etc.)
55
59
  // Reason we need this is that we want the DEX APR and not the APR of other projects
@@ -76,7 +80,7 @@ class OffchainAPRHelper {
76
80
  }, {});
77
81
  }
78
82
  catch (err) {
79
- console.warn("The llamas pools down?");
83
+ console.warn("The llamas yields down?");
80
84
  this.llamaAllPools = {};
81
85
  }
82
86
  });
@@ -99,6 +103,23 @@ class OffchainAPRHelper {
99
103
  }
100
104
  });
101
105
  }
106
+ // Initializes the `totalSupplyUsd` from our yields
107
+ initializePoolsBorrow() {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ try {
110
+ const response = yield fetch("https://yields.llama.fi/poolsBorrow").then((i) => i.json());
111
+ const impermaxPools = response.data.filter((i) => i.project === 'impermax-finance');
112
+ this.chainsTotalSupplied = impermaxPools.reduce((acc, pool) => {
113
+ acc[pool.chain.toLowerCase()] = (acc[pool.chain.toLowerCase()] || 0) + pool.totalSupplyUsd;
114
+ return acc;
115
+ }, {});
116
+ }
117
+ catch (err) {
118
+ console.warn("The llamas poolsBorrow down?");
119
+ this.chainsTotalSupplied = {};
120
+ }
121
+ });
122
+ }
102
123
  getLlamaYields() {
103
124
  return __awaiter(this, void 0, void 0, function* () {
104
125
  // First call initializes
@@ -119,6 +140,14 @@ class OffchainAPRHelper {
119
140
  return this.chainTvls;
120
141
  });
121
142
  }
143
+ getChainsTotalSupplied() {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ if (!this.totalSuppliedInitialized)
146
+ this.totalSuppliedInitialized = this.initializePoolsBorrow();
147
+ yield this.totalSuppliedInitialized;
148
+ return this.chainsTotalSupplied;
149
+ });
150
+ }
122
151
  // ---------------- Getters ---------------- //
123
152
  getLlamaAPR(pool, chain) {
124
153
  var _a;
@@ -140,13 +169,17 @@ class OffchainAPRHelper {
140
169
  getLlamaTvlAndBorrows(chain) {
141
170
  return __awaiter(this, void 0, void 0, function* () {
142
171
  // Get or initialize the tvl for all chains
143
- const llamaTvls = yield this.getLlamaTvls();
172
+ const [llamaTvls, totalSuppliedYields] = yield Promise.all([
173
+ this.getLlamaTvls(),
174
+ this.getChainsTotalSupplied()
175
+ ]);
144
176
  const llamaChain = LlamaChains[chain];
145
177
  if (!llamaChain)
146
- return { tvl: 0, borrowed: 0 };
178
+ return { tvl: 0, borrowed: 0, totalSupplied: 0 };
147
179
  const tvl = llamaTvls[llamaChain];
148
180
  const borrowed = llamaTvls[llamaChain.concat("-borrowed")];
149
- return { tvl, borrowed };
181
+ const totalSupplied = totalSuppliedYields[chain];
182
+ return { tvl, borrowed, totalSupplied };
150
183
  });
151
184
  }
152
185
  // Overall Cross-chain stats
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "1.2.85",
3
+ "version": "1.2.87",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",