Skip to content

[update] SparkDEX V3-1/V4: date-gated BBB fee split from 2026-05-18#8307

Closed
0xNx wants to merge 2 commits into
DefiLlama:masterfrom
SparkDEX:sparkdex-v3-v4-bbb
Closed

[update] SparkDEX V3-1/V4: date-gated BBB fee split from 2026-05-18#8307
0xNx wants to merge 2 commits into
DefiLlama:masterfrom
SparkDEX:sparkdex-v3-v4-bbb

Conversation

@0xNx

@0xNx 0xNx commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Update SparkDEX V3-1 and V4 fee revenue attribution after governance proposal B (effective 2026-05-18): 25% of swap fees go to treasury for SPRK buyback-and-burn; 75% to LPs; 0% protocol revenue.
  • Add fees/sparkdex-v4 (factory cannot date-gate fee percentages; V3-1 already keeps a custom fees adapter).
  • Align factory/uniSubgraph.ts static feesPercent with the post-BBB split (DEX volume surface).

Proposal: https://sparkdex.ai/governance/proposal/6a046cbecd38e8c7fea826ee

Fee split

Protocol Period LP Protocol Holders
V3-1 before 2026-05-18 87.5% 2.5% 5% buyback + 5% staking
V3-1 from 2026-05-18 75% 0% 25% buyback
V4 before 2026-05-18 75% 5% 10% buyback + 10% staking
V4 from 2026-05-18 75% 0% 25% buyback

Files

  • fees/sparkdex-v3-1/index.ts — date-gated split + early-redemption burns unchanged
  • fees/sparkdex-v4/index.ts — new fees adapter (algebraDayData)
  • factory/uniSubgraph.ts — post-BBB static ratios + methodology

Notes

  • Accurate pre/post history lives in the fees adapters; uniSubgraph uses the current (post-BBB) static percentages because factory configs cannot switch by date.
  • Perps BBB changes are not included (separate PR/branch).

Test plan

  • fees/sparkdex-v3-1 for 2026-05-17 → 87.5 / 2.5 / 10
  • fees/sparkdex-v3-1 for 2026-05-18 → 75 / 0 / 25 (buyback)
  • fees/sparkdex-v4 for 2026-05-17 → 75 / 5 / 20
  • fees/sparkdex-v4 for 2026-05-18 → 75 / 0 / 25 (buyback)
  • Confirm factory sparkdex-v3-1 / sparkdex-v4 still resolve for dexs volume

NOTE: Please enable "Allow edits by maintainers".

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3d3d6780-412a-4152-813f-01db05890862

📥 Commits

Reviewing files that changed from the base of the PR and between 3edd2c7 and 011a007.

📒 Files selected for processing (3)
  • fees/sparkdex-v3-1/index.ts
  • fees/sparkdex-v4/index.ts
  • helpers/sparkdex.ts

Summary by CodeRabbit

  • New Features
    • Added support for tracking SparkDEX V4 daily fees and revenue on Flare.
  • Updates
    • Revised SparkDEX V3.1 fee-to-revenue allocations to use an effective timestamp boundary, changing the post-cutoff distribution (including setting protocol revenue to 0% after the cutoff).
    • Updated SparkDEX V4 revenue split rules using the same cutoff for holders buyback-and-burn vs supply-side LP fees.
    • Improved early redemption penalty reporting with clearer “Early Redemption Penalty” categorization.
  • Documentation / Reporting
    • Refreshed the exposed fee-revenue methodology descriptions to match the new pre/post allocation semantics.

Walkthrough

SparkDEX V3.1 now applies BBB cutoff-based fee splits and labels early redemption penalties. A new SparkDEX V4 Flare adapter fetches daily Goldsky fees and applies the same allocation boundary. Factory configurations define updated dates, percentages, and methodologies.

Changes

SparkDEX fee allocation

Layer / File(s) Summary
Update SparkDEX V3.1 allocation logic
helpers/sparkdex.ts, fees/sparkdex-v3-1/index.ts
Adds the BBB cutoff, applies pre- and post-cutoff revenue splits, labels early redemption penalties, and updates methodology descriptions.
Add SparkDEX V4 adapter
fees/sparkdex-v4/index.ts
Adds a Flare adapter that queries daily Goldsky fee data and returns fee, protocol, holder, and supply-side revenue balances using cutoff-based allocations.
Wire factory fee methodologies
factory/uniSubgraph.ts
Updates SparkDEX V3.1 and V4 fee percentages, dates, and explicit methodology configurations.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Adapter
  participant Goldsky
  participant RevenueBuckets
  Adapter->>Goldsky: Query algebraDayData by dateId
  Goldsky-->>Adapter: Return feesUSD
  Adapter->>RevenueBuckets: Apply BBB_START fee allocation
  RevenueBuckets-->>Adapter: Return daily revenue balances
