[DEV-275] Implement compound finance liquid treasury data provider#1542
Merged
[DEV-275] Implement compound finance liquid treasury data provider#1542
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
LeonardoVieira1630
approved these changes
Jan 16, 2026
Member
LeonardoVieira1630
left a comment
There was a problem hiding this comment.
I love it. Nice job.
apps/indexer/src/api/services/treasury/providers/defillama–provider.ts
Outdated
Show resolved
Hide resolved
PedroBinotto
commented
Jan 16, 2026
PedroBinotto
commented
Jan 16, 2026
apps/dashboard/features/attack-profitability/components/AttackCostBarChart.tsx
Show resolved
Hide resolved
pikonha
approved these changes
Jan 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
Documentation
Compound Finance API consumption and data parsing
The Compound finance API returns data in the following format:
Show JSON Schema for Compound API response data
{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Generated schema for Root", "type": "object", "properties": { "data": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "number" }, "q": { "type": "string" }, "p": { "type": "number" }, "v": { "type": "number" }, "d": { "type": "number" }, "sId": { "type": "number" } }, "required": [ "id", "q", "p", "v", "d", "sId" ] } }, "meta": { "type": "object", "properties": { "limit": { "type": "number" }, "offset": { "type": "number" }, "total": { "type": "number" } }, "required": [ "limit", "offset", "total" ] } }, "required": [ "data", "meta" ] }Show example data
{ "data": [ { "id": 93273, "q": "103157124389546947170", "p": 3320.67686679802, "v": 342551.476605774, "d": 1768348800, "sId": 94 } ], "meta": { "limit": 30, "offset": 0, "total": 92811 } }Wherein:
"data.id"is a (unique) serial record ID;"data.q"represents the amount of the asset held by the treasury (needs to be treated as Wei [x / (10 ^ 18)];"data.p"represents the price of the asset at that moment in time;"data.v"represents the total value of the assets of this type held by the treasury [p * (q / (10 ^ 18))];"data.d"represents the date (at 9AM) as a UNIX timestamp;"data.sId"specifies the asset's id;The total treasury value (excluding the value in
$COMPgov. token) is then computed by summing up all asset position values for each day, filtering out the positions that point to and"sId"that has been identified as the$COMPtoken on some platform (values mapped out by analyzing the dashboard amounts to the values in the API data; see the following comparison for the results [Compound Finance dashboard/Anticapture]):Liquid treasury data caching for providers
Changes to environment configuration
The configuration model for the treasury data providers has been tweaked so that the instance no longer receives different variables for each provider (as the list was getting a bit long and difficult to maintain); instead, all providers are now configured via the same configuration parameters:
TREASURY_DATA_PROVIDER_ID:"DUNE" | "DEFILLAMA" | "COMPOUND";TREASURY_DATA_PROVIDER_API_URL:"https://api.dev/trasury?...";TREASURY_DATA_PROVIDER_API_KEY:"secretkey";The environment must be set according to the following table:
TREASURY_DATA_PROVIDER_IDTREASURY_DATA_PROVIDER_API_URLTREASURY_DATA_PROVIDER_API_KEY"DUNE""DEFILLAMA""COMPOUND"In case these values are not passed or are informed incorrectly, Anticapture will use an
undefinedprovider config and print the following warning: