Skip to content

Commit 2c947f0

Browse files
authored
track doublezero fees/revenue (#4572)
1 parent 39afb32 commit 2c947f0

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

fees/doublezero/index.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Source: https://dune.com/queries/5920586/9559880
2+
// https://docs.malbeclabs.com/paying-fees/
3+
4+
import ADDRESSES from '../../helpers/coreAssets.json'
5+
import { Dependencies, FetchOptions, SimpleAdapter } from "../../adapters/types";
6+
import { CHAIN } from "../../helpers/chains";
7+
import { queryDuneSql } from "../../helpers/dune";
8+
9+
const fetch: any = async (_a: any, _b: any, options: FetchOptions) => {
10+
const dailyFees = options.createBalances();
11+
12+
const query = `
13+
with initialize_deposit_account as (
14+
select
15+
account_arguments[1] as deposit_account
16+
from solana.instruction_calls
17+
left join dune.the_flyingfish_glide.result_validators_app_details
18+
on account_arguments[2] = validator_account
19+
where executing_account = 'dzrevZC94tBLwuHw1dyynZxaXTWyp7yocsinyEVPtt4'
20+
and bytearray_substring(data, 1, 8) = 0x09af49b1ebce3065
21+
and block_date >= date '2025-10-02'
22+
and tx_success
23+
)
24+
select
25+
sum(bytearray_to_bigint(bytearray_reverse(bytearray_substring(data,1+8,8))) / 1e9) as fee
26+
from solana.instruction_calls
27+
left join initialize_deposit_account
28+
on deposit_account = account_arguments[3]
29+
where executing_account = 'dzrevZC94tBLwuHw1dyynZxaXTWyp7yocsinyEVPtt4'
30+
and bytearray_substring(data, 1, 8) = 0xf1858bc4f612713b
31+
and tx_success
32+
and TIME_RANGE
33+
`;
34+
35+
const fees = await queryDuneSql(options, query);
36+
37+
dailyFees.add(ADDRESSES.solana.SOL, fees[0].fee * 1e9);
38+
39+
return {
40+
dailyFees,
41+
dailyRevenue: dailyFees,
42+
dailyProtocolRevenue: dailyFees,
43+
}
44+
}
45+
46+
const adapter: SimpleAdapter = {
47+
version: 1,
48+
fetch,
49+
chains: [CHAIN.SOLANA],
50+
start: '2025-10-03',
51+
dependencies: [Dependencies.DUNE],
52+
isExpensiveAdapter: true,
53+
methodology: {
54+
Fees: "A flat 5% fee is charged on block signature rewards and priority fees. Fees started at epoch 859 (October 4th, 2025) and are denominated in SOL and settled per epoch.",
55+
Revenue: "5% block reward fees and priority fees are collected by the protocol from validators.",
56+
ProtocolRevenue: "5% block reward fees and priority fees are collected by the protocol from validators."
57+
}
58+
};
59+
60+
export default adapter;

0 commit comments

Comments
 (0)