impermax-sdk 1.2.75 → 1.2.77
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.d.ts +2 -0
- package/lib/config/amms.js +3 -0
- package/lib/config/farms.d.ts +2 -0
- package/lib/config/farms.js +3 -0
- package/lib/offchain/offchain.js +10 -0
- package/lib/offchain/offchainPriceHelper.d.ts +3 -0
- package/lib/offchain/offchainPriceHelper.js +32 -9
- package/package.json +1 -1
package/lib/config/amms.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export declare enum Amms {
|
|
|
37
37
|
aeroStable1 = "aeroStable1",
|
|
38
38
|
merchantmoe = "merchantmoe",
|
|
39
39
|
tokan = "tokan",
|
|
40
|
+
tokan1 = "tokan1",
|
|
40
41
|
tokanStable = "tokanStable",
|
|
41
42
|
scale = "scale",
|
|
42
43
|
equalizer = "equalizer",
|
|
@@ -81,6 +82,7 @@ export declare const hrAmms: {
|
|
|
81
82
|
scale: string;
|
|
82
83
|
merchantmoe: string;
|
|
83
84
|
tokan: string;
|
|
85
|
+
tokan1: string;
|
|
84
86
|
tokanStable: string;
|
|
85
87
|
equalizer: string;
|
|
86
88
|
velodrome: string;
|
package/lib/config/amms.js
CHANGED
|
@@ -41,6 +41,7 @@ var Amms;
|
|
|
41
41
|
Amms["aeroStable1"] = "aeroStable1";
|
|
42
42
|
Amms["merchantmoe"] = "merchantmoe";
|
|
43
43
|
Amms["tokan"] = "tokan";
|
|
44
|
+
Amms["tokan1"] = "tokan1";
|
|
44
45
|
Amms["tokanStable"] = "tokanStable";
|
|
45
46
|
Amms["scale"] = "scale";
|
|
46
47
|
Amms["equalizer"] = "equalizer";
|
|
@@ -85,6 +86,7 @@ exports.hrAmms = {
|
|
|
85
86
|
[Amms.scale]: 'Scale',
|
|
86
87
|
[Amms.merchantmoe]: 'MerchantMoe',
|
|
87
88
|
[Amms.tokan]: 'Tokan',
|
|
89
|
+
[Amms.tokan1]: 'Tokan',
|
|
88
90
|
[Amms.tokanStable]: 'Tokan Stable',
|
|
89
91
|
[Amms.equalizer]: 'Equalizer',
|
|
90
92
|
[Amms.velodrome]: 'Velodrome',
|
|
@@ -161,6 +163,7 @@ exports.AMM_FACTORY = {
|
|
|
161
163
|
},
|
|
162
164
|
[types_1.Networks.Scroll]: {
|
|
163
165
|
[Amms.tokan]: '0x074568F090e93194289c2C2BF285eE7f60b485a9',
|
|
166
|
+
[Amms.tokan1]: '0x3e35933C468ECEca9748DD1C5FADeFfe64158777',
|
|
164
167
|
[Amms.tokanStable]: '0x6c041ff2d25310a2751C57555265F2364CaCA195', //NOTICE: this is actually the staked LP factory
|
|
165
168
|
},
|
|
166
169
|
[types_1.Networks.Optimism]: {
|
package/lib/config/farms.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare enum Farms {
|
|
|
44
44
|
aeroStable1 = "aeroStable1",
|
|
45
45
|
merchantmoe = "merchantmoe",
|
|
46
46
|
tokan = "tokan",
|
|
47
|
+
tokan1 = "tokan1",
|
|
47
48
|
tokanStable = "tokanStable",
|
|
48
49
|
velodrome = "velodrome"
|
|
49
50
|
}
|
|
@@ -91,6 +92,7 @@ export declare const hrFarms: {
|
|
|
91
92
|
aeroStable: string;
|
|
92
93
|
aeroStable1: string;
|
|
93
94
|
tokan: string;
|
|
95
|
+
tokan1: string;
|
|
94
96
|
tokanStable: string;
|
|
95
97
|
velodrome: string;
|
|
96
98
|
};
|
package/lib/config/farms.js
CHANGED
|
@@ -48,6 +48,7 @@ var Farms;
|
|
|
48
48
|
Farms["aeroStable1"] = "aeroStable1";
|
|
49
49
|
Farms["merchantmoe"] = "merchantmoe";
|
|
50
50
|
Farms["tokan"] = "tokan";
|
|
51
|
+
Farms["tokan1"] = "tokan1";
|
|
51
52
|
Farms["tokanStable"] = "tokanStable";
|
|
52
53
|
Farms["velodrome"] = "velodrome";
|
|
53
54
|
})(Farms = exports.Farms || (exports.Farms = {}));
|
|
@@ -95,6 +96,7 @@ exports.hrFarms = {
|
|
|
95
96
|
[Farms.aeroStable]: 'Aerodrome Stable',
|
|
96
97
|
[Farms.aeroStable1]: 'Aerodrome Stable',
|
|
97
98
|
[Farms.tokan]: 'Tokan',
|
|
99
|
+
[Farms.tokan1]: 'Tokan',
|
|
98
100
|
[Farms.tokanStable]: 'Tokan Stable',
|
|
99
101
|
[Farms.velodrome]: 'Velodrome',
|
|
100
102
|
};
|
|
@@ -172,6 +174,7 @@ exports.STAKED_LP_FACTORY = {
|
|
|
172
174
|
},
|
|
173
175
|
[types_1.Networks.Scroll]: {
|
|
174
176
|
[Farms.tokan]: '0x074568F090e93194289c2C2BF285eE7f60b485a9',
|
|
177
|
+
[Farms.tokan1]: '0x3e35933C468ECEca9748DD1C5FADeFfe64158777',
|
|
175
178
|
[Farms.tokanStable]: '0x6c041ff2d25310a2751C57555265F2364CaCA195',
|
|
176
179
|
},
|
|
177
180
|
[types_1.Networks.Optimism]: {
|
package/lib/offchain/offchain.js
CHANGED
|
@@ -169,6 +169,11 @@ class Offchain {
|
|
|
169
169
|
// Crosschain TVL Data
|
|
170
170
|
getCrossChainTVL() {
|
|
171
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
// Try llama
|
|
173
|
+
const llamaTvl = yield this.getAPRHelper().getImpermaxTvl();
|
|
174
|
+
if (llamaTvl)
|
|
175
|
+
return llamaTvl;
|
|
176
|
+
// Fallback to subgraph
|
|
172
177
|
const tvlData = yield this.getTvlData();
|
|
173
178
|
return tvlData.crossChainTVLUSD;
|
|
174
179
|
});
|
|
@@ -188,6 +193,11 @@ class Offchain {
|
|
|
188
193
|
// This chain TVL Data
|
|
189
194
|
getTotalValueLocked() {
|
|
190
195
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
// Try llama
|
|
197
|
+
const { tvl } = yield this.getAPRHelper().getLlamaTvlAndBorrows(this.network);
|
|
198
|
+
if (tvl)
|
|
199
|
+
return tvl;
|
|
200
|
+
// Gallback to subgraph
|
|
191
201
|
const tvlData = yield this.getTvlData();
|
|
192
202
|
return tvlData.totalBalanceUSD;
|
|
193
203
|
});
|
|
@@ -4,6 +4,8 @@ export default class OffchainPriceHelper {
|
|
|
4
4
|
offchain: Offchain;
|
|
5
5
|
private subgraphTokensPrice;
|
|
6
6
|
private debankTokensPrice;
|
|
7
|
+
private coingeckoInitialized;
|
|
8
|
+
private coingeckoTokenPrices;
|
|
7
9
|
constructor(offchain: Offchain);
|
|
8
10
|
cleanCache(): void;
|
|
9
11
|
private addPriceIfMissing;
|
|
@@ -11,6 +13,7 @@ export default class OffchainPriceHelper {
|
|
|
11
13
|
getSubgraphTokensPrice(): Promise<{
|
|
12
14
|
[key in Address]: number | undefined;
|
|
13
15
|
}>;
|
|
16
|
+
private getAllCoingeckoPrices;
|
|
14
17
|
private getCoingeckoTokenPrice;
|
|
15
18
|
private getDexscreenerTokenPrice;
|
|
16
19
|
private getFantomTokenPrice;
|
|
@@ -38,7 +38,6 @@ const coingecko_ids = {
|
|
|
38
38
|
"0x1a2fcb585b327fadec91f55d45829472b15f17a4": "tokan",
|
|
39
39
|
"0x188b158caf5ea252012dbd6030afc030329c4961": "zen",
|
|
40
40
|
"0xf610a9dfb7c89644979b4a0f27063e9e7d7cda32": "wrapped-steth",
|
|
41
|
-
"0x74ccbe53f77b08632ce0cb91d3a545bf6b8e0979": "fantom-bomb",
|
|
42
41
|
"0xa25b25548b4c98b0c7d3d27dca5d5ca743d68b7f": "wrapped-rseth",
|
|
43
42
|
"0x80137510979822322193fc997d400d5a6c747bf7": "stakestone-ether",
|
|
44
43
|
"0x2b6a85cd35d15691357eea61d88cb3f401a92fc3": "surveyor-dao",
|
|
@@ -55,6 +54,7 @@ const coingecko_ids = {
|
|
|
55
54
|
"0x7002458b1df59eccb57387bc79ffc7c29e22e6f7": "origin-protocol",
|
|
56
55
|
"0xdbfefd2e8460a6ee4955a68582f85708baea60a3": "super-oeth",
|
|
57
56
|
"0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf": "coinbase-wrapped-btc",
|
|
57
|
+
"0x576bca23dcb6d94ff8e537d88b0d3e1bead444a2": "base-carbon-tonne",
|
|
58
58
|
// optimism
|
|
59
59
|
"0x9560e827af36c94d2ac33a39bce1fe78631088db": "velodrome-finance",
|
|
60
60
|
"0x4200000000000000000000000000000000000042": "optimism",
|
|
@@ -78,6 +78,8 @@ const dexscreener_ids = {
|
|
|
78
78
|
"0x994ac01750047B9d35431a7Ae4Ed312ee955E030": "base",
|
|
79
79
|
// opxvelo on op
|
|
80
80
|
"0xc38464250f51123078bbd7ea574e185f6623d037": "optimism",
|
|
81
|
+
// fantom-bomb on scroll (removed from coingecko)
|
|
82
|
+
"0x6b6882f7642ee1c15f12b51f1a4988b3e7e29f5c": "scroll",
|
|
81
83
|
};
|
|
82
84
|
const fantom_ids = {
|
|
83
85
|
// uponly on ftm
|
|
@@ -114,7 +116,9 @@ const fantom_ids = {
|
|
|
114
116
|
"0x5deb27e51dbeef691ba1175a2e563870499c2acb": "fantom"
|
|
115
117
|
};
|
|
116
118
|
class OffchainPriceHelper {
|
|
119
|
+
;
|
|
117
120
|
constructor(offchain) {
|
|
121
|
+
this.coingeckoInitialized = null;
|
|
118
122
|
this.offchain = offchain;
|
|
119
123
|
this.debankTokensPrice = {};
|
|
120
124
|
}
|
|
@@ -163,23 +167,42 @@ class OffchainPriceHelper {
|
|
|
163
167
|
return this.subgraphTokensPrice;
|
|
164
168
|
});
|
|
165
169
|
}
|
|
166
|
-
|
|
170
|
+
getAllCoingeckoPrices() {
|
|
167
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
// Remove duplicates just in case, get the unique coingecko token ids
|
|
173
|
+
const tokenIds = Object.values(coingecko_ids);
|
|
174
|
+
const uniqueIds = [...new Set(tokenIds)].join(",");
|
|
168
175
|
try {
|
|
169
|
-
|
|
170
|
-
const response = yield fetch("https://api.coingecko.com/api/v3/simple/price?ids=" +
|
|
176
|
+
// Get all token prices from gecko
|
|
177
|
+
const response = yield fetch("https://api.coingecko.com/api/v3/simple/price?ids=" + uniqueIds + "&vs_currencies=usd");
|
|
171
178
|
if (response.status != 200)
|
|
172
|
-
return
|
|
179
|
+
return;
|
|
173
180
|
const data = yield response.json();
|
|
174
181
|
if (!data)
|
|
175
|
-
return
|
|
176
|
-
|
|
182
|
+
return;
|
|
183
|
+
// Record of: { 'address_0': price, 'address_1': price }
|
|
184
|
+
this.coingeckoTokenPrices = Object.keys(coingecko_ids).reduce((prices, address) => {
|
|
185
|
+
var _a;
|
|
186
|
+
const tokenId = coingecko_ids[address];
|
|
187
|
+
prices[address] = ((_a = data[tokenId]) === null || _a === void 0 ? void 0 : _a.usd) || 0;
|
|
188
|
+
return prices;
|
|
189
|
+
}, {});
|
|
177
190
|
}
|
|
178
|
-
catch (
|
|
179
|
-
|
|
191
|
+
catch (err) {
|
|
192
|
+
console.log("Gecko API fail");
|
|
193
|
+
this.coingeckoTokenPrices = {};
|
|
180
194
|
}
|
|
181
195
|
});
|
|
182
196
|
}
|
|
197
|
+
getCoingeckoTokenPrice(tokenAddress) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
if (!this.coingeckoInitialized)
|
|
200
|
+
this.coingeckoInitialized = this.getAllCoingeckoPrices();
|
|
201
|
+
yield this.coingeckoInitialized;
|
|
202
|
+
const geckoPrice = this.coingeckoTokenPrices[tokenAddress];
|
|
203
|
+
return geckoPrice || 0;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
183
206
|
getDexscreenerTokenPrice(tokenAddress) {
|
|
184
207
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
208
|
try {
|