Skip to content

Commit

Permalink
PR cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Redm4x committed Sep 12, 2023
1 parent 2a78145 commit 437262b
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 234 deletions.
24 changes: 19 additions & 5 deletions api/src/db/networkRevenueProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getWeb3IndexRevenue = async (debug?: boolean) => {
date: r.date.getTime() / 1000,
revenue: round(r.usd, 2),
revenueUAkt: r.uakt,
revenueUUsdc: r.uusdc,// TODO: Include in web3index? Maybe should only include akt spending
revenueUUsdc: r.uusdc,
aktPrice: r.aktPrice,
dateStr: r.date
}));
Expand Down Expand Up @@ -61,34 +61,41 @@ export const getWeb3IndexRevenue = async (debug?: boolean) => {
if (date <= sixtyDaysAgo) {
sixtyDaysAgoRevenue += b.revenue;
sixtyDaysAgoRevenueUAkt += b.revenueUAkt;
sixtyDaysAgoRevenueUUsdc += b.revenueUUsdc;
}
if (date <= thirtyDaysAgo) {
thirtyDaysAgoRevenue += b.revenue;
thirtyDaysAgoRevenueUAkt += b.revenueUAkt;
thirtyDaysAgoRevenueUUsdc += b.revenueUUsdc;
}
if (date <= twoWeeksAgo) {
twoWeeksAgoRevenue += b.revenue;
twoWeeksAgoRevenueUAkt += b.revenueUAkt;
twoWeeksAgoRevenueUUsdc += b.revenueUUsdc;
}
if (date <= oneWeekAgo) {
oneWeekAgoRevenue += b.revenue;
oneWeekAgoRevenueUAkt += b.revenueUAkt;
oneWeekAgoRevenueUUsdc += b.revenueUUsdc;
}
if (date <= twoDaysAgo) {
twoDaysAgoRevenue += b.revenue;
twoDaysAgoRevenueUAkt += b.revenueUAkt;
twoDaysAgoRevenueUUsdc += b.revenueUUsdc;
}
if (date <= oneDayAgo) {
oneDayAgoRevenue += b.revenue;
oneDayAgoRevenueUAkt += b.revenueUAkt;
oneDayAgoRevenueUUsdc += b.revenueUUsdc;
}

totalRevenue += b.revenue;
totalRevenueUAkt += b.revenueUAkt;
totalRevenueUUsdc += b.revenueUUsdc;
}, 0);

if (!debug) {
days = days.map(({ dateStr, revenueUAkt, aktPrice, ...others }) => others) as any;
days = days.map(({ dateStr, revenueUAkt, revenueUUsdc, aktPrice, ...others }) => others) as any;
}

let revenueStats = {
Expand All @@ -112,7 +119,15 @@ export const getWeb3IndexRevenue = async (debug?: boolean) => {
twoWeeksAgAkt: uaktToAKT(twoWeeksAgoRevenueUAkt, 6),
thirtyDaysAgoAkt: uaktToAKT(thirtyDaysAgoRevenueUAkt, 6),
sixtyDaysAgoAkt: uaktToAKT(sixtyDaysAgoRevenueUAkt, 6),
ninetyDaysAgoAkt: uaktToAKT(ninetyDaysAgoRevenueUAkt, 6)
ninetyDaysAgoAkt: uaktToAKT(ninetyDaysAgoRevenueUAkt, 6),
nowUsdc: udenomToDenom(totalRevenueUUsdc, 6),
oneDayAgoUsdc: udenomToDenom(oneDayAgoRevenueUUsdc, 6),
twoDaysAgoUsdc: udenomToDenom(twoDaysAgoRevenueUUsdc, 6),
oneWeekAgoUsdc: udenomToDenom(oneWeekAgoRevenueUUsdc, 6),
twoWeeksAgUsdc: udenomToDenom(twoWeeksAgoRevenueUUsdc, 6),
thirtyDaysAgoUsdc: udenomToDenom(thirtyDaysAgoRevenueUUsdc, 6),
sixtyDaysAgoUsdc: udenomToDenom(sixtyDaysAgoRevenueUUsdc, 6),
ninetyDaysAgoUsdc: udenomToDenom(ninetyDaysAgoRevenueUUsdc, 6)
} as any;
}

