Skip to content

[fix] dln - take the day from options.dateString - #11451

Merged
bheluga merged 1 commit into
DefiLlama:masterfrom
takinanton:fix-dln-utc-date
Nov 29, 2026
Merged

bheluga merged 1 commit into
DefiLlama:masterfrom
takinanton:fix-dln-utc-date

Conversation

@takinanton

Copy link
Copy Markdown
Contributor

fees/dln formats the day for the deBridge stats and treasury requests with getFullYear, getMonth and getDate so the date follows the machine timezone. With TZ=America/New_York pnpm test fees dln 2026-11-25 ethereum,solana asks the API for 2026-11-23 and shows 1.75 k on ethereum and 3.60 k in total while the day it should report has 2.53 k and 4.33 k. I dropped the local formatter and pass options.dateString instead. Now the same command prints 2.53 k and 4.33 k under New York and Tokyo as well as UTC. The UTC output did not change so no refill is needed.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary by CodeRabbit

  • Bug Fixes
    • Date-based revenue lookups and prefetching now use the specified date value directly, avoiding differences caused by local calendar date formatting.

Walkthrough

The DLN prefetch and fetchHoldersRevenue functions now use options.dateString for daily queries. The local date-formatting helpers were removed.

Changes

DLN date selection

Layer / File(s) Summary
Use the supplied date for daily queries
fees/dln/index.ts
prefetch uses options.dateString for the daily statistics query. fetchHoldersRevenue uses it for the reserves query and returned-date matching. The local date-formatting helpers were removed.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Suggested labels: fees, bug-fix

Suggested reviewers: bheluga

Merge Risk: Minimal · up to c3dbd

DLN daily fee queries now use the supplied date string instead of the machine's local date, so results no longer vary with timezone. No concrete merge-blocking issue was found. Whether past values from non-UTC runs need a refill depends on operational data outside the repository.

Pre-merge checks: Passed 14

