Skip to content

Commit 1e1be03

Browse files
track stellar chain fees (#4887)
* track stellar chain fees * fix revenue * refactor --------- Co-authored-by: treeoflife2 <sol.analyzoor@gmail.com>
1 parent c6a5d3b commit 1e1be03

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

fees/stellar/index.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Dependencies, FetchOptions, ProtocolType, SimpleAdapter } from "../../adapters/types";
2+
import { queryDuneSql } from "../../helpers/dune";
3+
import { CHAIN } from "../../helpers/chains";
4+
5+
async function fetch(_a: any, _b: any, options: FetchOptions) {
6+
const dailyFees = options.createBalances();
7+
8+
const query = `
9+
select
10+
sum(fee_charged/1e7) as stellar_txn_fee
11+
from stellar.history_transactions
12+
where closed_at_date=Date('${options.dateString}')
13+
`;
14+
15+
const queryResults: { stellar_txn_fee: string }[] = await queryDuneSql(options, query);
16+
17+
if (!queryResults[0] || !queryResults[0].stellar_txn_fee)
18+
throw new Error(`Stellar txn fee not found`);
19+
20+
dailyFees.addCGToken("stellar", queryResults[0].stellar_txn_fee);
21+
22+
return {
23+
dailyFees,
24+
dailyRevenue: dailyFees,
25+
dailyProtocolRevenue: dailyFees
26+
}
27+
}
28+
29+
const methodology = {
30+
Fees: "Transaction fee paid by users",
31+
Revenue: "All the fee goes to fee pool",
32+
ProtocolRevenue: "All the fee goes to fee pool",
33+
};
34+
35+
const adapter: SimpleAdapter = {
36+
fetch,
37+
start: "2015-09-30",
38+
chains: [CHAIN.STELLAR],
39+
protocolType: ProtocolType.CHAIN,
40+
isExpensiveAdapter: true,
41+
dependencies: [Dependencies.DUNE],
42+
methodology,
43+
};
44+
45+
export default adapter;

0 commit comments

Comments
 (0)