Skip to content

Commit 2056d37

Browse files
committed
revert back to using api
1 parent 348f494 commit 2056d37

File tree

1 file changed

+7
-99
lines changed

1 file changed

+7
-99
lines changed

dexs/1dex/index.ts

+7-99
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,18 @@
1-
import { SimpleAdapter } from "../../adapters/types";
2-
import { CHAIN } from "../../helpers/chains";
3-
import { httpGet } from "../../utils/fetchURL";
4-
5-
const endpoint = "https://eos.hyperion.eosrio.io/v2";
6-
7-
interface ActionData {
8-
account_action_seq: number;
9-
act: {
10-
name: string;
11-
data: {
12-
quantity?: string;
13-
contract?: string;
14-
ev?: {
15-
price: number;
16-
base_quantity: string;
17-
quote_quantity: string;
18-
time: string;
19-
[key: string]: any;
20-
};
21-
[key: string]: any;
22-
};
23-
};
24-
block_time: string;
25-
[key: string]: any;
26-
}
27-
28-
interface HyperionResponse {
29-
actions: ActionData[];
30-
total: number;
31-
}
32-
async function getContractActions(
33-
contract: string,
34-
actionNames: string | string[],
35-
startDate: string,
36-
endDate: string
37-
): Promise<ActionData[]> {
38-
const allActions: ActionData[] = [];
39-
let skip = 0;
40-
const limit = 100;
41-
let hasMore = true;
42-
43-
const actionNameParam = Array.isArray(actionNames)
44-
? actionNames.map((action) => `${contract}:${action}`).join(",")
45-
: `${contract}:${actionNames}`;
46-
47-
while (hasMore) {
48-
const url = `${endpoint}/history/get_actions?account=${contract}&limit=${limit}&skip=${skip}&after=${startDate}&before=${endDate}&filter=${actionNameParam}`;
49-
const response: HyperionResponse = await httpGet(url);
50-
51-
const actions = response.actions || [];
52-
if (actions.length === 0) break;
53-
54-
allActions.push(...actions);
55-
56-
skip += limit;
57-
hasMore = actions.length === limit;
58-
}
59-
60-
return allActions;
61-
}
62-
63-
function parseQuantity(quantityStr: string): number {
64-
const [amount] = quantityStr.split(" ");
65-
return parseFloat(amount);
66-
}
67-
68-
function formatDate(date: Date): string {
69-
return date.toISOString();
70-
}
1+
import { CHAIN } from "../../helpers/chains"
2+
import { httpGet } from "../../utils/fetchURL"
713

724
async function fetch() {
73-
const now = new Date();
74-
const oneDayAgo = new Date(now);
75-
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
76-
77-
const startDate = formatDate(oneDayAgo);
78-
const endDate = formatDate(now);
79-
80-
const actions = await getContractActions(
81-
"event.velox",
82-
"emitfilled",
83-
startDate,
84-
endDate
85-
);
86-
87-
let dailyVolume = 0;
88-
89-
actions.forEach((action) => {
90-
const eventData = action.act.data.ev;
91-
if (!eventData) return;
92-
93-
const quoteAmount = parseQuantity(eventData.quote_quantity);
94-
dailyVolume += quoteAmount;
95-
});
96-
97-
return { dailyVolume };
5+
const endpoint = `https://api.1dex.com/24h-trade-info`
6+
const { data: { volume_usdt: dailyVolume } } = await httpGet(endpoint)
7+
return { dailyVolume, }
988
}
999

100-
const adapter: SimpleAdapter = {
10+
export default {
10111
adapter: {
10212
[CHAIN.EOS]: {
10313
fetch,
10414
start: "2025-04-15",
10515
runAtCurrTime: true,
10616
},
10717
},
108-
};
109-
110-
export default adapter;
18+
}

0 commit comments

Comments
 (0)