@ape.swap/bonds-sdk 1.0.355 → 1.0.356
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/dist/components/BondModal/BondModal.js +20 -11
- package/dist/components/YourBonds/YourBonds.js +43 -62
- package/dist/components/YourBonds/fetchBillsUser.d.ts +3 -3
- package/dist/components/YourBonds/fetchBillsUser.js +4 -4
- package/dist/types/bonds.d.ts +0 -62
- package/dist/types/yourbonds.d.ts +0 -4
- package/package.json +1 -1
- package/dist/config/abi/erc20.json +0 -117
- package/dist/config/abi/price-getter-linea.json +0 -1448
- package/dist/config/abi/price-getter.json +0 -1309
- package/dist/enum/abis.d.ts +0 -80
- package/dist/enum/abis.js +0 -1
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.d.ts +0 -17
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.js +0 -205
- package/dist/state/bills/cleanBillsData.d.ts +0 -5
- package/dist/state/bills/cleanBillsData.js +0 -41
- package/dist/state/bills/fetchBills.d.ts +0 -4
- package/dist/state/bills/fetchBills.js +0 -61
- package/dist/state/bills/fetchBillsCalls.d.ts +0 -4
- package/dist/state/bills/fetchBillsCalls.js +0 -27
- package/dist/state/bills/fetchBillsUser.d.ts +0 -15
- package/dist/state/bills/fetchBillsUser.js +0 -171
- package/dist/state/bills/getBillNftData.d.ts +0 -9
- package/dist/state/bills/getBillNftData.js +0 -109
- package/dist/state/bills/hooks.d.ts +0 -4
- package/dist/state/bills/hooks.js +0 -142
- package/dist/state/bills/index.d.ts +0 -48
- package/dist/state/bills/index.js +0 -293
- package/dist/state/bills/types.d.ts +0 -168
- package/dist/state/bills/types.js +0 -1
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.d.ts +0 -4
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.js +0 -68
- package/dist/state/tokenPrices/getAllTokenPrices.d.ts +0 -5
- package/dist/state/tokenPrices/getAllTokenPrices.js +0 -288
- package/dist/state/tokenPrices/useTokenPricesNew.d.ts +0 -11
- package/dist/state/tokenPrices/useTokenPricesNew.js +0 -72
- package/dist/types/dexFactories.d.ts +0 -11
- package/dist/types/dexFactories.js +0 -2
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
|
-
import { ABOND_ADDRESSES } from '../../config/constants/addresses';
|
|
58
|
-
import { getTokenPricesV2FromPriceGetter } from '../../hooks/PriceGetter/usePricesFromPriceGetter';
|
|
59
|
-
import { getBalanceNumber } from '../../utils/getBalanceNumber';
|
|
60
|
-
import { cloneDeep } from 'lodash';
|
|
61
|
-
import multicall from '../../utils/multicall';
|
|
62
|
-
import ERC20ABI from '../../config/abi/erc20.json';
|
|
63
|
-
import axios from 'axios';
|
|
64
|
-
import { ChainId, LiquidityDex } from '../../enum/apeswaplists';
|
|
65
|
-
var getAllTokenPrices = function (chainId, tokens) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
-
var dexScreenerTokensToCall, filterTokensToCall, filterLpTokensToCall, arrayFilterTokens, abondIndex, parsedDexscreenerTokens, dexScreenerResults, tokenResults, lpTokenResults, parsedTokenResults, parsedLpTokenResults;
|
|
67
|
-
return __generator(this, function (_a) {
|
|
68
|
-
switch (_a.label) {
|
|
69
|
-
case 0:
|
|
70
|
-
dexScreenerTokensToCall = Object.fromEntries(Object.entries(tokens).filter(function (_a) {
|
|
71
|
-
var _b;
|
|
72
|
-
var token = _a[1];
|
|
73
|
-
return ((_b = token === null || token === void 0 ? void 0 : token.liquidityDex) === null || _b === void 0 ? void 0 : _b[chainId]) === LiquidityDex.External;
|
|
74
|
-
}));
|
|
75
|
-
filterTokensToCall = Object.fromEntries(Object.entries(tokens).filter(function (_a) {
|
|
76
|
-
var _b, _c;
|
|
77
|
-
var token = _a[1];
|
|
78
|
-
return ((token === null || token === void 0 ? void 0 : token.active) &&
|
|
79
|
-
!(token === null || token === void 0 ? void 0 : token.lpToken) &&
|
|
80
|
-
token.address[chainId] &&
|
|
81
|
-
((_b = token.decimals) === null || _b === void 0 ? void 0 : _b[chainId]) &&
|
|
82
|
-
((_c = token === null || token === void 0 ? void 0 : token.liquidityDex) === null || _c === void 0 ? void 0 : _c[chainId]) !== LiquidityDex.External);
|
|
83
|
-
}));
|
|
84
|
-
filterLpTokensToCall = Object.fromEntries(Object.entries(tokens).filter(function (_a) {
|
|
85
|
-
var _b, _c;
|
|
86
|
-
var token = _a[1];
|
|
87
|
-
return ((token === null || token === void 0 ? void 0 : token.active) &&
|
|
88
|
-
(token === null || token === void 0 ? void 0 : token.lpToken) &&
|
|
89
|
-
token.address[chainId] &&
|
|
90
|
-
((_b = token.decimals) === null || _b === void 0 ? void 0 : _b[chainId]) &&
|
|
91
|
-
((_c = token === null || token === void 0 ? void 0 : token.liquidityDex) === null || _c === void 0 ? void 0 : _c[chainId]) !== LiquidityDex.External);
|
|
92
|
-
}));
|
|
93
|
-
arrayFilterTokens = Object.values(filterTokensToCall);
|
|
94
|
-
abondIndex = arrayFilterTokens.findIndex(function (token) { var _a, _b; return ((_a = token.address[chainId]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = ABOND_ADDRESSES[chainId]) === null || _b === void 0 ? void 0 : _b.toLowerCase()); });
|
|
95
|
-
parsedDexscreenerTokens = Object.values(dexScreenerTokensToCall).map(function (token) {
|
|
96
|
-
var _a, _b, _c, _d;
|
|
97
|
-
return __assign(__assign({}, token), { address: (_a = token.address[chainId]) !== null && _a !== void 0 ? _a : '', decimals: (_c = (_b = token === null || token === void 0 ? void 0 : token.decimals) === null || _b === void 0 ? void 0 : _b[chainId]) !== null && _c !== void 0 ? _c : 18, lpToken: (_d = token.lpToken) !== null && _d !== void 0 ? _d : false });
|
|
98
|
-
});
|
|
99
|
-
if (chainId === ChainId.BSC_TESTNET) {
|
|
100
|
-
return [2 /*return*/, arrayFilterTokens.map(function (token) {
|
|
101
|
-
var _a, _b;
|
|
102
|
-
return {
|
|
103
|
-
symbol: token.symbol,
|
|
104
|
-
address: token.address[chainId],
|
|
105
|
-
price: 1,
|
|
106
|
-
decimals: (_b = (_a = token.decimals) === null || _a === void 0 ? void 0 : _a[chainId]) !== null && _b !== void 0 ? _b : undefined,
|
|
107
|
-
chainId: chainId,
|
|
108
|
-
};
|
|
109
|
-
})];
|
|
110
|
-
}
|
|
111
|
-
return [4 /*yield*/, getBatchTokenPriceWithDexscreener({ chainId: chainId, tokens: parsedDexscreenerTokens })];
|
|
112
|
-
case 1:
|
|
113
|
-
dexScreenerResults = _a.sent();
|
|
114
|
-
return [4 /*yield*/, getTokenPricesV2FromPriceGetter(filterTokensToCall, chainId, false)];
|
|
115
|
-
case 2:
|
|
116
|
-
tokenResults = _a.sent();
|
|
117
|
-
return [4 /*yield*/, getTokenPricesV2FromPriceGetter(filterLpTokensToCall, chainId, true)];
|
|
118
|
-
case 3:
|
|
119
|
-
lpTokenResults = _a.sent();
|
|
120
|
-
parsedTokenResults = arrayFilterTokens.map(function (token, i) {
|
|
121
|
-
var _a, _b, _c, _d;
|
|
122
|
-
var price = token.symbol.toLowerCase() === 'veabond'
|
|
123
|
-
? getBalanceNumber((_a = tokenResults === null || tokenResults === void 0 ? void 0 : tokenResults[abondIndex]) === null || _a === void 0 ? void 0 : _a.toString(), 18)
|
|
124
|
-
: getBalanceNumber((_b = tokenResults === null || tokenResults === void 0 ? void 0 : tokenResults[i]) === null || _b === void 0 ? void 0 : _b.toString(), 18);
|
|
125
|
-
return {
|
|
126
|
-
symbol: token.symbol,
|
|
127
|
-
address: token.address[chainId],
|
|
128
|
-
price: price !== null && price !== void 0 ? price : undefined,
|
|
129
|
-
decimals: (_d = (_c = token.decimals) === null || _c === void 0 ? void 0 : _c[chainId]) !== null && _d !== void 0 ? _d : undefined,
|
|
130
|
-
chainId: chainId,
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
parsedLpTokenResults = Object.values(filterLpTokensToCall).map(function (token, i) {
|
|
134
|
-
var _a, _b;
|
|
135
|
-
return {
|
|
136
|
-
symbol: token.symbol,
|
|
137
|
-
address: token.address[chainId],
|
|
138
|
-
price: getBalanceNumber(lpTokenResults[i].toString(), 18),
|
|
139
|
-
decimals: (_b = (_a = token.decimals) === null || _a === void 0 ? void 0 : _a[chainId]) !== null && _b !== void 0 ? _b : undefined,
|
|
140
|
-
chainId: chainId,
|
|
141
|
-
};
|
|
142
|
-
});
|
|
143
|
-
return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], parsedTokenResults, true), parsedLpTokenResults, true), dexScreenerResults, true)];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}); };
|
|
147
|
-
export default getAllTokenPrices;
|
|
148
|
-
var getBatchTokenPriceWithDexscreener = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
149
|
-
var chainId, tokens, tokensCopy, baseURL_1, totalSupplies_1, chains_1, chainName_1, calls, result, error_1;
|
|
150
|
-
return __generator(this, function (_a) {
|
|
151
|
-
switch (_a.label) {
|
|
152
|
-
case 0:
|
|
153
|
-
chainId = params.chainId, tokens = params.tokens;
|
|
154
|
-
tokensCopy = cloneDeep(tokens);
|
|
155
|
-
_a.label = 1;
|
|
156
|
-
case 1:
|
|
157
|
-
_a.trys.push([1, 3, , 4]);
|
|
158
|
-
baseURL_1 = 'https://api.dexscreener.com/latest/dex';
|
|
159
|
-
totalSupplies_1 = [];
|
|
160
|
-
chains_1 = [];
|
|
161
|
-
chainName_1 = getDexScreenerChainName(chainId);
|
|
162
|
-
calls = tokensCopy.map(function (token) { return __awaiter(void 0, void 0, void 0, function () {
|
|
163
|
-
var symbol, lpToken, totalSupply, decimals, endpoint, calls_1, supply, _a, url, response, error_2;
|
|
164
|
-
return __generator(this, function (_b) {
|
|
165
|
-
switch (_b.label) {
|
|
166
|
-
case 0:
|
|
167
|
-
symbol = token.symbol, lpToken = token.lpToken, totalSupply = token.totalSupply, decimals = token.decimals;
|
|
168
|
-
if (['USDT', 'USDC'].includes(symbol)) {
|
|
169
|
-
chains_1.push('injective');
|
|
170
|
-
return [2 /*return*/, {
|
|
171
|
-
pairs: [
|
|
172
|
-
{
|
|
173
|
-
chainId: chainName_1,
|
|
174
|
-
baseToken: {
|
|
175
|
-
address: token.address,
|
|
176
|
-
},
|
|
177
|
-
liquidity: {
|
|
178
|
-
usd: 1,
|
|
179
|
-
},
|
|
180
|
-
priceUsd: 1,
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
}];
|
|
184
|
-
}
|
|
185
|
-
if (symbol.toLowerCase() === 'inj' || symbol.toLowerCase() === 'winj') {
|
|
186
|
-
token.address = 'inj';
|
|
187
|
-
}
|
|
188
|
-
if (!chainName_1) {
|
|
189
|
-
console.log("Chain ".concat(chainId, " is not supported by dexscreener."));
|
|
190
|
-
return [2 /*return*/, null];
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
chains_1.push(chainName_1);
|
|
194
|
-
}
|
|
195
|
-
if (!lpToken) return [3 /*break*/, 4];
|
|
196
|
-
if (!!totalSupply) return [3 /*break*/, 2];
|
|
197
|
-
calls_1 = [
|
|
198
|
-
{
|
|
199
|
-
address: token.address,
|
|
200
|
-
name: 'totalSupply',
|
|
201
|
-
},
|
|
202
|
-
];
|
|
203
|
-
_a = getBalanceNumber;
|
|
204
|
-
return [4 /*yield*/, multicall(chainId, ERC20ABI, calls_1)];
|
|
205
|
-
case 1:
|
|
206
|
-
supply = _a.apply(void 0, [(_b.sent())[0], decimals]);
|
|
207
|
-
totalSupplies_1.push(supply);
|
|
208
|
-
return [3 /*break*/, 3];
|
|
209
|
-
case 2:
|
|
210
|
-
totalSupplies_1.push(totalSupply);
|
|
211
|
-
_b.label = 3;
|
|
212
|
-
case 3:
|
|
213
|
-
endpoint = "pairs/".concat(chainName_1);
|
|
214
|
-
return [3 /*break*/, 5];
|
|
215
|
-
case 4:
|
|
216
|
-
endpoint = "tokens";
|
|
217
|
-
_b.label = 5;
|
|
218
|
-
case 5:
|
|
219
|
-
url = "".concat(baseURL_1, "/").concat(endpoint, "/").concat(token.address);
|
|
220
|
-
_b.label = 6;
|
|
221
|
-
case 6:
|
|
222
|
-
_b.trys.push([6, 8, , 9]);
|
|
223
|
-
return [4 /*yield*/, axios.get(url)];
|
|
224
|
-
case 7:
|
|
225
|
-
response = _b.sent();
|
|
226
|
-
return [2 /*return*/, response.data];
|
|
227
|
-
case 8:
|
|
228
|
-
error_2 = _b.sent();
|
|
229
|
-
console.log("Failed to fetch data for token ".concat(token.address, ": ").concat(error_2));
|
|
230
|
-
return [2 /*return*/, null];
|
|
231
|
-
case 9: return [2 /*return*/];
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
}); });
|
|
235
|
-
return [4 /*yield*/, Promise.all(calls)];
|
|
236
|
-
case 2:
|
|
237
|
-
result = _a.sent();
|
|
238
|
-
return [2 /*return*/, result.map(function (response, index) {
|
|
239
|
-
var _a;
|
|
240
|
-
if (!response || !response.pairs) {
|
|
241
|
-
return __assign(__assign({}, tokensCopy === null || tokensCopy === void 0 ? void 0 : tokensCopy[index]), { price: undefined, chainId: chainId });
|
|
242
|
-
}
|
|
243
|
-
var supply = totalSupplies_1[index];
|
|
244
|
-
var token = tokensCopy[index];
|
|
245
|
-
var price;
|
|
246
|
-
try {
|
|
247
|
-
if (token.lpToken) {
|
|
248
|
-
var liquidity = response.pair.liquidity.usd;
|
|
249
|
-
price = liquidity / supply;
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
var pairs = response.pairs;
|
|
253
|
-
price = (_a = pairs
|
|
254
|
-
.filter(function (pair) {
|
|
255
|
-
return pair.chainId === chainName_1 && pair.baseToken.address.toLowerCase() === token.address.toLowerCase();
|
|
256
|
-
})
|
|
257
|
-
.sort(function (a, b) { var _a, _b; return ((_a = b === null || b === void 0 ? void 0 : b.liquidity) === null || _a === void 0 ? void 0 : _a.usd) - ((_b = a === null || a === void 0 ? void 0 : a.liquidity) === null || _b === void 0 ? void 0 : _b.usd); })[0]) === null || _a === void 0 ? void 0 : _a.priceUsd;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
catch (error) {
|
|
261
|
-
price = undefined;
|
|
262
|
-
}
|
|
263
|
-
return __assign(__assign({}, tokensCopy === null || tokensCopy === void 0 ? void 0 : tokensCopy[index]), { address: token.address === 'inj' ? '0x4569348D39cc38F4d6a1180573Df73B7b03251d9' : token.address, chainId: chainId, price: parseFloat(price !== null && price !== void 0 ? price : '0') });
|
|
264
|
-
})];
|
|
265
|
-
case 3:
|
|
266
|
-
error_1 = _a.sent();
|
|
267
|
-
console.log("Failed to get price from dexscreener for chain ".concat(chainId, "."));
|
|
268
|
-
return [2 /*return*/, tokensCopy.map(function (token) {
|
|
269
|
-
return __assign(__assign({}, token), { chainId: chainId, price: undefined });
|
|
270
|
-
})];
|
|
271
|
-
case 4: return [2 /*return*/];
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
}); };
|
|
275
|
-
export var getDexScreenerChainName = function (chainId) {
|
|
276
|
-
var _a;
|
|
277
|
-
var chainsName = (_a = {},
|
|
278
|
-
_a[ChainId.MAINNET] = 'ethereum',
|
|
279
|
-
_a[ChainId.TLOS] = 'telos',
|
|
280
|
-
_a[ChainId.BSC] = 'bsc',
|
|
281
|
-
_a[ChainId.MATIC] = 'polygon',
|
|
282
|
-
_a[ChainId.ARBITRUM] = 'arbitrum',
|
|
283
|
-
_a[ChainId.INEVM] = 'injective',
|
|
284
|
-
_a[ChainId.LINEA] = 'linea',
|
|
285
|
-
_a);
|
|
286
|
-
//@ts-ignore
|
|
287
|
-
return chainsName[chainId];
|
|
288
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ChainId } from '../../enum/apeswaplists';
|
|
2
|
-
export interface TokenPrices {
|
|
3
|
-
symbol: string | undefined;
|
|
4
|
-
address: string | undefined;
|
|
5
|
-
price: number | undefined;
|
|
6
|
-
decimals: number | undefined;
|
|
7
|
-
chainId: ChainId | undefined;
|
|
8
|
-
}
|
|
9
|
-
export declare const fetchPrices: () => Promise<TokenPrices[]>;
|
|
10
|
-
export default function useTokenPricesNew(): import("@tanstack/react-query/build/legacy/types").UseQueryResult<TokenPrices[], Error>;
|
|
11
|
-
export declare const useTokenPriceNew: (inputTokenAddress: string, chainId: ChainId) => number | undefined;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { useQuery } from '@tanstack/react-query';
|
|
38
|
-
import { QUERY_KEYS } from '../../config/constants/queryKeys';
|
|
39
|
-
import fetchTokenPricesForMultipleChains from './fetchTokenPricesForMultipleChains';
|
|
40
|
-
import { MAINNET_CHAINS } from '../../config/constants/chains';
|
|
41
|
-
import { WRAPPED_NATIVE_CURRENCY } from '../../config/constants/tokens';
|
|
42
|
-
export var fetchPrices = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
return __generator(this, function (_a) {
|
|
44
|
-
switch (_a.label) {
|
|
45
|
-
case 0: return [4 /*yield*/, fetchTokenPricesForMultipleChains(MAINNET_CHAINS)];
|
|
46
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}); };
|
|
50
|
-
export default function useTokenPricesNew() {
|
|
51
|
-
return useQuery({
|
|
52
|
-
queryKey: [QUERY_KEYS.TOKEN_PRICES],
|
|
53
|
-
queryFn: fetchPrices,
|
|
54
|
-
refetchInterval: 40000,
|
|
55
|
-
refetchOnWindowFocus: false,
|
|
56
|
-
refetchOnMount: false,
|
|
57
|
-
retry: 1,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
export var useTokenPriceNew = function (inputTokenAddress, chainId) {
|
|
61
|
-
var _a;
|
|
62
|
-
var tokenPrices = useTokenPricesNew().data;
|
|
63
|
-
return (_a = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find(function (tokenPrice) {
|
|
64
|
-
var _a, _b, _c, _d, _e;
|
|
65
|
-
if (inputTokenAddress === 'ETH') {
|
|
66
|
-
return (((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_c = (_b = WRAPPED_NATIVE_CURRENCY[chainId]) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c.toLowerCase()) &&
|
|
67
|
-
((_d = WRAPPED_NATIVE_CURRENCY[chainId]) === null || _d === void 0 ? void 0 : _d.chainId) === chainId);
|
|
68
|
-
}
|
|
69
|
-
else
|
|
70
|
-
return ((_e = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.address) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === (inputTokenAddress === null || inputTokenAddress === void 0 ? void 0 : inputTokenAddress.toLowerCase()) && tokenPrice.chainId === chainId;
|
|
71
|
-
})) === null || _a === void 0 ? void 0 : _a.price;
|
|
72
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ChainId, LiquidityDex, Protocols } from "../enum/apeswaplists";
|
|
2
|
-
type DexInfo = {
|
|
3
|
-
factory: string;
|
|
4
|
-
router?: string;
|
|
5
|
-
protocol: Protocols;
|
|
6
|
-
};
|
|
7
|
-
type dexFactories = Partial<Record<ChainId, Partial<Record<LiquidityDex, DexInfo>>>>;
|
|
8
|
-
type defaultDexFactories = Partial<Record<ChainId, Partial<Record<Protocols, string>>>>;
|
|
9
|
-
export declare const dexFactories: dexFactories;
|
|
10
|
-
export declare const defaultDexFactories: defaultDexFactories;
|
|
11
|
-
export {};
|