Skip to content

Commit b5d3c08

Browse files
authored
Update unicornx.ts
add usd1 fee
1 parent ba3a23b commit b5d3c08

File tree

1 file changed

+47
-27
lines changed

1 file changed

+47
-27
lines changed

fees/unicornx.ts

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import ADDRESSES from "../helpers/coreAssets.json";
2+
23
import { FetchOptions, SimpleAdapter } from "../adapters/types";
34
import { CHAIN } from "../helpers/chains";
45
import { queryDuneSql } from "../helpers/dune";
56
import { evmReceivedGasAndTokens } from "../helpers/token";
67

7-
88
const fetch: any = async (_a: any, _b: any, options: FetchOptions) => {
99
const dailyFees = options.createBalances();
1010

1111
const query = `
12-
WITH allFeePayments AS (
12+
WITH
13+
allFeePayments AS (
1314
SELECT
1415
tx_id,
1516
balance_change AS fee_token_amount
@@ -20,46 +21,65 @@ const fetch: any = async (_a: any, _b: any, options: FetchOptions) => {
2021
AND address = '9mAZ2HFYfUW9r1rYpM1cAsQTWS7SUp49AW1VzoLaPNgr'
2122
AND tx_success
2223
AND balance_change > 0
23-
)
24-
SELECT
25-
SUM(fee_token_amount) AS fee
26-
FROM
27-
dex_solana.trades AS trades
28-
JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id
29-
WHERE
30-
trades.trader_id != '9mAZ2HFYfUW9r1rYpM1cAsQTWS7SUp49AW1VzoLaPNgr'
31-
AND TIME_RANGE
24+
)
25+
SELECT
26+
SUM(fee_token_amount) AS fee
27+
FROM
28+
dex_solana.trades AS trades
29+
JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id
30+
WHERE
31+
trades.trader_id != '9mAZ2HFYfUW9r1rYpM1cAsQTWS7SUp49AW1VzoLaPNgr'
32+
AND TIME_RANGE
3233
`;
3334

3435
const fees = await queryDuneSql(options, query);
3536
dailyFees.add(ADDRESSES.solana.SOL, fees[0].fee);
3637

37-
return { dailyFees, dailyRevenue: dailyFees, dailyProtocolRevenue: dailyFees };
38+
return { dailyFees, dailyRevenue: dailyFees };
3839
};
3940

40-
const fetchEvm = async (_a:any, _b:any, options: FetchOptions) => {
41-
const { dailyFees } = await evmReceivedGasAndTokens("0xCb077A7f06D54c582eD82f5C5ef9FeFB9B8Be449", [])(options);
42-
return { dailyFees, dailyRevenue: dailyFees, dailyProtocolRevenue: dailyFees };
43-
}
44-
45-
const methodology = {
46-
Fees: "All trading fees paid by users while using UnicornX app and website.",
47-
Revenue: "Trading fees are collected by UnicornX.",
48-
ProtocolRevenue: "Trading fees are collected by UnicornX.",
49-
}
50-
5141
const adapter: SimpleAdapter = {
5242
version: 1,
5343
adapter: {
5444
[CHAIN.SOLANA]: {
55-
fetch,
45+
fetch: fetch,
5646
start: "2025-01-22",
57-
meta: { methodology },
47+
meta: {
48+
methodology: {
49+
Fees: "All trading fees paid by users while using UnicornX app and website.",
50+
Revenue: "Trading fees are collected by UnicornX.",
51+
},
52+
},
5853
},
5954
[CHAIN.BSC]: {
60-
fetch: fetchEvm,
55+
fetch: async (_: any, _1: any, options: FetchOptions) => {
56+
const dailyFees = options.createBalances();
57+
const dailyRevenue = options.createBalances();
58+
const USD1 = "0x8d0D000Ee44948FC98c9B98A4FA4921476f08B0d";
59+
const { dailyFees: bnbFees, dailyRevenue: bnbRevenue } =
60+
await evmReceivedGasAndTokens(
61+
"0xCb077A7f06D54c582eD82f5C5ef9FeFB9B8Be449",
62+
[]
63+
)(options);
64+
dailyFees.addBalances(bnbFees);
65+
dailyRevenue.addBalances(bnbRevenue);
66+
67+
const { dailyFees: usd1Fees, dailyRevenue: usd1Revenue } =
68+
await evmReceivedGasAndTokens(
69+
"0x7e618674021EF084cA2154069798Fe16727849cC",
70+
[USD1]
71+
)(options);
72+
dailyFees.addBalances(usd1Fees);
73+
dailyRevenue.addBalances(usd1Revenue);
74+
return { dailyFees, dailyRevenue };
75+
},
6176
start: "2025-03-30",
62-
meta: { methodology },
77+
meta: {
78+
methodology: {
79+
Fees: "All trading fees paid by users while using UnicornX app and website.",
80+
Revenue: "Trading fees are collected by UnicornX.",
81+
},
82+
},
6383
},
6484
},
6585
isExpensiveAdapter: true,

0 commit comments

Comments
 (0)