Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions dexs/aqua-network/index.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dry-cake thanks for the PR but I have reverted it back to use version 1 because, the api returns daily data not for a arbitrary time range (per-requsite for v2 adapters)

Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
import fetchURL from "../../utils/fetchURL"
import { SimpleAdapter } from "../../adapters/types";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";

const AQUA_VOLUME_ENDPOINT = "https://amm-api.aqua.network/api/external/v1/statistics/totals/?size=all"

interface IVolumeAll {
volume: number;
tvl: number;
date: string;
volume: number;
tvl: number;
date: string;
protocol_fees: number;
lp_fees: number;
external_rewards: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this field and why is counted as fees?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, whats the difference between protocol fees & lp fees? do the LPs get aqua rewards on top of the swap fees or instead of the swap fees?

Also, can you please add the "methodology" field 🙏

Copy link
Contributor Author

@dry-cake dry-cake Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we can add timestamps range from - to for each day, it's only restriction from moving to v2?
It should be unixtime timestamp, right?

Copy link
Contributor Author

@dry-cake dry-cake Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@g1nt0ki ^ 👀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, unix timestamp in seconds.

}

const fetch = async (timestamp: number) => {
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000))
const historicalVolume: IVolumeAll[] = (await fetchURL(AQUA_VOLUME_ENDPOINT));
const fetch = async (_: any, _1: any, { dateString, }: FetchOptions) => {
const historicalVolume: IVolumeAll[] = (await fetchURL(AQUA_VOLUME_ENDPOINT));

const dailyVolume = historicalVolume
.find(dayItem => (new Date(dayItem.date).getTime() / 1000) === dayTimestamp)?.volume

return {
dailyVolume: dailyVolume ? `${Number(dailyVolume) / 1e7}` : undefined,
};
const day = historicalVolume
.find(i => i.date === dateString)
if (!day) throw new Error('No data for timestamp: ' + dateString);

const ProtocolFees = day.protocol_fees / 1e7
const LPFees = day.lp_fees / 1e7
const ExternalRewards = day.external_rewards / 1e7

return {
dailyVolume: day.volume / 1e7,
dailyFees: ProtocolFees + LPFees + ExternalRewards,
dailySupplySideRevenue: LPFees,
dailyRevenue: LPFees + ExternalRewards,
dailyHoldersRevenue: LPFees + ExternalRewards,
dailyProtocolRevenue: 0,
}
};

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.STELLAR]: {
fetch,
start: '2024-07-01',
},
},
adapter: {
[CHAIN.STELLAR]: { fetch, start: '2024-07-01' },
},
};

export default adapter;
Loading