impermax-sdk 1.2.44 → 1.2.46
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 +3 -1
- package/lib/config/amms.js +7 -2
- package/lib/config/contracts/impermax-factories.js +1 -0
- package/lib/config/contracts/routers.js +2 -1
- package/lib/config/subgraphs.js +2 -1
- package/lib/offchain/offchainPriceHelper.d.ts +1 -0
- package/lib/offchain/offchainPriceHelper.js +51 -15
- package/package.json +1 -1
package/lib/config/amms.d.ts
CHANGED
|
@@ -34,7 +34,8 @@ export declare enum Amms {
|
|
|
34
34
|
pearlStable = "pearlStable",
|
|
35
35
|
aerodrome = "aerodrome",
|
|
36
36
|
merchantmoe = "merchantmoe",
|
|
37
|
-
tokan = "tokan"
|
|
37
|
+
tokan = "tokan",
|
|
38
|
+
tokanStable = "tokanStable"
|
|
38
39
|
}
|
|
39
40
|
export declare const hrAmms: {
|
|
40
41
|
uniswap: string;
|
|
@@ -72,6 +73,7 @@ export declare const hrAmms: {
|
|
|
72
73
|
aerodrome: string;
|
|
73
74
|
merchantmoe: string;
|
|
74
75
|
tokan: string;
|
|
76
|
+
tokanStable: string;
|
|
75
77
|
};
|
|
76
78
|
export declare const AMM_FACTORY: AmmIndex;
|
|
77
79
|
export declare function getAmmByFactory(network: Networks, address: Address): Amms | null;
|
package/lib/config/amms.js
CHANGED
|
@@ -39,6 +39,7 @@ var Amms;
|
|
|
39
39
|
Amms["aerodrome"] = "aerodrome";
|
|
40
40
|
Amms["merchantmoe"] = "merchantmoe";
|
|
41
41
|
Amms["tokan"] = "tokan";
|
|
42
|
+
Amms["tokanStable"] = "tokanStable";
|
|
42
43
|
})(Amms = exports.Amms || (exports.Amms = {}));
|
|
43
44
|
exports.hrAmms = {
|
|
44
45
|
[Amms.uniswap]: 'Uniswap',
|
|
@@ -76,6 +77,7 @@ exports.hrAmms = {
|
|
|
76
77
|
[Amms.aerodrome]: 'Aerodrome',
|
|
77
78
|
[Amms.merchantmoe]: 'MerchantMoe',
|
|
78
79
|
[Amms.tokan]: 'Tokan',
|
|
80
|
+
[Amms.tokanStable]: 'Tokan',
|
|
79
81
|
};
|
|
80
82
|
exports.AMM_FACTORY = {
|
|
81
83
|
[types_1.Networks.Ropsten]: {
|
|
@@ -145,7 +147,8 @@ exports.AMM_FACTORY = {
|
|
|
145
147
|
[Amms.uniswap]: '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6'
|
|
146
148
|
},
|
|
147
149
|
[types_1.Networks.Scroll]: {
|
|
148
|
-
[Amms.tokan]: '0x074568F090e93194289c2C2BF285eE7f60b485a9',
|
|
150
|
+
[Amms.tokan]: '0x074568F090e93194289c2C2BF285eE7f60b485a9',
|
|
151
|
+
[Amms.tokanStable]: '0x6c041ff2d25310a2751C57555265F2364CaCA195', //NOTICE: this is actually the staked LP factory
|
|
149
152
|
}
|
|
150
153
|
};
|
|
151
154
|
function getAmmByFactory(network, address) {
|
|
@@ -210,7 +213,7 @@ exports.AMM_SUBGRAPH_URLS = {
|
|
|
210
213
|
[types_1.Networks.Sxnetwork]: {},
|
|
211
214
|
[types_1.Networks.Base]: {
|
|
212
215
|
[Amms.aerodrome]: 'https://api.thegraph.com/subgraphs/name/ethzoomer/aerodrome-trading-data',
|
|
213
|
-
[Amms.uniswap]: 'https://api.thegraph.com/
|
|
216
|
+
[Amms.uniswap]: 'https://api.studio.thegraph.com/query/46041/uniswap-v2-base/v0.0.1',
|
|
214
217
|
},
|
|
215
218
|
[types_1.Networks.Mantle]: {},
|
|
216
219
|
[types_1.Networks.Scroll]: {},
|
|
@@ -283,6 +286,7 @@ exports.ADD_LIQUIDITY_URLS = {
|
|
|
283
286
|
},
|
|
284
287
|
[types_1.Networks.Scroll]: {
|
|
285
288
|
[Amms.tokan]: 'https://app.tokan.exchange/liquidity/',
|
|
289
|
+
[Amms.tokanStable]: 'https://app.tokan.exchange/liquidity/',
|
|
286
290
|
},
|
|
287
291
|
};
|
|
288
292
|
exports.AMM_LP_FEE = {
|
|
@@ -350,6 +354,7 @@ exports.AMM_LP_FEE = {
|
|
|
350
354
|
},
|
|
351
355
|
[types_1.Networks.Scroll]: {
|
|
352
356
|
[Amms.tokan]: 0,
|
|
357
|
+
[Amms.tokanStable]: 0,
|
|
353
358
|
},
|
|
354
359
|
[types_1.Networks.Mantle]: {
|
|
355
360
|
[Amms.merchantmoe]: 0.003,
|
|
@@ -47,6 +47,7 @@ exports.IMPERMAX_FACTORY = {
|
|
|
47
47
|
},
|
|
48
48
|
[types_1.Networks.Scroll]: {
|
|
49
49
|
[types_1.Factory.SOLV2]: '0x02Ff7B4d96EeBF8c9B34Fae0418E591e11da3099',
|
|
50
|
+
[types_1.Factory.SOL_STABLE]: '0x44F7E2FcF7d52fF1C200Fa2510fA7702Dc1272b4',
|
|
50
51
|
},
|
|
51
52
|
[types_1.Networks.Mantle]: {
|
|
52
53
|
[types_1.Factory.V2V2]: '0x3047523D5ed0df1545B1C440BdAaB095f1f3cf5C'
|
|
@@ -50,7 +50,8 @@ exports.ROUTER = {
|
|
|
50
50
|
[types_1.Factory.V2V2]: '0x21D9d4d17255d427A5F77D23fb9Eb3c5Cd281ebf'
|
|
51
51
|
},
|
|
52
52
|
[types_1.Networks.Scroll]: {
|
|
53
|
-
[types_1.Factory.SOLV2]: '0xFF8D0CDC9C857c7fA265121394558B26e1eAAffE'
|
|
53
|
+
[types_1.Factory.SOLV2]: '0xFF8D0CDC9C857c7fA265121394558B26e1eAAffE',
|
|
54
|
+
[types_1.Factory.SOL_STABLE]: '0x791f517EF0364D20bcF4dB89Cbf016D95A0fe09d'
|
|
54
55
|
},
|
|
55
56
|
[types_1.Networks.Mantle]: {
|
|
56
57
|
[types_1.Factory.V2V2]: '0xF4A9dda025e65945E7A3F873D6146A12c8110A19'
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -45,10 +45,11 @@ exports.IMPERMAX_SUBGRAPH_URL = {
|
|
|
45
45
|
[types_1.Networks.Sxnetwork]: {},
|
|
46
46
|
[types_1.Networks.Base]: {
|
|
47
47
|
[types_1.Factory.SOLV2]: 'https://api.studio.thegraph.com/query/46041/impermax-base-solv2/v0.0.2',
|
|
48
|
-
[types_1.Factory.V2V2]: 'https://api.studio.thegraph.com/query/46041/
|
|
48
|
+
[types_1.Factory.V2V2]: 'https://api.studio.thegraph.com/query/46041/impermax-base-v2/v0.0.1',
|
|
49
49
|
},
|
|
50
50
|
[types_1.Networks.Scroll]: {
|
|
51
51
|
[types_1.Factory.SOLV2]: 'https://api.studio.thegraph.com/query/46041/impermax-scroll-solv2/v0.0.1',
|
|
52
|
+
[types_1.Factory.SOL_STABLE]: 'https://api.studio.thegraph.com/query/46041/impermax-scroll-solv2-stable/v0.0.2'
|
|
52
53
|
},
|
|
53
54
|
};
|
|
54
55
|
exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
|
|
@@ -12,6 +12,7 @@ export default class OffchainPriceHelper {
|
|
|
12
12
|
[key in Address]: number | undefined;
|
|
13
13
|
}>;
|
|
14
14
|
private getCoingeckoTokenPrice;
|
|
15
|
+
private getDexscreenerTokenPrice;
|
|
15
16
|
private initializeDebankTokenPrice;
|
|
16
17
|
getDebankTokenPrice(tokenAddress: Address): Promise<number>;
|
|
17
18
|
}
|
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const debank_ids_1 = require("../config/debank-ids");
|
|
13
12
|
// coingecko has priority over debank for initialized tokens
|
|
14
13
|
const coingecko_ids = {
|
|
15
14
|
//Polygon
|
|
@@ -37,14 +36,27 @@ const coingecko_ids = {
|
|
|
37
36
|
"0x160e07e42adbc1fce92d505b579bcd8a3fbea77d": "dracula-fi",
|
|
38
37
|
// Scroll
|
|
39
38
|
"0x1a2fcb585b327fadec91f55d45829472b15f17a4": "tokan",
|
|
40
|
-
"0x78ab77f7d590fb101aa18affc238cbfea31ead5b": "impermax",
|
|
41
39
|
"0xf610a9dfb7c89644979b4a0f27063e9e7d7cda32": "wrapped-steth",
|
|
42
40
|
"0x74ccbe53f77b08632ce0cb91d3a545bf6b8e0979": "fantom-bomb",
|
|
41
|
+
"0xa25b25548b4c98b0c7d3d27dca5d5ca743d68b7f": "wrapped-rseth",
|
|
42
|
+
"0x80137510979822322193fc997d400d5a6c747bf7": "stakestone-ether",
|
|
43
43
|
// base
|
|
44
44
|
"0x940181a94a35a4569e4529a3cdfb74e38fd98631": "aerodrome-finance",
|
|
45
45
|
"0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed": "degen-base",
|
|
46
46
|
"0x4200000000000000000000000000000000000006": "ethereum"
|
|
47
47
|
};
|
|
48
|
+
const dexscreener_ids = {
|
|
49
|
+
// ibex on scroll
|
|
50
|
+
"0x78ab77f7d590fb101aa18affc238cbfea31ead5b": "scroll",
|
|
51
|
+
// ibex on polygon
|
|
52
|
+
"0xf972daced7c6b03223710c11413036d17eb298f6": "polygon",
|
|
53
|
+
// ibex on arb
|
|
54
|
+
"0x56659245931cb6920e39c189d2a0e7dd0da2d57b": "arbitrum",
|
|
55
|
+
// ibex on zksync
|
|
56
|
+
"0xbe9f8c0d6f0fd7e46cdacca340747ea2f247991d": "zksync",
|
|
57
|
+
// fantom-bomb on scroll
|
|
58
|
+
"0x74ccbe53f77b08632ce0cb91d3a545bf6b8e0979": "scroll",
|
|
59
|
+
};
|
|
48
60
|
class OffchainPriceHelper {
|
|
49
61
|
constructor(offchain) {
|
|
50
62
|
this.offchain = offchain;
|
|
@@ -109,31 +121,55 @@ class OffchainPriceHelper {
|
|
|
109
121
|
}
|
|
110
122
|
});
|
|
111
123
|
}
|
|
112
|
-
|
|
124
|
+
getDexscreenerTokenPrice(tokenAddress) {
|
|
113
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
if (Object.keys(coingecko_ids).includes(tokenAddress.toLowerCase())) {
|
|
115
|
-
const result = yield this.getCoingeckoTokenPrice(tokenAddress.toLowerCase());
|
|
116
|
-
if (result)
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
126
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
"https://pro-openapi.debank.com/v1/token?chain_id=" + debank_chain_ids[this.offchain.network] + "&id=" + tokenAddress,
|
|
123
|
-
{headers: {"AccessKey": "0ac0fba6aeb0905b4c9a1c5cfd9d48d74fbc60e0"}}
|
|
124
|
-
);*/
|
|
127
|
+
const chainId = dexscreener_ids[tokenAddress];
|
|
128
|
+
const response = yield fetch("https://api.dexscreener.com/latest/dex/search?q=" + tokenAddress);
|
|
125
129
|
if (response.status != 200)
|
|
126
130
|
return 0;
|
|
127
131
|
const data = yield response.json();
|
|
128
|
-
if (!data)
|
|
132
|
+
if (!data || !data.pairs || data.pairs.length === 0)
|
|
129
133
|
return 0;
|
|
130
|
-
|
|
134
|
+
const pairs = data.pairs;
|
|
135
|
+
const pairItem = pairs.filter((pair) => pair.chainId == chainId && (pair.baseToken.address.toLowerCase() == tokenAddress || pair.quoteToken.address.toLowerCase() == tokenAddress));
|
|
136
|
+
return pairItem.length > 0 ? pairItem[0].priceUsd : 0;
|
|
131
137
|
}
|
|
132
138
|
catch (_a) {
|
|
133
139
|
return 0;
|
|
134
140
|
}
|
|
135
141
|
});
|
|
136
142
|
}
|
|
143
|
+
initializeDebankTokenPrice(tokenAddress) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
if (Object.keys(dexscreener_ids).includes(tokenAddress.toLowerCase())) {
|
|
146
|
+
const result = yield this.getDexscreenerTokenPrice(tokenAddress.toLowerCase());
|
|
147
|
+
if (result)
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
if (Object.keys(coingecko_ids).includes(tokenAddress.toLowerCase())) {
|
|
151
|
+
const result = yield this.getCoingeckoTokenPrice(tokenAddress.toLowerCase());
|
|
152
|
+
if (result)
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
return 0;
|
|
156
|
+
// openapi is currently failing always so just commented out
|
|
157
|
+
// try {
|
|
158
|
+
// const response = await fetch("https://openapi.debank.com/v1/token?chain_id=" + DEBANK_IDS[this.offchain.network] + "&id=" + tokenAddress);
|
|
159
|
+
// /*const response = await fetch(
|
|
160
|
+
// "https://pro-openapi.debank.com/v1/token?chain_id=" + debank_chain_ids[this.offchain.network] + "&id=" + tokenAddress,
|
|
161
|
+
// {headers: {"AccessKey": "0ac0fba6aeb0905b4c9a1c5cfd9d48d74fbc60e0"}}
|
|
162
|
+
// );*/
|
|
163
|
+
// if (response.status != 200) return 0;
|
|
164
|
+
// const data = await response.json();
|
|
165
|
+
// if (!data) return 0;
|
|
166
|
+
// return data.price ? data.price : 0;
|
|
167
|
+
// }
|
|
168
|
+
// catch {
|
|
169
|
+
// return 0;
|
|
170
|
+
// }
|
|
171
|
+
});
|
|
172
|
+
}
|
|
137
173
|
getDebankTokenPrice(tokenAddress) {
|
|
138
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
175
|
if (tokenAddress.toLowerCase() === '0xf28164a485b0b2c90639e47b0f377b4a438a16b1') { // fix for dQuick
|