Skip to content

Conversation

@larrettgee
Copy link

@larrettgee larrettgee commented Jan 19, 2026

Hydrex already exists on DeFi Llama with the TVL adapter. Adding in fee adapter here. LMK if you need anything else!

Summary by CodeRabbit

  • New Features
    • Added Hydrex adapter for BASE chain fee and revenue tracking.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

A new TypeScript adapter module for Hydrex is added at fees/hydrex/index.ts. The adapter computes daily fees and revenue by querying Option Exercise events for USDC payments, retrieving CreateBribe events from a bribe factory, and aggregating RewardAdded events from bribe contracts to accumulate rewards by token.

Changes

Cohort / File(s) Summary
New Hydrex Fees Adapter
fees/hydrex/index.ts
Introduces a SimpleAdapter (v2) for the BASE chain with a fetch routine that queries Option Exercise events for revenue, CreateBribe events for bribe contract discovery (with historical block tracking and cloud caching), and RewardAdded events to accumulate token rewards. Includes methodology documentation for Fees and Revenue categories. Default export of the adapter.

Sequence Diagram(s)

sequenceDiagram
    participant Adapter as Hydrex Adapter
    participant Contract as Option Exercise<br/>Contract
    participant BribeFactory as Bribe Factory
    participant BribeContracts as Bribe Contracts
    participant Revenue as Revenue<br/>Accumulator

    Adapter->>Contract: Query Option Exercise events
    Contract-->>Adapter: USDC payment records
    Adapter->>Revenue: Accumulate as dailyRevenue
    
    Adapter->>BribeFactory: Query CreateBribe events<br/>(with fromBlock & cache)
    BribeFactory-->>Adapter: Bribe contract addresses
    
    Adapter->>BribeContracts: Query RewardAdded events
    BribeContracts-->>Adapter: Reward by token records
    Adapter->>Revenue: Accumulate as dailyFees

    Revenue-->>Adapter: Return computed fees & revenue
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A Hydrex adapter hops into place,
Querying events at a brisk pace,
With bribes and rewards in the cache,
Daily fees bloom—no need to thrash!
BASE chain dancing, revenue in line,
Another adapter? Simply divine! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is minimal and does not follow the repository's template structure, lacking required fields for new protocol listings despite adding a new adapter. Although this appears to be updating an existing protocol, clarify whether the template applies and provide more context about the adapter's purpose and scope.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: hydrex fee adapter' is specific and directly reflects the main change—adding a fee adapter for the Hydrex protocol.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@fees/hydrex/index.ts`:
- Around line 38-44: create a guard around the creation and use of
bribeContracts so we never call getLogs with an empty or duplicated target list:
derive bribeContracts from createBribeLogs by mapping e.bribe.toLowerCase() then
deduplicate (e.g. via a Set) and if the resulting array is empty skip calling
getLogs (or return an empty rewardLogs) to avoid errors/double-counting; update
the call site that passes event_reward_added to getLogs to use the deduped
bribeContracts.

Comment on lines +38 to +44
const bribeContracts: string[] = createBribeLogs.map((e: any) => e.bribe.toLowerCase());

// 3. Get all RewardAdded events from bribe contracts (this accounts for DEX fees, omni fees, and bribes)
const rewardLogs = await getLogs({
targets: bribeContracts,
eventAbi: event_reward_added,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Guard empty bribe list and dedupe targets.

If createBribeLogs is empty or contains duplicates, getLogs may error or double-count rewards depending on its internals. A small guard + dedupe avoids both risks.

♻️ Suggested fix
-  const bribeContracts: string[] = createBribeLogs.map((e: any) => e.bribe.toLowerCase());
+  const bribeContracts = Array.from(
+    new Set(createBribeLogs.map((e: any) => e.bribe.toLowerCase()))
+  );
+
+  if (!bribeContracts.length) {
+    return { dailyFees: dailyRevenue, dailyRevenue };
+  }
🤖 Prompt for AI Agents
In `@fees/hydrex/index.ts` around lines 38 - 44, create a guard around the
creation and use of bribeContracts so we never call getLogs with an empty or
duplicated target list: derive bribeContracts from createBribeLogs by mapping
e.bribe.toLowerCase() then deduplicate (e.g. via a Set) and if the resulting
array is empty skip calling getLogs (or return an empty rewardLogs) to avoid
errors/double-counting; update the call site that passes event_reward_added to
getLogs to use the deduped bribeContracts.

@llamabutler
Copy link

The hydrex adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees hydrex

🦙 Running HYDREX adapter 🦙
---------------------------------------------------
Start Date:	Sun, 18 Jan 2026 15:19:21 GMT
End Date:	Mon, 19 Jan 2026 15:19:21 GMT
---------------------------------------------------

BASE 👇
Backfill start time: 8/9/2025
Daily fees: 11.22 k
Daily revenue: 11.22 k
End timestamp: 1768835960 (2026-01-19T15:19:20.000Z)

@treeoflife2 treeoflife2 self-assigned this Jan 23, 2026
Copy link
Member

@treeoflife2 treeoflife2 left a comment

Choose a reason for hiding this comment

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

.

},
methodology: {
Fees: "Total fees from DEX fees, option exercises (SPR), Omni Liquidity Fees, and bribe rewards",
Revenue: "Total revenue from DEX fees, option exercises (SPR), Omni Liquidity Fees, and bribe rewards",
Copy link
Member

Choose a reason for hiding this comment

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

what's bribe rewards in this? we track dailyBribeRevenue separtely, and bribes paid to pools won't be included in the dailyRevenue

},
},
methodology: {
Fees: "Total fees from DEX fees, option exercises (SPR), Omni Liquidity Fees, and bribe rewards",
Copy link
Member

Choose a reason for hiding this comment

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

what's SPR, here? we should also track yield generated by the pool as dailyFees, and dailyRevenue(part of fees going back to token holders if any + fees going to protocol treasury)

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