Skip to content

feat: use 7d growthepie endpoint #15611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/lib/api/fetchGrowThePie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,19 @@ const TXCOUNT = "txcount"
const ACTIVE_ADDRESSES = "aa_last7d"

export const fetchGrowThePie = async (): Promise<GrowThePieData> => {
const url = "https://api.growthepie.xyz/v1/fundamentals.json"
const url = "https://api.growthepie.xyz/v1/fundamentals_7d.json"

const response = await fetch(url, { cache: "no-store" })
const response = await fetch(url)
if (!response.ok) {
console.log(response.status, response.statusText)
throw new Error("Failed to fetch growthepie data")
}
const data: DataItem[] = await response.json()

// Get the date 7 days ago
const sevenDaysAgo = new Date()
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7)

// Filter data to only include the last 7 days and the metrics we need
const filteredData = data.filter((item) => {
const itemDate = new Date(item.date)
return (
itemDate >= sevenDaysAgo &&
[TXCOSTS_MEDIAN_USD, TXCOUNT, ACTIVE_ADDRESSES].includes(item.metric_key)
)
})
// Filter data to only include the metrics we need
const filteredData = data.filter((item) =>
[TXCOSTS_MEDIAN_USD, TXCOUNT, ACTIVE_ADDRESSES].includes(item.metric_key)
)

const mostRecentDate = filteredData.reduce((latest, item) => {
const itemDate = new Date(item.date)
Expand Down