Skip to content

feat(plugins): per-cycle yield-distribution Sankey auto-report - #88

Open
BreadrichEngels wants to merge 3 commits into
mainfrom
feat/distribution-sankey-plugin
Open

feat(plugins): per-cycle yield-distribution Sankey auto-report#88
BreadrichEngels wants to merge 3 commits into
mainfrom
feat/distribution-sankey-plugin

Conversation

@BreadrichEngels

Copy link
Copy Markdown
Contributor

Type of Change

  • Feature skill - adds a channel or integration (source code changes + SKILL.md)
  • Utility skill
  • Operational/container skill
  • Fix
  • Simplification
  • Documentation

Profile plugin (no src/ changes), same slot as sd-kickoff / weekly-agenda.

Description

What — After each new on-chain yield distribution, posts a Mermaid Sankey of that cycle (per-cycle, not cumulative) to a channel.

Why — Gives the team an automatic, visual, trustless record of where each cycle's BREAD went — derived from chain events, independent of the subgraph (which had drifted; see the companion fix in BreadchainCoop/subgraph#5).

How it works

  1. Polls YieldDistributed logs on the YieldDistributor (0xeE95…024b, Gnosis).
  2. For each new cycle block, reads the BREAD Transfer logs emitted from the distributor in that block — authoritative recipient + amount, with no positional project-array mapping (that mapping is exactly what keeps breaking the subgraph).
  3. Renders sankey-beta (Yield Distributor, <recipient>, <BREAD>) + a one-line caption, and posts it.

Uses plain fetch JSON-RPC + minimal hex decoding, so it adds no new dependency (event topic hashes are hardcoded). First run anchors to the chain head and doesn't backfill history. Config + state live in the KB; no-op until config.md exists.

Example output (real, from live Gnosis data while building this — the all-time view; the plugin posts the single newest cycle each time):

sankey-beta
Yield Distributor,Bread Core,14153.8
Yield Distributor,Bread Treasury,8691.23
Yield Distributor,Symbiota,8275.17
Loading

Files

  • profiles/example/plugins/distribution-sankey.mjs — the flow
  • profiles/example/plugins/__tests__/distribution-sankey.test.mjs — unit tests
  • profiles/example/groups/slack_main/context/distribution-sankey/README.md — config format

How it was tested

  • node --check clean; 5 unit tests for the pure helpers (config parse incl. the quoted-address YAML footgun, topic→address decode, unit formatting, per-cycle aggregation/sort/label, Sankey render).
  • Full suite green: 727/727. prettier --check "src/**/*.ts" unaffected (new files are .mjs/.md, outside the src/** CI globs).
  • Validated end-to-end against the live Gnosis RPC during development: pulled all 22 historical cycles and reconciled totals (59.6k BREAD, 406.5k supply).

Notes

  • Per Ron: this is meant to run on the breadchain profile. Since that profile is host-local/gitignored, the .mjs needs to land in profiles/breadchain/plugins/ on the droplet (deploy/admin step), and a config.md dropped in the KB — I can prep the config (channel + the recipient name map) once we pick the target channel.

For Skills

  • SKILL.md contains instructions, not inline code
  • SKILL.md is under 500 lines
  • I tested this skill on a fresh clone

Adds a distribution-sankey profile plugin (sibling to sd-kickoff /
weekly-agenda) that, after each new on-chain yield distribution, posts a
Mermaid sankey-beta of THAT cycle (per-cycle, not cumulative) to a channel.

Derives each cycle straight from events, no subgraph dependency:
- polls YieldDistributed logs on the YieldDistributor
- for each new cycle block, reads the BREAD Transfer logs FROM the distributor
  (authoritative recipient + amount — avoids the positional project-array
  mapping that keeps breaking the subgraph)
- renders 'Yield Distributor, <recipient>, <BREAD>'

Plain fetch JSON-RPC + minimal hex decoding, so it adds NO dependency. First
run anchors to the chain head (no history backfill). Config + state live in the
KB (context/distribution-sankey/config.md); no-op until that file exists.

Ships the plugin, unit tests for the pure decode/aggregate/render helpers, and
a config README. Verified end-to-end against live Gnosis data while building it
(22 historical cycles, 59.6k BREAD).
… link)

Per review (Ron/Marv's marketing workflow), the per-cycle report is now
newsletter-ready:
- human cycle DATE (from the block timestamp)
- total BREAD + ~USD value (usd_per_bread config, default 1 — BREAD is 1:1 DAI)
- gnosisscan tx link for the distribution (explorer_tx_base config)
- per-project breakdown with %

Adds usd_per_bread + explorer_tx_base config knobs and a formatCycleDate helper;
poll() now fetches the block timestamp + tx hash per cycle. Tests cover the new
config fields, the date formatter, and the enriched render. Full suite green.
…nth)

Adds a container skill so the distribution report can be generated outside the
scheduled plugin routine — the call-it-anytime path Ron asked for (and the basis
for Marv's monthly post).

report.mjs is self-contained (plain fetch JSON-RPC, no deps): derives cycles
from YieldDistributed + the BREAD Transfers from the distributor, names from the
KB config layered over built-ins, and prints a ready-to-post caption + Mermaid
sankey-beta + per-project % breakdown. Modes: latest (default), all (cumulative),
month YYYY-MM. Verified live against Gnosis (latest cycle, all-time 22 cycles /
59.6k BREAD, and a month aggregate).
@RonTuretzky
RonTuretzky force-pushed the feat/distribution-sankey-plugin branch from a65598a to 5b2c40b Compare July 31, 2026 20:21
RonTuretzky pushed a commit that referenced this pull request Jul 31, 2026
fix: move getPlatformId patch to whatsapp-auth.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant