Skip to content

Commit

Permalink
fix param
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Oct 23, 2024
1 parent 74843dd commit c3bd2b5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
22 changes: 19 additions & 3 deletions dexs/gains-network/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,28 @@ interface IStats {
daily_volume: number;
}

const requests: any = {}


export async function fetchURLWithRetry(url: string, options: FetchOptions) {
const start = options.startTimestamp;
const end = options.endTimestamp;
const key = `${url}-${start}`;
if (!requests[key])
requests[key] = queryDune("4192496", {
start: start,
end: end,
})
return requests[key]
}

const fetch: any = async (
timestamp: number,
_: ChainBlocks,
{ chain, startOfDay, toTimestamp }: FetchOptions
options: FetchOptions
): Promise<FetchResultVolume> => {
const stats: IStats[] = await queryDune("4192496", { start: startOfDay, end: toTimestamp });
const chainStat = stats.find((stat) => stat.unix_ts === startOfDay && stat.blockchain === chain);
const stats: IStats[] = await fetchURLWithRetry("4192496", options);
const chainStat = stats.find((stat) => stat.unix_ts === options.startOfDay && stat.blockchain === options.chain);

return { timestamp, dailyVolume: chainStat?.daily_volume || 0 };
};
Expand All @@ -26,6 +41,7 @@ const adapter: SimpleAdapter = {
[CHAIN.POLYGON]: { fetch, start: 1684972800 },
[CHAIN.BASE]: { fetch, start: 1727351131 },
},
isExpensiveAdapter: true,
};

export default adapter;
20 changes: 17 additions & 3 deletions fees/gains-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,23 @@ interface IStats {
// GNS staking
gns_stakers: number;
}
const requests: any = {}

const fetch = async (timestamp: number, _: ChainBlocks, { chain, startOfDay, toTimestamp }: FetchOptions): Promise<FetchResultFees> => {
const stats: IStats[] = await queryDune("4192496", { start: startOfDay, end: toTimestamp });
const chainStat = stats.find((stat) => stat.unix_ts === startOfDay && stat.blockchain === chain);
export async function fetchURLWithRetry(url: string, options: FetchOptions) {
const start = options.startTimestamp;
const end = options.endTimestamp;
const key = `${url}-${start}`;
if (!requests[key])
requests[key] = queryDune("4192496", {
start: start,
end: end,
})
return requests[key]
}

const fetch = async (timestamp: number, _: ChainBlocks, options: FetchOptions): Promise<FetchResultFees> => {
const stats: IStats[] = await fetchURLWithRetry("4192496", options);
const chainStat = stats.find((stat) => stat.unix_ts === options.startOfDay && stat.blockchain === options.chain);
const [dailyFees, dailyRevenue, dailyHoldersRevenue, dailySupplySideRevenue, totalFees] = chainStat
? [
chainStat.all_fees,
Expand Down Expand Up @@ -64,6 +77,7 @@ const adapter: Adapter = {
start: 1727351131,
},
},
isExpensiveAdapter: true,
};

export default adapter;

0 comments on commit c3bd2b5

Please sign in to comment.