Skip to content

Commit 0c373bd

Browse files
authored
feat: add query router fees to Space and Time fee adapter (#5648)
1 parent c6d3429 commit 0c373bd

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

fees/space-and-time.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ const getPayPortalFees = async (startTimestamp: number, endTimestamp: number) =>
2323
return Number(logs.reduce((sum, log) => sum + BigInt(log.args.fee), 0n));
2424
};
2525

26+
const getQueryRouterFees = async (startTimestamp: number, endTimestamp: number, chain: any) => {
27+
const fromBlock = await getBlock(startTimestamp, chain)
28+
const toBlock = await getBlock(endTimestamp, chain)
29+
const logs = await sdk.getEventLogs({
30+
chain: chain,
31+
fromBlock: fromBlock,
32+
toBlock: toBlock,
33+
target: "0x220a7036a815a1Bd4A7998fb2BCE608581fA2DbB",
34+
eventAbi:"event PayoutOccurred(bytes32 indexed queryId, address indexed fulfiller, address indexed refundRecipient, uint256 fulfillerAmount, uint256 refundAmount)",
35+
});
36+
return Number(logs.reduce((sum, log) => sum + BigInt(log.args.fulfillerAmount), 0n));
37+
};
38+
2639
const fetch = async (_a: any, _b: any, options: FetchOptions) => {
2740
const dailyFees = options.createBalances();
2841
const dailyRevenue = options.createBalances();
@@ -31,10 +44,16 @@ const fetch = async (_a: any, _b: any, options: FetchOptions) => {
3144
const gasBurned = await getGasBurned(options.startTimestamp, options.endTimestamp);
3245

3346
// PayPortal transfer fees on Base
34-
const payPortalFees = await getPayPortalFees(options.startTimestamp, options.endTimestamp);
47+
const payPortalFees = await getPayPortalFees(options.startTimestamp, options.endTimestamp);
48+
49+
// QueryRouter fees
50+
const queryRouterFeesEthereum = await getQueryRouterFees(options.startTimestamp, options.endTimestamp, CHAIN.ETHEREUM);
51+
const queryRouterFeesBase = await getQueryRouterFees(options.startTimestamp, options.endTimestamp, CHAIN.BASE);
3552

3653
dailyFees.addCGToken('space-and-time', Number(gasBurned) / 1e18);
3754
dailyFees.addCGToken('space-and-time', Number(payPortalFees) / 1e18);
55+
dailyFees.addCGToken('space-and-time', Number(queryRouterFeesEthereum) / 1e18);
56+
dailyFees.addCGToken('space-and-time', Number(queryRouterFeesBase) / 1e18);
3857
dailyRevenue.addCGToken('space-and-time', Number(payPortalFees) / 1e18);
3958

4059
return { dailyFees, dailyRevenue, dailyProtocolRevenue: dailyRevenue };

0 commit comments

Comments
 (0)