-
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
Open
dry-cake
wants to merge
5
commits into
DefiLlama:master
Choose a base branch
from
dry-cake:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,64 @@ | ||
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; | ||
protocol_fees: number; | ||
lp_fees: number; | ||
external_rewards: number; | ||
timestamp_date_from: number; | ||
timestamp_date_to: number; | ||
} | ||
|
||
const fetch = async (timestamp: number) => { | ||
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) | ||
const historicalVolume: IVolumeAll[] = (await fetchURL(AQUA_VOLUME_ENDPOINT)); | ||
const fetch = async ({ fromTimestamp, toTimestamp }: 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, | ||
}; | ||
// Seems like we have here gap about 3.5 hours in to-timestamps, can u maybe explain that diff? | ||
// Finding day period from our api, that matches llama toTimestamp (current time) | ||
const day = historicalVolume | ||
.find(i => toTimestamp >= i.timestamp_date_from && toTimestamp <= i.timestamp_date_to); | ||
|
||
if (!day) { | ||
throw new Error('No data for timestamp: ' + fromTimestamp); | ||
} | ||
|
||
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, | ||
dailyUserFees: ProtocolFees + LPFees, | ||
dailySupplySideRevenue: LPFees, | ||
dailyRevenue: ProtocolFees, | ||
dailyHoldersRevenue: ProtocolFees, | ||
dailyBribesRevenue: ExternalRewards, | ||
dailyProtocolRevenue: 0, | ||
} | ||
}; | ||
|
||
const methodology = { | ||
dailyFees: "All fees including 100% of the swap fees and external rewards for AQUA holders.", | ||
dailyUserFees: "100% of the swap fees", | ||
dailyRevenue: "50% of the swap fees that are received by the protocol and then distributed between AQUA holders that voted for the markets where these fees have been collected", | ||
dailyProtocolRevenue: "Share of the fees kept by Aquarius. Currently equals 0.", | ||
dailyHoldersRevenue: "50% of the swap fees that are received by the protocol and then distributed between AQUA holders that voted for the markets where these fees have been collected.", | ||
dailySupplySideRevenue: "50% of the swap fees that are shared with the Aquarius liquidity providers", | ||
dailyBribesRevenue: "Amount of external incentives for AQUA holders voting for specific markets on Aquarius.", | ||
} | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.STELLAR]: { | ||
fetch, | ||
start: '2024-07-01', | ||
}, | ||
}, | ||
version: 2, | ||
methodology, | ||
adapter: { | ||
[CHAIN.STELLAR]: { fetch, start: '2024-07-01' }, | ||
}, | ||
}; | ||
|
||
export default adapter; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)