impermax-sdk 1.2.84 → 1.2.86
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.
- package/lib/config/amms.js +4 -1
- package/lib/config/contracts/impermax-factories.js +1 -0
- package/lib/config/contracts/routers.js +1 -0
- package/lib/config/farms.js +1 -0
- package/lib/config/subgraphs.js +2 -1
- package/lib/offchain/offchain.js +11 -1
- package/lib/offchain/offchainAPRHelper.d.ts +5 -0
- package/lib/offchain/offchainAPRHelper.js +37 -4
- package/lib/offchain/offchainPriceHelper.js +4 -0
- package/package.json +1 -1
package/lib/config/amms.js
CHANGED
|
@@ -83,7 +83,7 @@ exports.hrAmms = {
|
|
|
83
83
|
[Amms.aerodrome]: 'Aerodrome',
|
|
84
84
|
[Amms.aeroStable]: 'Aerodrome Stable',
|
|
85
85
|
[Amms.aeroStable1]: 'Aerodrome Stable',
|
|
86
|
-
[Amms.scale]: 'Scale',
|
|
86
|
+
[Amms.scale]: 'Equalizer Scale',
|
|
87
87
|
[Amms.merchantmoe]: 'MerchantMoe',
|
|
88
88
|
[Amms.tokan]: 'Tokan',
|
|
89
89
|
[Amms.tokan1]: 'Tokan',
|
|
@@ -170,6 +170,7 @@ exports.AMM_FACTORY = {
|
|
|
170
170
|
[Amms.velodrome]: '0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a',
|
|
171
171
|
},
|
|
172
172
|
[types_1.Networks.Real]: {
|
|
173
|
+
[Amms.pearl]: '0x2B965fDf04f9e9bEEf1659464Ef3A0094A68D923',
|
|
173
174
|
[Amms.pearlStable]: '0x28E22D8c807b6E6c0ECa4373fC3B9920453cEEEe',
|
|
174
175
|
}
|
|
175
176
|
};
|
|
@@ -320,6 +321,7 @@ exports.ADD_LIQUIDITY_URLS = {
|
|
|
320
321
|
},
|
|
321
322
|
[types_1.Networks.Real]: {
|
|
322
323
|
[Amms.pearlStable]: 'https://www.pearl.exchange/supply-liquidity/v2/',
|
|
324
|
+
[Amms.pearl]: 'https://www.pearl.exchange/supply-liquidity/v2/',
|
|
323
325
|
}
|
|
324
326
|
};
|
|
325
327
|
exports.AMM_LP_FEE = {
|
|
@@ -400,5 +402,6 @@ exports.AMM_LP_FEE = {
|
|
|
400
402
|
},
|
|
401
403
|
[types_1.Networks.Real]: {
|
|
402
404
|
[Amms.pearlStable]: 0,
|
|
405
|
+
[Amms.pearl]: 0,
|
|
403
406
|
}
|
|
404
407
|
};
|
|
@@ -51,6 +51,7 @@ exports.IMPERMAX_FACTORY = {
|
|
|
51
51
|
[types_1.Factory.SOL_STABLE]: '0xFBD17F3AA7d6506601D2bF7e15a6C96081296a01',
|
|
52
52
|
},
|
|
53
53
|
[types_1.Networks.Real]: {
|
|
54
|
+
[types_1.Factory.SOLV2]: '0x2944e1544cE201ae19e6385490bBA13DaA5f44e4',
|
|
54
55
|
[types_1.Factory.SOL_STABLE]: '0x3B1f3a48A70e372144307A4b126A5cDA46E169AD',
|
|
55
56
|
},
|
|
56
57
|
[types_1.Networks.Mantle]: {
|
|
@@ -61,6 +61,7 @@ exports.ROUTER = {
|
|
|
61
61
|
[types_1.Factory.V2V2]: '0xF4A9dda025e65945E7A3F873D6146A12c8110A19'
|
|
62
62
|
},
|
|
63
63
|
[types_1.Networks.Real]: {
|
|
64
|
+
[types_1.Factory.SOLV2]: '0x64515b2f866Ac9B1297f03329d82a8507332fEf5',
|
|
64
65
|
[types_1.Factory.SOL_STABLE]: '0x3784D354863fe8862d60E446E3f29A08c21D1Ea9'
|
|
65
66
|
},
|
|
66
67
|
};
|
package/lib/config/farms.js
CHANGED
|
@@ -181,6 +181,7 @@ exports.STAKED_LP_FACTORY = {
|
|
|
181
181
|
[Farms.velodrome]: '0x47183bB55AD0F891887E099Cec3570d3C667cD00',
|
|
182
182
|
},
|
|
183
183
|
[types_1.Networks.Real]: {
|
|
184
|
+
[Farms.pearl]: '0x2B965fDf04f9e9bEEf1659464Ef3A0094A68D923',
|
|
184
185
|
[Farms.pearlStable]: '0x28E22D8c807b6E6c0ECa4373fC3B9920453cEEEe',
|
|
185
186
|
}
|
|
186
187
|
};
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -57,7 +57,8 @@ exports.IMPERMAX_SUBGRAPH_URL = {
|
|
|
57
57
|
[types_1.Factory.SOLV2]: 'https://api.studio.thegraph.com/query/46041/impermax-optimism-solv2/v0.0.1'
|
|
58
58
|
},
|
|
59
59
|
[types_1.Networks.Real]: {
|
|
60
|
-
[types_1.Factory.SOL_STABLE]: 'https://api.goldsky.com/api/public/project_cm2d5q4l4w31601vz4swb3vmi/subgraphs/impermax-finance/impermax-real-v2-stable/gn'
|
|
60
|
+
[types_1.Factory.SOL_STABLE]: 'https://api.goldsky.com/api/public/project_cm2d5q4l4w31601vz4swb3vmi/subgraphs/impermax-finance/impermax-real-v2-stable/gn',
|
|
61
|
+
[types_1.Factory.SOLV2]: 'https://api.goldsky.com/api/public/project_cm2rhb30ot9wu01to8c9h9e37/subgraphs/impermax-real-solv2/3.0/gn'
|
|
61
62
|
},
|
|
62
63
|
};
|
|
63
64
|
exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
|
package/lib/offchain/offchain.js
CHANGED
|
@@ -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
|
-
//
|
|
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
|
|
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
|
|
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
|
-
|
|
181
|
+
const totalSupplied = totalSuppliedYields[chain];
|
|
182
|
+
return { tvl, borrowed, totalSupplied };
|
|
150
183
|
});
|
|
151
184
|
}
|
|
152
185
|
// Overall Cross-chain stats
|
|
@@ -43,6 +43,7 @@ const coingecko_ids = {
|
|
|
43
43
|
"0x2b6a85cd35d15691357eea61d88cb3f401a92fc3": "surveyor-dao",
|
|
44
44
|
"0x7dbd14115baf4240aab8c4ef31bf71f76c708420": "uk-real-estate",
|
|
45
45
|
"0x25ea98ac87a38142561ea70143fd44c4772a16b6": "stack-2",
|
|
46
|
+
"0xd29687c813d741e2f938f4ac377128810e217b1b": "scroll",
|
|
46
47
|
// base
|
|
47
48
|
"0x940181a94a35a4569e4529a3cdfb74e38fd98631": "aerodrome-finance",
|
|
48
49
|
"0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed": "degen-base",
|
|
@@ -291,6 +292,9 @@ class OffchainPriceHelper {
|
|
|
291
292
|
if (tokenAddress.toLowerCase() === '0xc518a88c67ceca8b3f24c4562cb71deeb2af86b7') { // TEMPORARY fix for re.al usdc
|
|
292
293
|
return 1;
|
|
293
294
|
}
|
|
295
|
+
if (tokenAddress.toLowerCase() === '0xaec9e50e3397f9ddc635c6c429c8c7eca418a143') { // TEMPORARY fix for re.al arcUSD
|
|
296
|
+
return 1;
|
|
297
|
+
}
|
|
294
298
|
if (tokenAddress.toLowerCase() === '0xc71aaf8e486e3f33841bb56ca3fd2ac3fa8d29a8') { // TEMPORARY fix for WSTETH Canto
|
|
295
299
|
return (yield this.getDebankTokenPrice('0x5fd55a1b9fc24967c4db09c513c3ba0dfa7ff687')) * 1.12;
|
|
296
300
|
}
|