Expand Down Expand Up @@ -163,9 +178,8 @@ export async function getDailyRevenue() {
date: x.date,
uakt: x.uakt,
akt: uaktToAKT(x.uakt, 6),
aktInUsd: uaktToAKT(x.uakt, 6) * x.aktPrice,
uusdc: x.uusdc,
usdc: udenomToDenom(x.uusdc),
usdc: udenomToDenom(x.uusdc, 6),
usd: uaktToAKT(x.uakt, 6) * x.aktPrice + udenomToDenom(x.uusdc),
aktPrice: x.aktPrice
}));
Expand Down
6 changes: 6 additions & 0 deletions deploy-web/src/pages/graph/[snapshot].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ const getSnapshotMetadata = (snapshot: Snapshots): { unitFn: (number) => ISnapsh
case Snapshots.totalUAktSpent:
case Snapshots.dailyUUsdcSpent:
case Snapshots.totalUUsdcSpent:
case Snapshots.dailyUUsdSpent:
case Snapshots.totalUUsdSpent:
return { unitFn: x => ({ value: udenomToDenom(x) }) };
case Snapshots.activeCPU:
return {
Expand Down Expand Up @@ -223,6 +225,8 @@ const getTitle = (snapshot: Snapshots): string => {
return "Total AKT spent";
case Snapshots.totalUUsdcSpent:
return "Total USDC spent";
case Snapshots.totalUUsdSpent:
return "Total USD spent";
case Snapshots.totalLeaseCount:
return "All-time lease count";
case Snapshots.activeCPU:
Expand All @@ -237,6 +241,8 @@ const getTitle = (snapshot: Snapshots): string => {
return "Daily AKT spent";
case Snapshots.dailyUUsdcSpent:
return "Daily USDC spent";
case Snapshots.dailyUUsdSpent:
return "Daily USD spent";
case Snapshots.dailyLeaseCount:
return "Daily new leases";

Expand Down
2 changes: 1 addition & 1 deletion deploy-web/src/types/snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export enum Snapshots {
activeLeaseCount = "activeLeaseCount",
totalUAktSpent = "totalUAktSpent",
totalUUsdcSpent = "totalUUsdcSpent",
totalUsdSpent = "totalUUsdSpent",
totalUUsdSpent = "totalUUsdSpent",
totalLeaseCount = "totalLeaseCount",
activeCPU = "activeCPU",
activeGPU = "activeGPU",
Expand Down
2 changes: 2 additions & 0 deletions deploy-web/src/utils/snapshotsUrlHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export const urlParamToSnapshot = (snapshotsUrlParam: SnapshotsUrlParam) => {
[SnapshotsUrlParam.storage]: Snapshots.activeStorage,
[SnapshotsUrlParam.totalAKTSpent]: Snapshots.totalUAktSpent,
[SnapshotsUrlParam.totalUSDCSpent]: Snapshots.totalUUsdcSpent,
[SnapshotsUrlParam.totalUSDSpent]: Snapshots.totalUUsdSpent,
[SnapshotsUrlParam.dailyAktSpent]: Snapshots.dailyUAktSpent,
[SnapshotsUrlParam.dailyUsdcSpent]: Snapshots.dailyUUsdcSpent,
[SnapshotsUrlParam.dailyUsdSpent]: Snapshots.dailyUUsdSpent,
[SnapshotsUrlParam.dailyDeploymentCount]: Snapshots.dailyLeaseCount
};

Expand Down
Loading

0 comments on commit 437262b

Please sign in to comment.