Skip to content

[DEV-275] Implement compound finance liquid treasury data provider#1542

Merged
pikonha merged 11 commits intodevfrom
feat/compound-liquid-treasury
Jan 19, 2026
Merged

[DEV-275] Implement compound finance liquid treasury data provider#1542
pikonha merged 11 commits intodevfrom
feat/compound-liquid-treasury

Conversation

@PedroBinotto
Copy link
Contributor

@PedroBinotto PedroBinotto commented Jan 15, 2026

Changelog

  • Added implementation for Compound Finance as an integrated liquid treasury data provider;
  • Compound DAO dashboard now consuming liquid treasury data from the Compound Finance API;
  • Added new caching mechanism for liquid treasury data fetching;
  • Tweaked treasury data provider configuration environment variable parsing ir order to keep it simple and readable as more providers are added to Anticapture;

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 $COMP gov. 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 $COMP token 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]):

Screenshot from 2026-01-15 20-22-47 Screenshot from 2026-01-15 20-22-14

Liquid treasury data caching for providers

  • Caching mechanism has been added so that data from calls to treasury data provider APIs are stored and kept for 24 hours before being invalidated;

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 Provider TREASURY_DATA_PROVIDER_ID TREASURY_DATA_PROVIDER_API_URL TREASURY_DATA_PROVIDER_API_KEY
Dune "DUNE" API URL required API key required
DefiLlama "DEFILLAMA" Base API + value previously passed in as PROTOCOL_ID N/A
Compound "COMPOUND" API URL required N/A

In case these values are not passed or are informed incorrectly, Anticapture will use an undefined provider config and print the following warning:

Liquid treasury provider not configured. Only dao-token treasury will be available.

@vercel
Copy link

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
anticapture Ready Ready Preview, Comment Jan 19, 2026 6:17pm
anticapture-storybook Ready Ready Preview, Comment Jan 19, 2026 6:17pm

Request Review

@vercel vercel bot temporarily deployed to Preview – anticapture-storybook January 15, 2026 23:20 Inactive
@PedroBinotto PedroBinotto marked this pull request as ready for review January 15, 2026 23:21
@PedroBinotto PedroBinotto changed the title [DEV-275] Compound liquid treasury [DEV-275] Implement compound finance liquid treasury data provider Jan 15, 2026
Copy link
Member

@LeonardoVieira1630 LeonardoVieira1630 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it. Nice job.

@vercel vercel bot temporarily deployed to Preview – anticapture-storybook January 19, 2026 18:14 Inactive
@pikonha pikonha merged commit 2329919 into dev Jan 19, 2026
4 checks passed
@pikonha pikonha deleted the feat/compound-liquid-treasury branch January 19, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants