@fileverse-dev/formulajs 4.4.11-mod-46 → 4.4.11-mod-48
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/browser/formula.js +307 -260
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +63 -51
- package/lib/esm/crypto-constants.mjs +7 -6
- package/lib/esm/index.mjs +63 -51
- package/package.json +1 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -13092,7 +13092,8 @@ const SERVICE_API_KEY = {
|
|
|
13092
13092
|
Firefly: "FIRE_FLY_API_KEY",
|
|
13093
13093
|
GnosisPay: 'GNOSIS_API_KEY',
|
|
13094
13094
|
Neynar: 'NEYNAR_API_KEY',
|
|
13095
|
-
Defillama: 'DEFILLAMA_API_KEY'
|
|
13095
|
+
Defillama: 'DEFILLAMA_API_KEY',
|
|
13096
|
+
Uniswap: 'UNISWAP_API_KEY'
|
|
13096
13097
|
};
|
|
13097
13098
|
|
|
13098
13099
|
const fromTimeStampToBlock = async (timestamp, chain, apiKey) => {
|
|
@@ -13216,13 +13217,10 @@ if (scanKey === SERVICE_API_KEY.Gnosisscan) chainId = 'gnosis';
|
|
|
13216
13217
|
}
|
|
13217
13218
|
}
|
|
13218
13219
|
|
|
13219
|
-
const fromUsernameToFid = async (username) => {
|
|
13220
|
+
const fromUsernameToFid = async (username, apiKey) => {
|
|
13220
13221
|
if(!username) return null
|
|
13221
|
-
const url = `https://api.neynar.com/v2/farcaster/user/search
|
|
13222
|
+
const url = `https://api.neynar.com/v2/farcaster/user/search/?q=${username}&limit=5`;
|
|
13222
13223
|
const res = await fetch(url, {
|
|
13223
|
-
query: {
|
|
13224
|
-
q: username
|
|
13225
|
-
},
|
|
13226
13224
|
headers: {
|
|
13227
13225
|
'x-api-key': API_KEY,
|
|
13228
13226
|
'x-neynar-experimental': 'false'
|
|
@@ -13348,7 +13346,7 @@ async function LENS() {
|
|
|
13348
13346
|
flat[key] = value;
|
|
13349
13347
|
}
|
|
13350
13348
|
}
|
|
13351
|
-
flat.platform =
|
|
13349
|
+
flat.platform = 'lens';
|
|
13352
13350
|
return flat;
|
|
13353
13351
|
});
|
|
13354
13352
|
|
|
@@ -13401,7 +13399,7 @@ async function FARCASTER() {
|
|
|
13401
13399
|
flat[key] = value;
|
|
13402
13400
|
}
|
|
13403
13401
|
}
|
|
13404
|
-
flat.platform =
|
|
13402
|
+
flat.platform = "farcaster";
|
|
13405
13403
|
return flat;
|
|
13406
13404
|
});
|
|
13407
13405
|
|
|
@@ -13733,8 +13731,25 @@ async function COINGECKO(category, param1, param2) {
|
|
|
13733
13731
|
if (json.length > 200) {
|
|
13734
13732
|
data = json.slice(0, 200);
|
|
13735
13733
|
}
|
|
13736
|
-
|
|
13737
|
-
|
|
13734
|
+
|
|
13735
|
+
if(param1 !== 'all' && json && json.tickers){
|
|
13736
|
+
const exchangeDetails = {
|
|
13737
|
+
exchange_id: param1,
|
|
13738
|
+
exchange_name: json.name,
|
|
13739
|
+
exchange_logo: json.logo,
|
|
13740
|
+
exchange_url: json.url,
|
|
13741
|
+
exchange_trade_volume_24h_btc: json.trade_volume_24h_btc,
|
|
13742
|
+
exchange_number_of_futures_pairs: json.number_of_futures_pairs,
|
|
13743
|
+
exchange_number_of_perpetual_pairs: json.number_of_perpetual_pairs,
|
|
13744
|
+
exchange_open_interest_btc: json.open_interest_btc,
|
|
13745
|
+
};
|
|
13746
|
+
data = json.tickers.slice(0, 200).map(item => {
|
|
13747
|
+
return {
|
|
13748
|
+
...item,
|
|
13749
|
+
...exchangeDetails,
|
|
13750
|
+
usd_volume: item.converted_volume && item.converted_volume.usd,
|
|
13751
|
+
}
|
|
13752
|
+
});
|
|
13738
13753
|
}
|
|
13739
13754
|
}
|
|
13740
13755
|
|
|
@@ -13754,28 +13769,23 @@ async function COINGECKO(category, param1, param2) {
|
|
|
13754
13769
|
}
|
|
13755
13770
|
}
|
|
13756
13771
|
|
|
13757
|
-
async function EOA(
|
|
13758
|
-
) {
|
|
13772
|
+
async function EOA() {
|
|
13759
13773
|
const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Etherscan);
|
|
13760
13774
|
if (!API_KEY) return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.MISSING_KEY}`;
|
|
13761
|
-
|
|
13762
13775
|
let [
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13776
|
+
addresses,
|
|
13777
|
+
category,
|
|
13778
|
+
chains,
|
|
13779
|
+
startTime,
|
|
13780
|
+
endTime,
|
|
13781
|
+
page = 1,
|
|
13782
|
+
offset = 10,
|
|
13770
13783
|
] = argsToArray(arguments);
|
|
13771
|
-
|
|
13772
13784
|
const INPUTS = addresses.split(",").map(a => a.trim()).filter(Boolean);
|
|
13773
13785
|
const CHAINS = chains.split(",").map(c => c.trim()).filter(Boolean);
|
|
13774
13786
|
const out = [];
|
|
13775
|
-
|
|
13776
13787
|
// Map: finalAddress => ENS name (if applicable)
|
|
13777
13788
|
const ADDRESS_MAP = {};
|
|
13778
|
-
|
|
13779
13789
|
for (const input of INPUTS) {
|
|
13780
13790
|
if (isAddress(input)) {
|
|
13781
13791
|
ADDRESS_MAP[input.toLowerCase()] = null; // it's a direct address
|
|
@@ -13788,51 +13798,42 @@ async function EOA(
|
|
|
13788
13798
|
}
|
|
13789
13799
|
}
|
|
13790
13800
|
}
|
|
13791
|
-
|
|
13792
13801
|
const ADDRS = Object.keys(ADDRESS_MAP);
|
|
13793
|
-
|
|
13794
13802
|
for (const chain of CHAINS) {
|
|
13795
13803
|
const chainId = CHAIN_ID_MAP[chain];
|
|
13796
13804
|
if (!chainId) return ERROR_MESSAGES_FLAG.UNSUPPORTED_CHAIN;
|
|
13797
|
-
|
|
13798
13805
|
if (category === "balance") {
|
|
13799
13806
|
for (let i = 0; i < ADDRS.length; i += 20) {
|
|
13800
13807
|
const slice = ADDRS.slice(i, i + 20).join(",");
|
|
13801
|
-
const action =
|
|
13802
|
-
|
|
13808
|
+
const action = 'addresstokenbalance';
|
|
13803
13809
|
const url =
|
|
13804
13810
|
`https://api.etherscan.io/v2/api?chainid=${chainId}` +
|
|
13805
13811
|
`&module=account&action=${action}&address=${slice}` +
|
|
13806
|
-
`&
|
|
13807
|
-
|
|
13812
|
+
`&page=${page}&offset=${offset}&apikey=${API_KEY}`;
|
|
13808
13813
|
const data = await fetchJSON(url);
|
|
13809
13814
|
if (typeof data === "string") return data;
|
|
13810
|
-
|
|
13811
|
-
(Array.isArray(data) ? data : [data]).forEach(r =>
|
|
13815
|
+
data.forEach(tx =>
|
|
13812
13816
|
out.push({
|
|
13813
13817
|
chain,
|
|
13814
|
-
|
|
13815
|
-
name: ADDRESS_MAP[
|
|
13818
|
+
address: ADDRS[i],
|
|
13819
|
+
name: ADDRESS_MAP[ADDRS[i]],
|
|
13820
|
+
...tx,
|
|
13816
13821
|
}),
|
|
13817
13822
|
);
|
|
13818
13823
|
}
|
|
13819
13824
|
continue;
|
|
13820
13825
|
}
|
|
13821
|
-
|
|
13822
13826
|
if (category === "txns") {
|
|
13823
13827
|
const startBlock = await fromTimeStampToBlock(toTimestamp(startTime), chain, API_KEY);
|
|
13824
13828
|
const endBlock = await fromTimeStampToBlock(toTimestamp(endTime), chain, API_KEY);
|
|
13825
|
-
|
|
13826
13829
|
for (const addr of ADDRS) {
|
|
13827
13830
|
const url =
|
|
13828
13831
|
`https://api.etherscan.io/v2/api?chainid=${chainId}` +
|
|
13829
13832
|
`&module=account&action=txlist&address=${addr}` +
|
|
13830
13833
|
`&startblock=${startBlock}&endblock=${endBlock}` +
|
|
13831
13834
|
`&page=${page}&offset=${offset}&sort=asc&apikey=${API_KEY}`;
|
|
13832
|
-
|
|
13833
13835
|
const data = await fetchJSON(url);
|
|
13834
13836
|
if (typeof data === "string") return data;
|
|
13835
|
-
|
|
13836
13837
|
data.forEach(tx =>
|
|
13837
13838
|
out.push({
|
|
13838
13839
|
chain,
|
|
@@ -13844,7 +13845,6 @@ async function EOA(
|
|
|
13844
13845
|
}
|
|
13845
13846
|
continue;
|
|
13846
13847
|
}
|
|
13847
|
-
|
|
13848
13848
|
return ERROR_MESSAGES_FLAG.INVALID_CATEGORY;
|
|
13849
13849
|
}
|
|
13850
13850
|
|
|
@@ -13926,33 +13926,45 @@ async function SAFE() {
|
|
|
13926
13926
|
}
|
|
13927
13927
|
|
|
13928
13928
|
async function DEFILLAMA() {
|
|
13929
|
-
let [category
|
|
13929
|
+
let [category] = argsToArray(arguments);
|
|
13930
13930
|
const apiKey = window.localStorage.getItem(SERVICE_API_KEY.Defillama);
|
|
13931
13931
|
if (!apiKey) return `${SERVICE_API_KEY.Defillama}_MISSING`;
|
|
13932
|
-
const baseUrl = 'https://api.llama.fi/';
|
|
13933
13932
|
const categoryList = ['protocols', 'yields', 'dex'];
|
|
13934
13933
|
const categoryMap = {
|
|
13935
|
-
[categoryList[0]]: 'protocols',
|
|
13936
|
-
[categoryList[1]]: 'pools',
|
|
13937
|
-
[categoryList[2]]: 'overview/dexs?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true'
|
|
13934
|
+
[categoryList[0]]: 'https://api.llama.fi/protocols',
|
|
13935
|
+
[categoryList[1]]: 'https://yields.llama.fi/pools',
|
|
13936
|
+
[categoryList[2]]: 'https://api.llama.fi/overview/dexs?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true'
|
|
13938
13937
|
};
|
|
13939
|
-
let url =
|
|
13940
|
-
|
|
13941
|
-
url += `/${param1}`;
|
|
13942
|
-
}
|
|
13938
|
+
let url = categoryMap[category];
|
|
13939
|
+
|
|
13943
13940
|
try {
|
|
13944
13941
|
const response = await fetch(url);
|
|
13945
13942
|
if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
|
|
13946
13943
|
let json = await response.json();
|
|
13947
|
-
|
|
13948
|
-
|
|
13944
|
+
switch(category){
|
|
13945
|
+
case categoryList[0]: {
|
|
13946
|
+
if(json.length > 500){
|
|
13947
|
+
json = json.slice(0, 500);
|
|
13948
|
+
}
|
|
13949
|
+
break;
|
|
13950
|
+
}
|
|
13951
|
+
case categoryList[1]: {
|
|
13952
|
+
json = json.data.slice(0, 500);
|
|
13953
|
+
break;
|
|
13954
|
+
}
|
|
13955
|
+
case categoryList[2]: {
|
|
13956
|
+
json = json.protocols.slice(0, 500);
|
|
13957
|
+
break;
|
|
13958
|
+
}
|
|
13949
13959
|
}
|
|
13950
|
-
|
|
13960
|
+
|
|
13961
|
+
return removeNestedStructure(Array.isArray(json) ? json : [json]);
|
|
13951
13962
|
} catch (e) {
|
|
13952
13963
|
console.log(e);
|
|
13953
13964
|
return "ERROR IN FETCHING";
|
|
13954
13965
|
}
|
|
13955
13966
|
}
|
|
13967
|
+
|
|
13956
13968
|
function POLYMARKET() {
|
|
13957
13969
|
return "Coming Soon"
|
|
13958
13970
|
}
|
|
@@ -40,7 +40,8 @@ var SERVICE_API_KEY = {
|
|
|
40
40
|
Firefly: "FIRE_FLY_API_KEY",
|
|
41
41
|
GnosisPay: "GNOSIS_API_KEY",
|
|
42
42
|
Neynar: "NEYNAR_API_KEY",
|
|
43
|
-
Defillama: "DEFILLAMA_API_KEY"
|
|
43
|
+
Defillama: "DEFILLAMA_API_KEY",
|
|
44
|
+
Uniswap: "UNISWAP_API_KEY"
|
|
44
45
|
};
|
|
45
46
|
var FUNCTION_LOCALE = [
|
|
46
47
|
{
|
|
@@ -182,8 +183,8 @@ var FUNCTION_LOCALE = [
|
|
|
182
183
|
p: [
|
|
183
184
|
{
|
|
184
185
|
name: "username",
|
|
185
|
-
detail: "The Farcaster
|
|
186
|
-
example: `miroyato`,
|
|
186
|
+
detail: "The Farcaster username whose followers should be fetched.",
|
|
187
|
+
example: `"miroyato"`,
|
|
187
188
|
require: "m",
|
|
188
189
|
type: "number"
|
|
189
190
|
}
|
|
@@ -607,14 +608,14 @@ If "derivatives": exchange name (e.g., "binance_futures").`,
|
|
|
607
608
|
]
|
|
608
609
|
},
|
|
609
610
|
{
|
|
610
|
-
API_KEY: SERVICE_API_KEY.
|
|
611
|
+
API_KEY: SERVICE_API_KEY.Uniswap,
|
|
611
612
|
LOGO: "https://app.uniswap.org/favicon.png",
|
|
612
613
|
BRAND_COLOR: "#fef5fc",
|
|
613
614
|
BRAND_SECONDARY_COLOR: "#f50db4",
|
|
614
615
|
n: "UNISWAP",
|
|
615
616
|
t: 20,
|
|
616
|
-
d: "Returns
|
|
617
|
-
a: "Retrieves
|
|
617
|
+
d: "Returns Uniswap transaction history for the given address",
|
|
618
|
+
a: "Retrieves Uniswap data for a given chain and address from Uniswap",
|
|
618
619
|
p: [
|
|
619
620
|
{
|
|
620
621
|
name: "type",
|
package/lib/esm/index.mjs
CHANGED
|
@@ -13090,7 +13090,8 @@ const SERVICE_API_KEY = {
|
|
|
13090
13090
|
Firefly: "FIRE_FLY_API_KEY",
|
|
13091
13091
|
GnosisPay: 'GNOSIS_API_KEY',
|
|
13092
13092
|
Neynar: 'NEYNAR_API_KEY',
|
|
13093
|
-
Defillama: 'DEFILLAMA_API_KEY'
|
|
13093
|
+
Defillama: 'DEFILLAMA_API_KEY',
|
|
13094
|
+
Uniswap: 'UNISWAP_API_KEY'
|
|
13094
13095
|
};
|
|
13095
13096
|
|
|
13096
13097
|
const fromTimeStampToBlock = async (timestamp, chain, apiKey) => {
|
|
@@ -13214,13 +13215,10 @@ if (scanKey === SERVICE_API_KEY.Gnosisscan) chainId = 'gnosis';
|
|
|
13214
13215
|
}
|
|
13215
13216
|
}
|
|
13216
13217
|
|
|
13217
|
-
const fromUsernameToFid = async (username) => {
|
|
13218
|
+
const fromUsernameToFid = async (username, apiKey) => {
|
|
13218
13219
|
if(!username) return null
|
|
13219
|
-
const url = `https://api.neynar.com/v2/farcaster/user/search
|
|
13220
|
+
const url = `https://api.neynar.com/v2/farcaster/user/search/?q=${username}&limit=5`;
|
|
13220
13221
|
const res = await fetch(url, {
|
|
13221
|
-
query: {
|
|
13222
|
-
q: username
|
|
13223
|
-
},
|
|
13224
13222
|
headers: {
|
|
13225
13223
|
'x-api-key': API_KEY,
|
|
13226
13224
|
'x-neynar-experimental': 'false'
|
|
@@ -13346,7 +13344,7 @@ async function LENS() {
|
|
|
13346
13344
|
flat[key] = value;
|
|
13347
13345
|
}
|
|
13348
13346
|
}
|
|
13349
|
-
flat.platform =
|
|
13347
|
+
flat.platform = 'lens';
|
|
13350
13348
|
return flat;
|
|
13351
13349
|
});
|
|
13352
13350
|
|
|
@@ -13399,7 +13397,7 @@ async function FARCASTER() {
|
|
|
13399
13397
|
flat[key] = value;
|
|
13400
13398
|
}
|
|
13401
13399
|
}
|
|
13402
|
-
flat.platform =
|
|
13400
|
+
flat.platform = "farcaster";
|
|
13403
13401
|
return flat;
|
|
13404
13402
|
});
|
|
13405
13403
|
|
|
@@ -13731,8 +13729,25 @@ async function COINGECKO(category, param1, param2) {
|
|
|
13731
13729
|
if (json.length > 200) {
|
|
13732
13730
|
data = json.slice(0, 200);
|
|
13733
13731
|
}
|
|
13734
|
-
|
|
13735
|
-
|
|
13732
|
+
|
|
13733
|
+
if(param1 !== 'all' && json && json.tickers){
|
|
13734
|
+
const exchangeDetails = {
|
|
13735
|
+
exchange_id: param1,
|
|
13736
|
+
exchange_name: json.name,
|
|
13737
|
+
exchange_logo: json.logo,
|
|
13738
|
+
exchange_url: json.url,
|
|
13739
|
+
exchange_trade_volume_24h_btc: json.trade_volume_24h_btc,
|
|
13740
|
+
exchange_number_of_futures_pairs: json.number_of_futures_pairs,
|
|
13741
|
+
exchange_number_of_perpetual_pairs: json.number_of_perpetual_pairs,
|
|
13742
|
+
exchange_open_interest_btc: json.open_interest_btc,
|
|
13743
|
+
};
|
|
13744
|
+
data = json.tickers.slice(0, 200).map(item => {
|
|
13745
|
+
return {
|
|
13746
|
+
...item,
|
|
13747
|
+
...exchangeDetails,
|
|
13748
|
+
usd_volume: item.converted_volume && item.converted_volume.usd,
|
|
13749
|
+
}
|
|
13750
|
+
});
|
|
13736
13751
|
}
|
|
13737
13752
|
}
|
|
13738
13753
|
|
|
@@ -13752,28 +13767,23 @@ async function COINGECKO(category, param1, param2) {
|
|
|
13752
13767
|
}
|
|
13753
13768
|
}
|
|
13754
13769
|
|
|
13755
|
-
async function EOA(
|
|
13756
|
-
) {
|
|
13770
|
+
async function EOA() {
|
|
13757
13771
|
const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Etherscan);
|
|
13758
13772
|
if (!API_KEY) return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.MISSING_KEY}`;
|
|
13759
|
-
|
|
13760
13773
|
let [
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13774
|
+
addresses,
|
|
13775
|
+
category,
|
|
13776
|
+
chains,
|
|
13777
|
+
startTime,
|
|
13778
|
+
endTime,
|
|
13779
|
+
page = 1,
|
|
13780
|
+
offset = 10,
|
|
13768
13781
|
] = argsToArray(arguments);
|
|
13769
|
-
|
|
13770
13782
|
const INPUTS = addresses.split(",").map(a => a.trim()).filter(Boolean);
|
|
13771
13783
|
const CHAINS = chains.split(",").map(c => c.trim()).filter(Boolean);
|
|
13772
13784
|
const out = [];
|
|
13773
|
-
|
|
13774
13785
|
// Map: finalAddress => ENS name (if applicable)
|
|
13775
13786
|
const ADDRESS_MAP = {};
|
|
13776
|
-
|
|
13777
13787
|
for (const input of INPUTS) {
|
|
13778
13788
|
if (isAddress(input)) {
|
|
13779
13789
|
ADDRESS_MAP[input.toLowerCase()] = null; // it's a direct address
|
|
@@ -13786,51 +13796,42 @@ async function EOA(
|
|
|
13786
13796
|
}
|
|
13787
13797
|
}
|
|
13788
13798
|
}
|
|
13789
|
-
|
|
13790
13799
|
const ADDRS = Object.keys(ADDRESS_MAP);
|
|
13791
|
-
|
|
13792
13800
|
for (const chain of CHAINS) {
|
|
13793
13801
|
const chainId = CHAIN_ID_MAP[chain];
|
|
13794
13802
|
if (!chainId) return ERROR_MESSAGES_FLAG.UNSUPPORTED_CHAIN;
|
|
13795
|
-
|
|
13796
13803
|
if (category === "balance") {
|
|
13797
13804
|
for (let i = 0; i < ADDRS.length; i += 20) {
|
|
13798
13805
|
const slice = ADDRS.slice(i, i + 20).join(",");
|
|
13799
|
-
const action =
|
|
13800
|
-
|
|
13806
|
+
const action = 'addresstokenbalance';
|
|
13801
13807
|
const url =
|
|
13802
13808
|
`https://api.etherscan.io/v2/api?chainid=${chainId}` +
|
|
13803
13809
|
`&module=account&action=${action}&address=${slice}` +
|
|
13804
|
-
`&
|
|
13805
|
-
|
|
13810
|
+
`&page=${page}&offset=${offset}&apikey=${API_KEY}`;
|
|
13806
13811
|
const data = await fetchJSON(url);
|
|
13807
13812
|
if (typeof data === "string") return data;
|
|
13808
|
-
|
|
13809
|
-
(Array.isArray(data) ? data : [data]).forEach(r =>
|
|
13813
|
+
data.forEach(tx =>
|
|
13810
13814
|
out.push({
|
|
13811
13815
|
chain,
|
|
13812
|
-
|
|
13813
|
-
name: ADDRESS_MAP[
|
|
13816
|
+
address: ADDRS[i],
|
|
13817
|
+
name: ADDRESS_MAP[ADDRS[i]],
|
|
13818
|
+
...tx,
|
|
13814
13819
|
}),
|
|
13815
13820
|
);
|
|
13816
13821
|
}
|
|
13817
13822
|
continue;
|
|
13818
13823
|
}
|
|
13819
|
-
|
|
13820
13824
|
if (category === "txns") {
|
|
13821
13825
|
const startBlock = await fromTimeStampToBlock(toTimestamp(startTime), chain, API_KEY);
|
|
13822
13826
|
const endBlock = await fromTimeStampToBlock(toTimestamp(endTime), chain, API_KEY);
|
|
13823
|
-
|
|
13824
13827
|
for (const addr of ADDRS) {
|
|
13825
13828
|
const url =
|
|
13826
13829
|
`https://api.etherscan.io/v2/api?chainid=${chainId}` +
|
|
13827
13830
|
`&module=account&action=txlist&address=${addr}` +
|
|
13828
13831
|
`&startblock=${startBlock}&endblock=${endBlock}` +
|
|
13829
13832
|
`&page=${page}&offset=${offset}&sort=asc&apikey=${API_KEY}`;
|
|
13830
|
-
|
|
13831
13833
|
const data = await fetchJSON(url);
|
|
13832
13834
|
if (typeof data === "string") return data;
|
|
13833
|
-
|
|
13834
13835
|
data.forEach(tx =>
|
|
13835
13836
|
out.push({
|
|
13836
13837
|
chain,
|
|
@@ -13842,7 +13843,6 @@ async function EOA(
|
|
|
13842
13843
|
}
|
|
13843
13844
|
continue;
|
|
13844
13845
|
}
|
|
13845
|
-
|
|
13846
13846
|
return ERROR_MESSAGES_FLAG.INVALID_CATEGORY;
|
|
13847
13847
|
}
|
|
13848
13848
|
|
|
@@ -13924,33 +13924,45 @@ async function SAFE() {
|
|
|
13924
13924
|
}
|
|
13925
13925
|
|
|
13926
13926
|
async function DEFILLAMA() {
|
|
13927
|
-
let [category
|
|
13927
|
+
let [category] = argsToArray(arguments);
|
|
13928
13928
|
const apiKey = window.localStorage.getItem(SERVICE_API_KEY.Defillama);
|
|
13929
13929
|
if (!apiKey) return `${SERVICE_API_KEY.Defillama}_MISSING`;
|
|
13930
|
-
const baseUrl = 'https://api.llama.fi/';
|
|
13931
13930
|
const categoryList = ['protocols', 'yields', 'dex'];
|
|
13932
13931
|
const categoryMap = {
|
|
13933
|
-
[categoryList[0]]: 'protocols',
|
|
13934
|
-
[categoryList[1]]: 'pools',
|
|
13935
|
-
[categoryList[2]]: 'overview/dexs?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true'
|
|
13932
|
+
[categoryList[0]]: 'https://api.llama.fi/protocols',
|
|
13933
|
+
[categoryList[1]]: 'https://yields.llama.fi/pools',
|
|
13934
|
+
[categoryList[2]]: 'https://api.llama.fi/overview/dexs?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true'
|
|
13936
13935
|
};
|
|
13937
|
-
let url =
|
|
13938
|
-
|
|
13939
|
-
url += `/${param1}`;
|
|
13940
|
-
}
|
|
13936
|
+
let url = categoryMap[category];
|
|
13937
|
+
|
|
13941
13938
|
try {
|
|
13942
13939
|
const response = await fetch(url);
|
|
13943
13940
|
if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
|
|
13944
13941
|
let json = await response.json();
|
|
13945
|
-
|
|
13946
|
-
|
|
13942
|
+
switch(category){
|
|
13943
|
+
case categoryList[0]: {
|
|
13944
|
+
if(json.length > 500){
|
|
13945
|
+
json = json.slice(0, 500);
|
|
13946
|
+
}
|
|
13947
|
+
break;
|
|
13948
|
+
}
|
|
13949
|
+
case categoryList[1]: {
|
|
13950
|
+
json = json.data.slice(0, 500);
|
|
13951
|
+
break;
|
|
13952
|
+
}
|
|
13953
|
+
case categoryList[2]: {
|
|
13954
|
+
json = json.protocols.slice(0, 500);
|
|
13955
|
+
break;
|
|
13956
|
+
}
|
|
13947
13957
|
}
|
|
13948
|
-
|
|
13958
|
+
|
|
13959
|
+
return removeNestedStructure(Array.isArray(json) ? json : [json]);
|
|
13949
13960
|
} catch (e) {
|
|
13950
13961
|
console.log(e);
|
|
13951
13962
|
return "ERROR IN FETCHING";
|
|
13952
13963
|
}
|
|
13953
13964
|
}
|
|
13965
|
+
|
|
13954
13966
|
function POLYMARKET() {
|
|
13955
13967
|
return "Coming Soon"
|
|
13956
13968
|
}
|