Conversation
WalkthroughThis PR adds support for the TxFlow chain by introducing a new chain identifier and two corresponding adapters: one for daily trading metrics (volume and fees) and another for hourly open-interest data, both sourcing from Dune SQL. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
🚥 Pre-merge checks | ❌ 6❌ Failed checks (6 warnings)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
✨ Simplify 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. Comment |
|
The txflow-perps adapter exports: |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@dexs/txflow-perps/index.ts`:
- Line 5: The fetch function currently uses the deprecated signature async
function fetch(_a: any, _b: any, options: FetchOptions) — update it to the
Version 2 adapter signature async function fetch(options: FetchOptions) by
removing the unused _a and _b parameters, update any internal references to use
options directly, and ensure the function conforms to Dune v2 adapter
expectations (keep the function name fetch and type FetchOptions).
- Around line 29-33: dailyUserFees is set to the same Balances object as
dailyFees (dailyUserFees: dailyFees), which can cause shared-mutation bugs;
update the return to create an explicit copy by using dailyUserFees:
dailyFees.clone() (or the Balances clone method used elsewhere) so dailyFees and
dailyUserFees are independent objects and consistent with helpers like
uniswap.ts.
In `@open-interest/txflow-perps-oi.ts`:
- Around line 1-4: The imports are split for types from the same module;
consolidate by importing Dependencies together with FetchOptions and
SimpleAdapter from "../adapters/types" (update the import containing
FetchOptions and SimpleAdapter to also include Dependencies) and remove the
separate import of Dependencies so only a single import statement for those
three types remains.
- Line 6: The fetch function currently uses unnamed placeholders (_a, _b) and
must adopt the V2 adapter signature: change the declaration async function
fetch(_a: any, _b: any, options: FetchOptions) to a clear V2 signature such as
async function fetch(timestamp: number, chainBlocks: any, options: FetchOptions)
(keeping the existing FetchOptions type), then update any internal references
accordingly to use timestamp and chainBlocks instead of _a/_b; the function name
fetch and the FetchOptions type are the key symbols to adjust.
- Around line 7-14: The Dune SQL comparison uses a raw integer timestamp so
update the duneQuery string (the duneQuery constant that references
options.startOfDay) to convert the epoch to a Dune timestamp using
from_unixtime(${options.startOfDay}) in the WHERE clause (instead of hour_ts =
${options.startOfDay}); also enable hourly pulls by adding pullHourly: true to
the adapter configuration object exported in this module so the source supports
hourly granularity.
🪄 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: caa6978f-3c3e-408a-bfb0-83fdd45924a9
📒 Files selected for processing (3)
dexs/txflow-perps/index.tshelpers/chains.tsopen-interest/txflow-perps-oi.ts
| import { CHAIN } from "../../helpers/chains"; | ||
| import { queryDuneSql } from "../../helpers/dune"; | ||
|
|
||
| async function fetch(_a: any, _b: any, options: FetchOptions) { |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Use Version 2 adapter signature.
The function uses the deprecated (_a: any, _b: any, options: FetchOptions) signature. Per guidelines, prefer the Version 2 signature (options: FetchOptions) for Dune queries.
♻️ Proposed fix
-async function fetch(_a: any, _b: any, options: FetchOptions) {
+async function fetch(options: FetchOptions) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| async function fetch(_a: any, _b: any, options: FetchOptions) { | |
| async function fetch(options: FetchOptions) { |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@dexs/txflow-perps/index.ts` at line 5, The fetch function currently uses the
deprecated signature async function fetch(_a: any, _b: any, options:
FetchOptions) — update it to the Version 2 adapter signature async function
fetch(options: FetchOptions) by removing the unused _a and _b parameters, update
any internal references to use options directly, and ensure the function
conforms to Dune v2 adapter expectations (keep the function name fetch and type
FetchOptions).
There was a problem hiding this comment.
dune queries would have version 1 , they would be run once a day as they are expensive, remember for future
There was a problem hiding this comment.
@bheluga, thanks for the clarification! I've noted this for future reviews — expensive Dune query adapters intentionally use the Version 1 signature (_a: any, _b: any, options: FetchOptions) since they run once a day, and the Version 2 signature recommendation does not apply to them.
✏️ Learnings added
Learnt from: bheluga
Repo: DefiLlama/dimension-adapters PR: 6390
File: dexs/txflow-perps/index.ts:5-5
Timestamp: 2026-04-14T11:10:46.769Z
Learning: Applies to dexs/**/*.ts and open-interest/**/*.ts: Expensive Dune query adapters (marked with `isExpensiveAdapter: true` and `dependencies: [Dependencies.DUNE]`) intentionally use the Version 1 adapter signature `async function fetch(_a: any, _b: any, options: FetchOptions)` because they run once a day. Do NOT flag this as deprecated or suggest switching to the Version 2 `(options: FetchOptions)` signature for such adapters.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
🧠 Learnings used
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: GUIDELINES.md:0-0
Timestamp: 2026-04-03T10:25:08.836Z
Learning: Applies to adapters/**/*.ts : Use Adapter Version 2 with `(options: FetchOptions)` signature for on-chain logs, contract calls, subgraphs, and Dune queries with timestamp filters. Support arbitrary start/end timestamps and `pullHourly` option. Prefer Version 2 over Version 1
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: dexs/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:25.918Z
Learning: Applies to dexs/**/*.ts : Prioritize on-chain event logs, then subgraphs, then query engines (Dune, Flipside, Allium), and use protocol APIs as a last resort for data sources in DEX adapters
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: aggregators/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:05.173Z
Learning: Applies to aggregators/**/*.ts : Track all chains the aggregator operates on in the adapter implementation
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: dexs/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:25.918Z
Learning: Applies to dexs/**/*.ts : Use options.getLogs() for on-chain event logs as the most reliable data source for DEX adapters
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: options/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:07:11.033Z
Learning: Applies to options/**/*.{ts,js} : Use query engines for complex options analysis as a data source
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: aggregator-options/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:05:54.952Z
Learning: Applies to aggregator-options/**/*.{ts,tsx,js,jsx} : Avoid double-counting with underlying options protocol adapters when aggregating options data
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: options/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:07:11.033Z
Learning: Applies to options/**/*.{ts,js} : Use protocol subgraphs as a data source for historical options data
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: aggregators/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:05.173Z
Learning: Applies to aggregators/**/*.ts : Use aggregator APIs as an alternative data source when on-chain tracking is complex
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: aggregators/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:05.173Z
Learning: Applies to aggregators/**/*.ts : Use query engines for cross-DEX aggregation analysis when needed
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: aggregator-derivatives/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:05:47.814Z
Learning: Applies to aggregator-derivatives/**/*.{js,ts,tsx} : Use Protocol APIs as a data source when on-chain tracking of aggregator volume is complex
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-30T12:07:15.631Z
Learning: Applies to **/*adapter*.{ts,js} : New adapters must use version: 2 format. Check that the adapter exports version: 2 unless it's updating an existing v1 adapter.
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:41.566Z
Learning: Applies to fees/**/*.ts : Include `dailyFees` dimension in fees adapters - maps to Gross Protocol Revenue and should include all fees from all sources (total value flow into protocol ecosystem)
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: dexs/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:25.918Z
Learning: Applies to dexs/**/*.ts : Track dailyFees, dailyRevenue, and dailySupplySideRevenue dimensions with appropriate breakdown labels and breakdownMethodology when tracking fees/revenue in DEX adapters
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-30T12:07:15.631Z
Learning: Applies to **/*adapter*.{ts,js} : For fees adapters: verify dailyFees represents Gross Protocol Revenue (all potential fees), dailyRevenue represents Gross Profit (protocol's portion), and dailySupplySideRevenue represents Cost of Funds (supplier payments). Ensure dailyRevenue = dailyFees - dailySupplySideRevenue conceptually.
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:41.566Z
Learning: Applies to fees/**/*.ts : Use source and destination labels for `dailySupplySideRevenue` dimension in fees adapters (e.g., 'Borrow Interest To Lenders', 'Swap Fees To LPs')
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:41.566Z
Learning: Applies to fees/**/*.ts : Use source and destination labels for `dailyRevenue` dimension in fees adapters (e.g., 'Borrow Interest To Treasury', 'Swap Fees To Protocol')
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: GUIDELINES.md:0-0
Timestamp: 2026-04-03T10:25:08.836Z
Learning: Applies to adapters/**/*.ts : Always provide breakdown labels even when there is only one source/destination of fees. Use source-of-fees labels for `dailyFees` (e.g., 'Swap Fees', 'Borrow Interest'). Use detailed destination labels for `dailyRevenue`/`dailySupplySideRevenue`/`dailyHoldersRevenue` (e.g., 'Swap Fees To LPs', 'Borrow Interest To Treasury')
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:41.566Z
Learning: Applies to fees/**/*.ts : Include integrator and referrer fees in `dailySupplySideRevenue` as supply-side costs in fees adapters
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:41.566Z
Learning: Applies to fees/**/*.ts : Include `dailyRevenue` dimension in fees adapters - maps to Gross Profit and should equal `dailyFees - dailySupplySideRevenue` (what protocol keeps)
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:41.566Z
Learning: Applies to fees/**/*.ts : Use simple source-based labels for `dailyFees` dimension in fees adapters (e.g., 'Borrow Interest', 'Swap Fees', 'Liquidation Fees')
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: GUIDELINES.md:0-0
Timestamp: 2026-04-03T10:25:08.836Z
Learning: Applies to adapters/**/*.ts : Do not use deprecated fields `dailyBribesRevenue` and `dailyTokenTaxes`; put these as sub-sections within `dailyHoldersRevenue` instead
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: GUIDELINES.md:0-0
Timestamp: 2026-04-03T10:25:08.836Z
Learning: For perpetual DEX adapters: track TAKER volume only, do NOT double-count maker+taker volume
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: dexs/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:25.918Z
Learning: Applies to dexs/**/*.ts : Include dailyVolume dimension as a required field in all DEX volume adapters
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: aggregator-derivatives/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:05:47.814Z
Learning: Applies to aggregator-derivatives/**/*.{js,ts,tsx} : Track `dailyVolume` as a required dimension for derivatives aggregators, representing perpetual/derivatives trading volume (TAKER volume only)
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: dexs/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:25.918Z
Learning: Applies to dexs/**/*.ts : Track actual trading volume from swap events in spot DEX implementations
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: bridge-aggregators/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:13.996Z
Learning: Applies to bridge-aggregators/**/[!.]*.ts : Track volume ROUTED through the bridge aggregator, including all cross-chain transfers facilitated, reflecting the value being bridged rather than fees
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: bridge-aggregators/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:13.996Z
Learning: Applies to bridge-aggregators/**/[!.]*.ts : Implement multi-chain indexing to track both source and destination chains for bridge aggregator volume tracking
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: dexs/GUIDELINES.md:0-0
Timestamp: 2026-03-30T12:06:25.918Z
Learning: Applies to dexs/**/*.ts : Track TAKER volume ONLY for perpetual/derivatives - do NOT double count by adding both taker and maker volumes
|
The txflow-perps adapter exports: |
https://app.txflow.com/