Skip to content

Commit be0b8aa

Browse files
treeoflife2sehrensinghsehrenCerwyn-UCT
authored
Tapp exchange Dex/Fee Adapter (DefiLlama#3546)
* feat: add fee, volume and revenue for tapp exchange * feat: change the dimension logic using our defillama dimension api * add methodology for fees, volume, and revenue * tapp exchange volume/revenue adapter --------- Co-authored-by: sehren <sehren.singh@youtap.id> Co-authored-by: sehren <sehrenjit@undercurrent.tech> Co-authored-by: cerwyn <cerwyn@undercurrent.tech> Co-authored-by: Cerwyn <96032711+Cerwyn-UCT@users.noreply.github.com>
1 parent 927d433 commit be0b8aa

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

dexs/tapp-exchange/index.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { SimpleAdapter } from "../../adapters/types";
2+
import { CHAIN } from "../../helpers/chains";
3+
import { postURL } from "../../utils/fetchURL";
4+
import { randomInt } from "node:crypto";
5+
import { getTimestampAtStartOfDayUTC } from "../../utils/date";
6+
7+
const URL = 'https://api.tapp.exchange/api/v1'
8+
9+
10+
interface TappDefillamaDimension {
11+
dailyVolume: number;
12+
dailyFee: number;
13+
dailyRevenue: number;
14+
}
15+
16+
const getDefillamaDimension = async (start: number, end: number) => {
17+
const body = {
18+
"method": "public/defillama_dimension",
19+
"jsonrpc": "2.0",
20+
"id": randomInt(1, 1000),
21+
"params": {
22+
"startTime": start,
23+
"endTime": end,
24+
}
25+
}
26+
const dimension: { result: TappDefillamaDimension } = await postURL(URL, body)
27+
return dimension.result;
28+
}
29+
30+
const fetch = async (timestamp: number) => {
31+
const startOfDay = getTimestampAtStartOfDayUTC(timestamp) * 1000;
32+
const endOfDay = startOfDay + 24 * 60 * 60 * 1000 - 1000;
33+
34+
const {
35+
dailyFee,
36+
dailyVolume,
37+
dailyRevenue
38+
} = await getDefillamaDimension(startOfDay, endOfDay);
39+
const dailySupplySideRevenue = Number(dailyFee || 0) - Number(dailyRevenue || 0);
40+
41+
return {
42+
dailyVolume,
43+
dailyFees: dailyFee,
44+
dailyRevenue,
45+
dailyProtocolRevenue: dailyRevenue,
46+
dailySupplySideRevenue
47+
};
48+
}
49+
50+
const adapter: SimpleAdapter = {
51+
version: 1,
52+
adapter: {
53+
[CHAIN.APTOS]: {
54+
fetch,
55+
start: "2025-06-12",
56+
meta: {
57+
methodology: {
58+
Fees: "Total fees from swaps, based on the fee tier of each pool.",
59+
Revenue: "Calculated as 33% of the total fees.",
60+
ProtocolRevenue: "33% of the total fees going to the protocol.",
61+
SupplySideRevenue: "67% of the total fees going to the liquidity providers."
62+
}
63+
}
64+
},
65+
},
66+
};
67+
68+
export default adapter;

fees/tapp-exchange.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import adapter from "../dexs/tapp-exchange";
2+
3+
export default adapter;

0 commit comments

Comments
 (0)