-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor/dev 234 create treasury endpoint #1508
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
base: dev
Are you sure you want to change the base?
Refactor/dev 234 create treasury endpoint #1508
Conversation
- Add TreasuryService with provider interface - Implement DefiLlama provider for treasury data - Implement Dune provider as fallback option - Add treasury-provider-factory for dynamic provider initialization - Support for liquid treasury historical data 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add DEFILLAMA_API_URL optional environment variable - Add TREASURY_PROVIDER_PROTOCOL_ID for provider configuration - Update .env.example with treasury provider examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Rename fetchTotalAssets to fetchLiquidTreasury - Move DuneResponse type to treasury providers - Update import to use treasury provider types - Remove obsolete types.ts file 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Update assets controller to use TreasuryService - Replace DuneService instantiation with createTreasuryProvider factory - Change endpoint from /total-assets to /liquid-treasury - Add order parameter support for historical data sorting - Remove totalAssets import from controllers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Update @types/pg to version 8.15.4 - Update pnpm lockfile 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
apps/indexer/src/api/services/treasury/providers/treasury-provider.interface.ts
Outdated
Show resolved
Hide resolved
| }); | ||
|
|
||
| // Create timeline from first data point to today | ||
| const timeline = createDailyTimelineFromData(liquidMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be moved to inside the forward fill func?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can… but I think it’s better to keep it separated.
- Make each thing responsible for a single responsibility.
- The treasury functions can keep using the timeline generated by calling createDailyTimelineFromData. If you take a look at that function in this file, the output of createDailyTimelineFromData is not used only for the forward fill.
apps/indexer/src/api/services/treasury/providers/coingecko-price-provider.ts
Outdated
Show resolved
Hide resolved
| export const useTreasury = ( | ||
| daoId: DaoIdEnum, | ||
| type: TreasuryType = "total", | ||
| days: TimeInterval = TimeInterval.ONE_YEAR, | ||
| options?: { | ||
| order?: "asc" | "desc"; | ||
| config?: Partial<SWRConfiguration<TreasuryResponse, Error>>; | ||
| }, | ||
| ) => { | ||
| const { order = "asc", config } = options || {}; | ||
| const key = daoId ? ["treasury", daoId, type, days, order] : null; | ||
|
|
||
| const { data, error, isValidating, mutate } = useSWR<TreasuryResponse>( | ||
| key, | ||
| () => fetchTreasury({ daoId, type, days, order }), | ||
| { | ||
| revalidateOnFocus: false, | ||
| shouldRetryOnError: false, | ||
| ...config, | ||
| }, | ||
| ); | ||
|
|
||
| return { | ||
| data: data?.items ?? [], | ||
| totalCount: data?.totalCount ?? 0, | ||
| loading: isValidating, | ||
| error, | ||
| refetch: mutate, | ||
| }; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export const useTreasury = ( | |
| daoId: DaoIdEnum, | |
| type: TreasuryType = "total", | |
| days: TimeInterval = TimeInterval.ONE_YEAR, | |
| options?: { | |
| order?: "asc" | "desc"; | |
| config?: Partial<SWRConfiguration<TreasuryResponse, Error>>; | |
| }, | |
| ) => { | |
| const { order = "asc", config } = options || {}; | |
| const key = daoId ? ["treasury", daoId, type, days, order] : null; | |
| const { data, error, isValidating, mutate } = useSWR<TreasuryResponse>( | |
| key, | |
| () => fetchTreasury({ daoId, type, days, order }), | |
| { | |
| revalidateOnFocus: false, | |
| shouldRetryOnError: false, | |
| ...config, | |
| }, | |
| ); | |
| return { | |
| data: data?.items ?? [], | |
| totalCount: data?.totalCount ?? 0, | |
| loading: isValidating, | |
| error, | |
| refetch: mutate, | |
| }; | |
| }; | |
| export const useTreasury = ( | |
| daoId: DaoIdEnum, | |
| type: TreasuryType = "total", | |
| days: TimeInterval = TimeInterval.ONE_YEAR, | |
| order: "asc" | "desc" = "asc", | |
| ) => { | |
| const { data, error, isValidating } = useSWR<TreasuryResponse>( | |
| ["treasury", daoId, type, days, order], | |
| () => fetchTreasury({ daoId, type, days, order }), | |
| { | |
| revalidateOnFocus: false, | |
| shouldRetryOnError: false, | |
| }, | |
| ); | |
| return { | |
| data: data?.items ?? [], | |
| totalCount: data?.totalCount ?? 0, | |
| loading: isValidating, | |
| error, | |
| }; | |
| }; | |
No description provided.