Loading

Possibly related PRs

Suggested labels: methodology

🚥 Pre-merge checks | ✅ 12 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is relevant, but it doesn't follow the required “[type] protocol-name - description” format because it uses a colon after the protocol name. Use the format [update] SparkDEX V3-1/V4 - date-gated BBB fee split from 2026-05-18.
Income Statement Balance ⚠️ Warning sparkdex-v3-1 adds redemption burns to both dailyFees and dailyHoldersRevenue, while dailySupplySideRevenue is cloned from burn-inclusive dailyFees, so fee=rev+sup fails on burn days. Base the LP split on swap fees only (or subtract burns from the fee base) so each redemption burn is counted once and the income statement balances.
Fetchoptions Usage ⚠️ Warning fees/sparkdex-v3-1 fetch still returns timestamp: todaysTimestamp, which the check forbids. Remove the timestamp field from the fetch result and let the runner populate timestamps instead.
✅ Passed checks (12 passed)
Check name Status Explanation
Description check ✅ Passed The description is detailed and includes summary, split table, affected files, notes, and test plan, which is sufficient for this update PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Breakdown Methodology Check ✅ Passed Both SparkDEX fee adapters export breakdownMethodology, and every .add() label (SWAP_FEES, TOKEN_BUY_BACK, STAKING_REWARDS, LP_FEES, early-redemption) is mapped.
Income Statement Compliance ✅ Passed SparkDEX v3-1/v4 set dailyFees to total fees, dailySupplySideRevenue to LP share, and dailyRevenue to protocol+holders; the splits sum to 100%.
Version 2 Required ✅ Passed PASS: the new fees/sparkdex-v4 adapter exports version: 2; sparkdex-v3-1 remains an updated existing version: 1 adapter.
Pullhourly Required For Version 2 ✅ Passed PASS: fees/sparkdex-v4/index.ts is version 2 and explicitly sets pullHourly: false with a comment noting only daily aggregates are available.
Dune Adapters Are Version 1 ✅ Passed No changed adapter queries Dune; sparkdex-v3-1 is version 1 and sparkdex-v4 uses GraphQL, so the rule is satisfied.
Adapter Shape ✅ Passed sparkdex-v4 uses a single-chain adapter (chains: [CHAIN.FLARE]) with one start, and no per-chain adapter object/config maps were added.
Efficiency And Error Handling ✅ Passed No flagged anti-patterns found: getLogs uses target+eventAbi, no raw topics/try-catch/allowNegativeValue/api.call loops, and new constants/ratios are source-commented.
Methodology Keys ✅ Passed Methodology objects use display keys (Fees, Revenue, SupplySideRevenue, ProtocolRevenue, HoldersRevenue, UserFees); no dailyFees/dailyVolume keys appear.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

The sparkdex-v3-1 adapter exports:

> adapters@1.0.0 test
> ts-node --transpile-only cli/testAdapter.ts fees sparkdex-v3-1

🦙 Running SPARKDEX-V3-1 adapter 🦙
---------------------------------------------------
Start Date:	Mon, 20 Jul 2026 00:00:00 GMT
End Date:	Tue, 21 Jul 2026 00:00:00 GMT
---------------------------------------------------

FLARE 👇
Backfill start time: 2/7/2024
Daily fees: 99.00
Daily revenue: 25.00
Daily protocol revenue: 0.00
Daily holders revenue: 25.00
Daily supply side revenue: 74.00
End timestamp: 1784505600 (2026-07-20T00:00:00.000Z)




FEES BREAKDOWN 👇

label           | Daily fees | Daily supply side revenue | Daily revenue | Daily holders revenue
---             | ---        | ---                       | ---           | ---                  
Token Swap Fees | 99         |                           |               |                      
LP Fees         |            | 74                        |               |                      
Token Buy Back  |            |                           | 25            | 25                   

@github-actions

Copy link
Copy Markdown

The sparkdex-v4 adapter exports:

> adapters@1.0.0 test
> ts-node --transpile-only cli/testAdapter.ts fees sparkdex-v4

🦙 Running SPARKDEX-V4 adapter 🦙
---------------------------------------------------
Start Date:	Mon, 20 Jul 2026 05:31:09 GMT
End Date:	Tue, 21 Jul 2026 05:31:09 GMT
---------------------------------------------------

FLARE 👇
Backfill start time: 26/1/2026
Daily fees: 404.00
Daily user fees: 404.00
Daily revenue: 101.00
Daily protocol revenue: 0.00
Daily holders revenue: 101.00
Daily supply side revenue: 303.00
End timestamp: 1784611868 (2026-07-21T05:31:08.000Z)




