Skip to content

Commit

Permalink
feat: add dappos-intentEx volumes and fees
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiangyj19 committed Jan 6, 2025
1 parent 78521bb commit 179ee89
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
35 changes: 35 additions & 0 deletions dexs/dappos-intentEx/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { SimpleAdapter } from "../../adapters/types";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";
import { httpGet } from "../../utils/fetchURL";
import { CHAIN } from "../../helpers/chains";

const URL = "https://trade-info.dappos.com/market/archive?timestamp=";

interface Response {
daily_trade_volume: string;
}

const fetch = async (timestamp: number) => {
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000));
const url = `${URL}${dayTimestamp}`
const respose: Response[] = await httpGet(url);
const dailyVolume = respose.reduce((acc, item) => {
return acc + Number(item.daily_trade_volume);
}, 0);

return {
dailyVolume: dailyVolume?.toString(),
timestamp: dayTimestamp,
};
};

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.OP_BNB]: {
fetch,
start: '2025-01-01',
},
}
};

export default adapter;
41 changes: 41 additions & 0 deletions fees/dappos-intentEx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { CHAIN } from "../helpers/chains"
import { Adapter, FetchOptions, } from '../adapters/types';
import { httpGet } from "../utils/fetchURL";
import { getUniqStartOfTodayTimestamp } from "../helpers/getUniSubgraphVolume";

const URL = "https://trade-info.dappos.com/market/archive?timestamp=";

interface Response {
daily_trade_fee: string;
total_trade_fee: string;
}

const fetchFees = async (options: FetchOptions) => {
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(options.endTimestamp * 1000));
const url = `${URL}${dayTimestamp}`
const respose: Response[] = await httpGet(url);
const dailyFees = respose.reduce((acc, item) => {
return acc + Number(item.daily_trade_fee);
}, 0);
const totalFees = respose.reduce((acc, item) => {
return acc + Number(item.total_trade_fee);
}, 0);

return {
dailyFees,
dailyRevenue: dailyFees,
totalFees,
totalRevenue: totalFees,
}
}

const adapter: Adapter = {
version: 2,
adapter: {
[CHAIN.OP_BNB]: {
fetch: fetchFees,
start: '2025-01-01',
},
},
}
export default adapter

0 comments on commit 179ee89

Please sign in to comment.