Skip to content

Commit

Permalink
add tx hash and primary key to dune rows
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBeardEth committed Jan 5, 2025
1 parent 8f74215 commit 9c58407
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 17 deletions.
71 changes: 67 additions & 4 deletions apps/nextjs/src/app/(app)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import Image from "next/image";
import Link from "next/link";
import { GameCard } from "@/app/(app)/games/GameCard";
import LordsIcon from "@/icons/lords.svg";
import { api } from "@/trpc/server";
import { reader } from "@/utils/keystatic";
import { Button } from "@realms-world/ui/components/ui/button";
import {
Card,
CardContent,
CardHeader,
CardTitle,
} from "@realms-world/ui/components/ui/card";
import {
Carousel,
CarouselContent,
CarouselItem,
CarouselNext,
CarouselPrevious,
} from "@realms-world/ui/components/ui/carousel";
import { formatNumber } from "@realms-world/utils";

import { PageLayout } from "../_components/PageLayout";
import { Partners } from "../_components/Partners";
import { VeLordsRewardsChart } from "./account/lords/velords/VeLordsRewardsChart";
import { BlogGrid } from "./blogs/BlogGrid";
import CollectionsList from "./collection/CollectionsList";

Expand All @@ -37,6 +47,8 @@ export default async function Home() {
title: game.entry.title,
}));

const veLordsBurns = await api.veLordsBurns.sumByWeek();

return (
<PageLayout>
<Carousel className="w-full">
Expand Down Expand Up @@ -71,6 +83,7 @@ export default async function Home() {
<CarouselPrevious className="left-2 sm:left-4 md:left-6 lg:left-8" />
<CarouselNext className="right-2 sm:right-4 md:right-6 lg:right-8" />
</Carousel>

<div className="px-4 sm:px-6 md:px-8">
<Partners />

Expand All @@ -90,10 +103,60 @@ export default async function Home() {
<BlogGrid />
</div>

{/*<div className="my-12 sm:my-16 md:my-20 lg:my-24">
<h2 className="mb-4 font-sans text-xl sm:text-2xl md:text-3xl">Events</h2>
<EventGrid isHomepage={true} />
</div>*/}
<div className="relative my-12 h-[300px] w-full overflow-hidden rounded-lg">
<div>
<Image
src="/velords-banner-bg.jpg"
alt="veLords background"
fill
className="object-cover brightness-50"
/>
</div>
<div className="relative z-10 flex h-full flex-col items-center justify-center p-6">
<h2 className="mb-8 text-center text-4xl font-bold md:text-5xl">
veLords - Lords Staking
</h2>

<div className="grid w-full max-w-4xl grid-cols-1 gap-6 md:grid-cols-3">
<Card>
<CardHeader className="pb-2">
<CardTitle className="text-lg text-muted">APY</CardTitle>
</CardHeader>
<CardContent>
<p className="text-2xl font-bold">{formatNumber(12.34)}%</p>
</CardContent>
</Card>

<Card>
<CardHeader className="pb-2">
<CardTitle className="text-lg text-muted">
Lords Locked
</CardTitle>
</CardHeader>
<CardContent>
<p className="text-2xl font-bold">
<LordsIcon />
{formatNumber(1234567)}
</p>
</CardContent>
</Card>

<Card>
<CardHeader className="pb-2">
<CardTitle className="text-lg text-muted">
90d Lords Rewards
</CardTitle>
</CardHeader>
<CardContent>
<p className="text-2xl font-bold">
<LordsIcon />
{formatNumber(98765)}
</p>
</CardContent>
</Card>
</div>
</div>
</div>

<hr className="my-6 border sm:my-8" />
<div className="my-12 sm:my-16 md:my-20">
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/api/dune/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { api } from "@/trpc/react";
import { DuneClient, QueryParameter } from "@duneanalytics/client-sdk";
import { DuneClient } from "@duneanalytics/client-sdk";
import { db } from "@realms-world/db/client";
import { schema } from "@realms-world/db/schema";
import { env } from "env";
Expand All @@ -22,8 +21,9 @@ export async function GET(request: Request) {
(row: Record<string, unknown>) => ({
source: row.Name as string,
amount: row.amount as string,
transaction_hash: row.transaction_hash as string,
//block_time: new Date(row.block_time),
//epoch: row.epoch ? new Date(row.epoch) : null,
epoch: row.epoch ? new Date(row.epoch) : null,
epoch_total_amount: row.epoch_total_amount as string,
sender_epoch_total_amount: row.sender_epoch_total_amount as string,
}),
Expand Down
30 changes: 20 additions & 10 deletions packages/db/src/schema/dune_velords.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { numeric, pgTable, text, timestamp } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod";
import {
numeric,
pgTable,
primaryKey,
text,
timestamp,
} from "drizzle-orm/pg-core";

export const velords_burns = pgTable("dune_velords_burns", {
source: text("source").notNull(),
amount: numeric("amount").notNull(),
//block_time: timestamp("block_time").notNull(),
//epoch: timestamp("epoch"),
epoch_total_amount: numeric("epoch_total_amount").notNull(),
sender_epoch_total_amount: numeric("sender_epoch_total_amount").notNull(),
});
export const velords_burns = pgTable(
"dune_velords_burns",
{
source: text("source").notNull(),
amount: numeric("amount").notNull(),
transaction_hash: text("transaction_hash").notNull(),
//block_time: timestamp("block_time").notNull(),
//epoch: timestamp("epoch"),
epoch_total_amount: numeric("epoch_total_amount").notNull(),
sender_epoch_total_amount: numeric("sender_epoch_total_amount").notNull(),
},
(t) => [primaryKey({ columns: [t.amount, t.transaction_hash] })],
);

0 comments on commit 9c58407

Please sign in to comment.