FEES BREAKDOWN 👇

label           | Daily fees | Daily supply side revenue | Daily revenue | Daily holders revenue
---             | ---        | ---                       | ---           | ---                  
Token Swap Fees | 404        |                           |               |                      
LP Fees         |            | 303                       |               |                      
Token Buy Back  |            |                           | 101           | 101                  

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@fees/sparkdex-v3-1/index.ts`:
- Around line 22-27: Extract the duplicated BBB_START constant and its
governance documentation into a shared helper under helpers, then update the
adapters’ fee logic to import and reuse that shared symbol. Remove the local
declarations from both sparkdex-v3-1 and sparkdex-v4 while preserving the
existing cutoff value and governance reference.

In `@fees/sparkdex-v4/index.ts`:
- Around line 12-17: Remove the duplicate BBB_START governance constant and its
associated comment from the Sparkdex v4 fee configuration, reusing the existing
shared definition or established source used by Sparkdex v3-1 instead.
- Around line 69-73: Update the version 2 adapter object in the fees adapter to
explicitly set pullHourly to false, and add a concise explanatory comment that
the algebraDayData source only provides daily aggregates and cannot support
hourly retrieval.
- Around line 19-21: Update the v2 adapter’s fetch function around fetch to
derive the date key from options.startTimestamp (or options.fromTimestamp)
instead of options.startOfDay, ensuring hourly runs produce distinct time
windows. Do not rely on start-of-day unless the adapter configuration explicitly
sets pullHourly: false.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8119595f-d313-421c-a13a-bcd5b82910ef

📥 Commits

Reviewing files that changed from the base of the PR and between 7a913b5 and 3edd2c7.

📒 Files selected for processing (3)
  • factory/uniSubgraph.ts
  • fees/sparkdex-v3-1/index.ts
  • fees/sparkdex-v4/index.ts

Comment thread fees/sparkdex-v3-1/index.ts Outdated
Comment thread fees/sparkdex-v4/index.ts Outdated
Comment thread fees/sparkdex-v4/index.ts
Comment thread fees/sparkdex-v4/index.ts
@github-actions

Copy link
Copy Markdown

The sparkdex-v3-1 adapter exports:

> adapters@1.0.0 test
> ts-node --transpile-only cli/testAdapter.ts fees sparkdex-v3-1

🦙 Running SPARKDEX-V3-1 adapter 🦙
---------------------------------------------------
Start Date:	Mon, 20 Jul 2026 00:00:00 GMT
End Date:	Tue, 21 Jul 2026 00:00:00 GMT
---------------------------------------------------

FLARE 👇
Backfill start time: 2/7/2024
Daily fees: 99.00
Daily revenue: 25.00
Daily protocol revenue: 0.00
Daily holders revenue: 25.00
Daily supply side revenue: 74.00
End timestamp: 1784505600 (2026-07-20T00:00:00.000Z)




FEES BREAKDOWN 👇

label           | Daily fees | Daily supply side revenue | Daily revenue | Daily holders revenue
---             | ---        | ---                       | ---           | ---                  
Token Swap Fees | 99         |                           |               |                      
LP Fees         |            | 74                        |               |                      
Token Buy Back  |            |                           | 25            | 25                   

@github-actions

Copy link
Copy Markdown

The sparkdex-v4 adapter exports:

> adapters@1.0.0 test
> ts-node --transpile-only cli/testAdapter.ts fees sparkdex-v4

🦙 Running SPARKDEX-V4 adapter 🦙
---------------------------------------------------
Start Date:	Mon, 20 Jul 2026 05:47:30 GMT
End Date:	Tue, 21 Jul 2026 05:47:30 GMT
---------------------------------------------------

FLARE 👇
Backfill start time: 26/1/2026
Daily fees: 770.00
Daily user fees: 770.00
Daily revenue: 193.00
Daily protocol revenue: 0.00
Daily holders revenue: 193.00
Daily supply side revenue: 578.00
End timestamp: 1784612849 (2026-07-21T05:47:29.000Z)




FEES BREAKDOWN 👇

label           | Daily fees | Daily supply side revenue | Daily revenue | Daily holders revenue
---             | ---        | ---                       | ---           | ---                  
Token Swap Fees | 770        |                           |               |                      
LP Fees         |            | 578                       |               |                      
Token Buy Back  |            |                           | 193           | 193                  

@bheluga

bheluga commented Jul 24, 2026

Copy link
Copy Markdown
Member

@0xNx thanks for the PR
Added here

@bheluga bheluga closed this Jul 24, 2026
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.

2 participants