Skip to content

use new api for aden for perp-volume #4014

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

Merged
merged 1 commit into from
Aug 14, 2025
Merged
Changes from all 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
64 changes: 26 additions & 38 deletions dexs/aden/index.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,42 @@
import { FetchResultVolume, SimpleAdapter } from "../../adapters/types";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { httpGet } from "../../utils/fetchURL";
import { CHAIN } from "../../helpers/chains";

interface FuturesMarketRow {
symbol: string;
"24h_amount": string;
"24h_volume": number;
interface DailyStats {
date: string;
dateString: string;
createdAt: string;
updatedAt: string;
builderFee: string;
takerVolume: string;
makerVolume: string;
activeUser: number;
}

interface FuturesMarketResponse {
success: boolean;
data: {
rows: FuturesMarketRow[];
};
}

const fetch = async (): Promise<FetchResultVolume> => {
// Using ADEN's CMC API endpoint with broker_id parameter
const response: FuturesMarketResponse = await httpGet(
"https://api.orderly.org/v1/public/futures_market?broker_id=aden"
const fetch = async (_t: number, _: any, { startOfDay }: FetchOptions) => {
const dailyStats: DailyStats[] = await httpGet(
"https://api.orderly.org/md/volume/builder/daily_stats?broker_id=aden"
);

if (!response.success || !response.data?.rows) {
throw new Error("Invalid response from ADEN API");
const targetDate = new Date(startOfDay * 1000).toISOString().split("T")[0];
const dayStats = dailyStats.find((day) =>
day.date.startsWith(targetDate)
);
if (!dayStats) {
throw new Error(`No stats found for date: ${targetDate}`);
}

// Calculate total 24h volume using 24h_amount (USD value)
// Divide by 2 to avoid double counting when both maker and taker use ADEN
const totalVolume = response.data.rows.reduce((total, row) => {
return total + parseFloat(row["24h_amount"] || "0");
}, 0);

const dailyVolume = totalVolume / 2;
const dailyVolume = parseFloat(dayStats.takerVolume || "0");

return {
dailyVolume,
};
return { dailyVolume };
};

const adapter: SimpleAdapter = {
adapter: {
// ADEN operates on Solana, Arbitrum, and BNB Chain through Orderly Network
// Using Arbitrum as the main chain since the API aggregates all chains data
[CHAIN.ARBITRUM]: {
fetch,
runAtCurrTime: true,
start: '2025-07-23', // ADEN launch date
},
},
doublecounted: true,
fetch,
// ADEN operates on Solana, Arbitrum, and BNB Chain through Orderly Network
// Using BNB Chain as the main chain since the API aggregates all chains data
chains: [CHAIN.BSC],
start: '2025-07-23',
};

export default adapter;
Loading