-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add: Aqua-network new data, move adapter to v2 #4122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this field and why is counted as fees? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 🙏 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @g1nt0ki ^ 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; |
There was a problem hiding this comment.
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)