Check name Status Explanation
Title check Passed The title "[fix] dln - take the day from options.dateString" follows the required [type] protocol-name - description format. It names the protocol (dln), the type (fix), and the main change (using opt…
Description check Passed The description explains the bug, the timezone-dependent date formatting that caused it, and the fix that passes options.dateString. It gives a reproduction command, before and after outputs under sev…
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 The check applies to fees adapters. The only changed file is fees/dln/index.ts (a fees adapter). The PR diff only changes the date source: both prefetch and fetchHoldersRevenue now use `options.da…
Income Statement Compliance Passed The check applies to fees adapters, and this PR changes one fees adapter, fees/dln/index.ts. The diff is limited to the date source. prefetch and fetchHoldersRevenue now use options.dateString i…
Version 2 Required Passed The check requires version: 2 for new adapters. It exempts updates to an existing v1 adapter. This PR changes one file, fees/dln/index.ts (M status, no added files). The fees/dln/index.ts file already…
Pullhourly Required For Version 2 Passed The check applies only to adapters with version: 2. It requires those adapters to set pullHourly explicitly. The changed file is fees/dln/index.ts, the only file in the PR diff. Its exported ada…
Dune Adapters Are Version 1 Passed The check applies only to adapters that query Dune (queryDuneSql, queryDune, or dune helpers). The changed file, fees/dln/index.ts, is the only file in the PR. It imports only Adapter types, CHAIN hel…
Income Statement Balance Passed The check applies to fees adapters. The only changed file is fees/dln/index.ts (one file, +2/-13). The diff replaces the local-timezone date formatter with options.dateString in prefetch and fetchHold…
Fetchoptions Usage Passed The check covers FetchOptions usage in fetch functions. The only changed file is fees/dln/index.ts (+2/-13). Evidence from the diff and the file: - Signatures: ***REDACTED_SECRET_ASSIGNMENT*** is a sing…
Adapter Shape Passed The check asks for one chainConfig object (per-chain entries with a start key) passed as adapter: chainConfig, read through chainConfig[options.chain], rather than separate chains, start, and …
Efficiency And Error Handling Passed The pull request changes one file, fees/dln/index.ts (+2/-13). It removes the local pad and formatTimestampAsDate helpers and passes options.dateString to the deBridge stats and treasury request…
Methodology Keys Passed The check applies to the methodology object keys. The PR changes only fees/dln/index.ts, and the diff does not touch the methodology object (lines 89-94 in the post-change file). The existing keys…
Full details: Title check

Explanation

The title "[fix] dln - take the day from options.dateString" follows the required [type] protocol-name - description format. It names the protocol (dln), the type (fix), and the main change (using options.dateString for the day). It matches the changeset, which replaces local date formatting in prefetch and fetchHoldersRevenue with options.dateString.

Full details: Description check

Explanation

The description explains the bug, the timezone-dependent date formatting that caused it, and the fix that passes options.dateString. It gives a reproduction command, before and after outputs under several timezones, and a note that UTC output did not change so no refill is needed. It does not use the repository template, which asks for a NOTE about maintainer edits, adapter links, and listing form fields. These sections apply to new protocol listings, though, so omitting them is acceptable for a bug fix.

Full details: Breakdown Methodology Check

Explanation

The check applies to fees adapters. The only changed file is fees/dln/index.ts (a fees adapter). The PR diff only changes the date source: both prefetch and fetchHoldersRevenue now use options.dateString instead of a local-timezone formatter (formatTimestampAsDate, pad) that was removed. Breakdown labels: the file has no .add() calls in either the base or the head revision, so there are no breakdown labels to match against breakdownMethodology. The label condition is satisfied vacuously. Export: the file has no breakdownMethodology object, and it has no export of one. The adapter exports only methodology (Fees, Revenue, ProtocolRevenue, HoldersRevenue). This gap already exists in the base revision. The PR does not add, remove, or change any breakdown-related code, so it does not introduce this condition. No failure condition in the check is introduced by this PR. Reviewers may still want to add a breakdownMethodology export in a later change, but that is outside this PR's scope.

Full details: Income Statement Compliance

Explanation

The check applies to fees adapters, and this PR changes one fees adapter, fees/dln/index.ts. The diff is limited to the date source. prefetch and fetchHoldersRevenue now use options.dateString instead of a local-timezone formatter. The diff does not change any income-statement field: - dailyFees, dailyUserFees, dailyRevenue, dailyProtocolRevenue, and dailyHoldersRevenue keep the same formulas. - No dailySupplySideRevenue field is added or changed. - The methodology text is unchanged. The PR changes which day's data is requested. It does not change how fees are classified as gross fees, protocol revenue, or supplier-side revenue. The current code sets dailyRevenue equal to dailyFees, which does not match the check's conceptual model of Gross Profit. That mapping predates this PR and the PR does not change or activate it, so it cannot cause a FAIL here. No explicit failure condition from the check is introduced by this change.

Full details: Version 2 Required

Explanation

The check requires version: 2 for new adapters. It exempts updates to an existing v1 adapter. This PR changes one file, fees/dln/index.ts (M status, no added files). The fees/dln/index.ts file already exists at the base ref, so this is not a new adapter. The adapter exports version: 1 at both base and head, and the diff does not touch the version export. The exemption for updating an existing v1 adapter applies, so the check passes. The PR is not a new adapter, so no version: 2 requirement is triggered.

Full details: Pullhourly Required For Version 2

Explanation

The check applies only to adapters with version: 2. It requires those adapters to set pullHourly explicitly. The changed file is fees/dln/index.ts, the only file in the PR diff. Its exported adapter declares version: 1 (line 97 in the reviewed head, line 108 in the base). The PR does not change the version. A version: 2 search and a pullHourly search of fees/dln/ both returned no matches. The check therefore does not apply to this adapter, and the PR introduces no violation.

Full details: Dune Adapters Are Version 1

Explanation

The check applies only to adapters that query Dune (queryDuneSql, queryDune, or dune helpers). The changed file, fees/dln/index.ts, is the only file in the PR. It imports only Adapter types, CHAIN helpers, and fetchURL. Its prefetch and fetchHoldersRevenue functions call the deBridge stats API and the deBridge treasury API directly. A search of the file for "dune" finds no matches. The check is therefore inapplicable to this PR. The adapter already exports version: 1, so it also meets the version rule if the check were applicable.

Full details: Income Statement Balance

Explanation

The check applies to fees adapters. The only changed file is fees/dln/index.ts (one file, +2/-13). The diff replaces the local-timezone date formatter with options.dateString in prefetch and fetchHoldersRevenue. It does not change any returned value or accounting field. The fetch() return object is unchanged: dailyFees = dailyUserFees = dailyRevenue = the summed totalProtocolFeeUsd, dailyProtocolRevenue is dailyFees before 2025-06-20 and '0' after, and dailyHoldersRevenue is the Solana buyback amount. The PR does not change how these values are computed. It only changes which calendar day is queried. The dailyFees = dailyRevenue + dailySupplySideRevenue relationship is not affected by the change. Pre-existing observations, not introduced by this PR: the adapter sets no dailySupplySideRevenue, and after 2025-06-20 dailyRevenue can differ from dailyProtocolRevenue + dailyHoldersRevenue on non-Solana chains. These behaviors predate the diff. Under the decision contract, unchanged behavior cannot cause a FAIL unless the PR activates or worsens it, and this PR does not. No new imbalance is introduced.

Full details: Fetchoptions Usage

Explanation

The check covers FetchOptions usage in fetch functions. The only changed file is fees/dln/index.ts (+2/-13). Evidence from the diff and the file: - Signatures: ***REDACTED_SECRET_ASSIGNMENT*** is a single argument, and this is a v1 adapter. The 3-argument v1 signature is not present. - Date handling: the diff replaces the local-timezone helper formatTimestampAsDate(options.startOfDay) with options.dateString in prefetch and fetchHoldersRevenue. This moves away from recomputing a date from a raw timestamp. dateString is a defined member of FetchOptions (adapters/types.ts:48). - Unused arguments: options is used in every changed function. No new unused arguments appear. - Timestamp field: the fetch result has dailyFees, dailyUserFees, dailyRevenue, dailyProtocolRevenue, and dailyHoldersRevenue. No timestamp field is returned. - v2 windows: the adapter is v1, so the startOfDay vs startTimestamp rule for v2 does not apply. options.startTimestamp is already used at line 76 and is unchanged. The PR introduces no violation of the stated conditions. The removed pad and formatTimestampAsDate helpers are not referenced elsewhere in the file. The change is a fix that follows the check's preferred option usage.

Full details: Adapter Shape

Explanation

The check asks for one chainConfig object (per-chain entries with a start key) passed as adapter: chainConfig, read through chainConfig[options.chain], rather than separate chains, start, and config structures. The file fees/dln/index.ts already follows this shape. Lines 5-38 define chainConfig: Record&lt;Chain, { chainId: number, start: string }&gt; with a start on every entry. Line 99 sets adapter: chainConfig. Line 69 reads chainConfig[options.chain].chainId. The PR diff only replaces the local formatTimestampAsDate helper with options.dateString in prefetch and fetchHoldersRevenue, and removes the pad and formatTimestampAsDate helpers. It does not change the adapter declaration, the chain list, or the start values. The PR therefore introduces no adapter-shape violation. The check is not affected by this change.

Full details: Efficiency And Error Handling

Explanation

The pull request changes one file, fees/dln/index.ts (+2/-13). It removes the local pad and formatTimestampAsDate helpers and passes options.dateString to the deBridge stats and treasury requests. None of the flagged patterns appear in the changed code: - No getLogs calls, so no noTarget or post-filtering concern. - No raw topics and no event ABI changes. - No loops of single api.call. The code uses fetchURL for HTTP requests, which the check does not cover. - No try/catch blocks. - No new hardcoded rates, addresses, or magic numbers. The chain config, the 1750550400 buyback timestamp (which has a comment), and the startDate=2024-01-01 URL parameter were all present before this change and are unchanged. - No allowNegativeValue usage. The removed code also contained none of the flagged patterns. The check therefore does not fail on this change.

Full details: Methodology Keys

Explanation

The check applies to the methodology object keys. The PR changes only fees/dln/index.ts, and the diff does not touch the methodology object (lines 89-94 in the post-change file). The existing keys are Fees, Revenue, ProtocolRevenue, and HoldersRevenue. All four are dimension display names, not code field names such as dailyFees. The PR therefore introduces no methodology key violation.

Finishing Touches

Simplify code

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f4ee546 and c3dbded.

Files selected for processing: 1

  • fees/dln/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@bheluga
bheluga merged commit e520bdd into DefiLlama:master Nov 29, 2026
1 check passed
@bheluga

bheluga commented Nov 29, 2026

Copy link
Copy Markdown
Member

@takinanton thanks for the PR

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