Skip to content

Commit

Permalink
Update to include dailyRevenue (#2124)
Browse files Browse the repository at this point in the history
  • Loading branch information
DJHellscream authored Nov 24, 2024
1 parent fb4b8d2 commit cde242b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fees/apexdefi/burst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ const burstFactoryFee = BigInt(75); // 0.75%

export async function burstMetrics(options: FetchOptions): Promise<{
dailyFees: Balances;
dailyRevenue: Balances;
dailyProtocolRevenue: Balances;
dailyVolume: Balances;
}> {
const { createBalances } = options;

let dailyFees = createBalances();
let dailyRevenue = createBalances();
let dailyProtocolRevenue = createBalances();
let dailyVolume = createBalances();

Expand All @@ -60,6 +62,7 @@ export async function burstMetrics(options: FetchOptions): Promise<{
const creatorRewardsAmount = BigInt(log.creatorRewards);
const totalFee = launchFeeAmount + creatorRewardsAmount;
dailyFees.addGasToken(totalFee);
dailyRevenue.addGasToken(launchFeeAmount);
dailyProtocolRevenue.addGasToken(launchFeeAmount);
});

Expand All @@ -68,13 +71,15 @@ export async function burstMetrics(options: FetchOptions): Promise<{
const fee = (nativeAmount * burstSwapFee) / scaleFactor;
const protocolRevenue = (nativeAmount * burstFactoryFee) / scaleFactor;
dailyFees.addGasToken(fee + protocolRevenue);
dailyRevenue.addGasToken(protocolRevenue);
dailyProtocolRevenue.addGasToken(protocolRevenue);
dailyVolume.addGasToken(nativeAmount);
});

return {
dailyFees: dailyFees,
dailyProtocolRevenue: dailyProtocolRevenue,
dailyVolume: dailyVolume,
dailyFees,
dailyRevenue,
dailyProtocolRevenue,
dailyVolume,
};
}
4 changes: 4 additions & 0 deletions fees/apexdefi/dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const lpFee = BigInt(20); // 0.2%

export async function swapMetrics(options: FetchOptions): Promise<{
dailyFees: Balances;
dailyRevenue: Balances;
dailySupplySideRevenue: Balances;
dailyProtocolRevenue: Balances;
dailyVolume: Balances;
Expand All @@ -41,6 +42,7 @@ export async function swapMetrics(options: FetchOptions): Promise<{
const dailySupplySideRevenue = createBalances();
const dailyProtocolRevenue = createBalances();
const dailyVolume = createBalances();
const dailyRevenue = createBalances();

const allTokens = await options.api.call({
target: FACTORIES[options.chain],
Expand All @@ -58,13 +60,15 @@ export async function swapMetrics(options: FetchOptions): Promise<{
const fee = (nativeAmount * lpFee) / scaleFactor;
const protocolRevenue = (nativeAmount * factoryFee) / scaleFactor;
dailyFees.addGasToken(fee + protocolRevenue);
dailyRevenue.addGasToken(protocolRevenue);
dailyProtocolRevenue.addGasToken(protocolRevenue);
dailySupplySideRevenue.addGasToken(fee);
dailyVolume.addGasToken(nativeAmount);
});

return {
dailyFees,
dailyRevenue,
dailyVolume,
dailyProtocolRevenue,
dailySupplySideRevenue,
Expand Down
5 changes: 5 additions & 0 deletions fees/apexdefi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ const fetch = async (options: FetchOptions) => {
const dailySupplySideRevenue = createBalances();
const dailyProtocolRevenue = createBalances();
const dailyVolume = createBalances();
const dailyRevenue = createBalances();

const swapMetricsResult = await swapMetrics(options);

dailyFees.addBalances(swapMetricsResult.dailyFees);

dailyRevenue.addBalances(swapMetricsResult.dailyRevenue);

dailySupplySideRevenue.addBalances(swapMetricsResult.dailySupplySideRevenue);

dailyProtocolRevenue.addBalances(swapMetricsResult.dailyProtocolRevenue);
Expand All @@ -34,12 +37,14 @@ const fetch = async (options: FetchOptions) => {
const burstMetricsResult = await burstMetrics(options);

dailyFees.addBalances(burstMetricsResult.dailyFees);
dailyRevenue.addBalances(burstMetricsResult.dailyRevenue);
dailyProtocolRevenue.addBalances(burstMetricsResult.dailyProtocolRevenue);
dailyVolume.addBalances(burstMetricsResult.dailyVolume);
}

return {
dailyFees,
dailyRevenue,
dailySupplySideRevenue,
dailyProtocolRevenue,
dailyVolume,
Expand Down

0 comments on commit cde242b

Please sign in to comment.