Conversation
WalkthroughA new Solana adapter module for Meteora DLMM PreStocks computes daily fee and revenue metrics by querying program accounts via RPC, decoding account data to extract positions, fetching per-pool volume history from Meteora's API, and aggregating USD values across three balance buckets. Changes
Sequence DiagramsequenceDiagram
participant Adapter as PreStocks Adapter
participant RPC as Solana RPC
participant API as Meteora API
Adapter->>RPC: getProgramAccounts(METEORA_DLMM_PROGRAM_ID)<br/>with memcmp filter for PRESTOCKS_LP_WALLET
RPC-->>Adapter: Program account data (base64)
loop For each position (with 500ms throttle)
Adapter->>Adapter: Decode base64, extract<br/>public keys via byte offset
Adapter->>API: requestPerPoolVolumeHistory<br/>(startOfDay, endTimestamp)
API-->>Adapter: Pool volume history
Adapter->>Adapter: Select entry matching<br/>startOfDay, aggregate USD
end
Adapter->>Adapter: Aggregate into 3 buckets:<br/>LP fees, protocol fees,<br/>net LP revenue
Adapter-->>Adapter: Return balances object
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
🚥 Pre-merge checks | ✅ 1 | ❌ 5❌ Failed checks (4 warnings, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ 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 prestocks adapter exports: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@fees/prestocks/index.ts`:
- Line 50: The fetch function is using the deprecated v1 signature with unused
parameters (_a, _b) — update async function fetch(_a: any, _b: any, options:
FetchOptions) to the v2 signature async function fetch(options: FetchOptions),
remove the unused parameters and any code that expects the old args, and ensure
any internal references use the single options object; keep the FetchOptions
type and adapter export as-is so the adapter uses the modern signature and can
opt out of isExpensiveAdapter.
- Around line 59-63: The code assumes todaysData exists after
poolData.data.find(...) and will crash if undefined; update the block that calls
todaysData.fees and todaysData.protocol_fees to first check if todaysData is
truthy (from poolData.data.find using options.startOfDay) and handle the missing
case (e.g., skip adding metrics or pass 0 values) before calling
dailyFees.addUSDValue, dailySupplySideRevenue.addUSDValue and
dailyRevenue.addUSDValue so you never dereference an undefined todaysData.
🪄 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: bf3f0562-b673-40b4-913e-df536e6e4b3e
📒 Files selected for processing (1)
fees/prestocks/index.ts
| }); | ||
| } | ||
|
|
||
| async function fetch(_a: any, _b: any, options: FetchOptions) { |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Use the modern adapter signature.
This adapter doesn't have isExpensiveAdapter: true, so it should use the Version 2 signature async function fetch(options: FetchOptions) instead of the deprecated v1 pattern with unused parameters.
♻️ 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 `@fees/prestocks/index.ts` at line 50, The fetch function is using the
deprecated v1 signature with unused parameters (_a, _b) — update async function
fetch(_a: any, _b: any, options: FetchOptions) to the v2 signature async
function fetch(options: FetchOptions), remove the unused parameters and any code
that expects the old args, and ensure any internal references use the single
options object; keep the FetchOptions type and adapter export as-is so the
adapter uses the modern signature and can opt out of isExpensiveAdapter.
There was a problem hiding this comment.
version would be 1 for either its dependent on dune, or some api which provides data once in 24hrs
version can be 2 and still expensive for allium
There was a problem hiding this comment.
@bheluga, thanks for the clarification! You're right — the Version 1 signature is the correct choice here because the Meteora API only returns daily aggregates (not per-timestamp data), making it impossible to use Version 2 even if the adapter isn't flagged as isExpensiveAdapter. I'll retract the suggestion.
✏️ Learnings added
Learnt from: bheluga
Repo: DefiLlama/dimension-adapters PR: 6409
File: fees/prestocks/index.ts:50-50
Timestamp: 2026-04-16T08:57:44.422Z
Learning: Applies to fees/**/*.ts: When an adapter fetches from an external API that only returns daily aggregated data (not filterable by arbitrary timestamps), the Version 1 adapter signature `async function fetch(_a: any, _b: any, options: FetchOptions)` is correct and intentional. Do NOT flag this as deprecated or suggest switching to the Version 2 `(options: FetchOptions)` signature. Version selection is determined by the data source's granularity, not by whether the adapter is marked `isExpensiveAdapter`. For example, the Meteora per-pool volume history API used in `fees/prestocks/index.ts` only provides daily aggregates, justifying Version 1.
Learnt from: bheluga
Repo: DefiLlama/dimension-adapters PR: 6409
File: fees/prestocks/index.ts:50-50
Timestamp: 2026-04-16T08:57:44.422Z
Learning: Applies to dexs/**/*.ts, fees/**/*.ts, open-interest/**/*.ts: The Version 2 adapter signature `(options: FetchOptions)` can still be "expensive" (e.g., Allium queries). Adapter version is NOT determined by whether it is expensive, but by whether the underlying data source supports timestamp-filtered queries. Use Version 1 when the data source (external API, etc.) only returns daily aggregates; use Version 2 when the source supports granular time filtering (on-chain logs, contract calls, subgraphs, Dune/Allium with timestamp filters).
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: bheluga
Repo: DefiLlama/dimension-adapters PR: 6390
File: dexs/txflow-perps/index.ts:5-5
Timestamp: 2026-04-14T11:10:50.312Z
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.
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-04-15T09:34:16.435Z
Learning: Applies to **/adapter.{js,ts} : 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: GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:32:36.613Z
Learning: Use Adapter Version 2 when possible with on-chain logs, contract calls, subgraphs, Dune queries with timestamp filters; use Version 1 only when v2 is not possible with external APIs that only return daily aggregates
Learnt from: CopsLikeDonuts
Repo: DefiLlama/dimension-adapters PR: 6353
File: fees/thorwallet/index.ts:5-7
Timestamp: 2026-04-08T12:11:46.613Z
Learning: In DefiLlama/dimension-adapters, THORWallet (`fees/thorwallet/index.ts`) intentionally omits defensive `|| 0` fallbacks on `parseFloat()` calls. The API endpoint (`https://api-v2-prod.thorwallet.org/defillama/fees`) is purpose-built for this adapter, and the preference is to fail loudly (throw/NaN) rather than silently return zeros when the response shape changes. This is consistent with how other adapters in the repo handle their data sources.
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: options/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:34:12.054Z
Learning: Applies to options/**/*.ts : Avoid double-counting expired options when calculating volume metrics in options adapters
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:32:36.613Z
Learning: Applies to **/*adapters/**/*.{ts,js} : Use `pullHourly: true` wherever EVM logs and Allium queries are used to avoid recomputing data for the same time period and provide more granular data
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: options/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:34:12.054Z
Learning: Applies to options/**/*.ts : If tracking fees/revenue dimensions in options adapters, follow the guidelines defined in `fees/GUIDELINES.md`
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: aggregator-options/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:32:56.336Z
Learning: Applies to aggregator-options/**/*.{js,ts,py,go,java,rs} : Follow fee/revenue tracking guidelines in `fees/GUIDELINES.md` if the aggregator charges fees and this adapter returns fee/revenue dimensions
Learnt from: CopsLikeDonuts
Repo: DefiLlama/dimension-adapters PR: 6353
File: fees/thorwallet/index.ts:35-39
Timestamp: 2026-04-08T11:57:56.597Z
Learning: In DefiLlama/dimension-adapters, THORWallet (`fees/thorwallet/index.ts`) is a **separate protocol** from THORChain and should use `CHAIN.THORWALLET` (not `CHAIN.THORCHAIN`). The DEX adapter at `dexs/thorwallet/index.ts` using `CHAIN.THORCHAIN` is a known legacy inconsistency to be fixed separately. Do not flag `CHAIN.THORWALLET` usage in the fees adapter as incorrect.
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:33:41.050Z
Learning: Applies to fees/**/*.ts : Always provide labels in `.add()` calls even when there is only one source of fees to prevent needing to update and backfill data later when adapter is listed under a parent protocol
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-04-15T09:34:16.435Z
Learning: Applies to **/fees/**/adapter.{js,ts} : 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-04-15T09:33:41.050Z
Learning: Applies to fees/**/*.ts : Include a required `breakdownMethodology` object in TypeScript adapter files documenting all labels used in `.add()` calls, organized by dimension (Fees, Revenue, SupplySideRevenue, HoldersRevenue)
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: dexs/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:33:22.030Z
Learning: Applies to dexs/**/*.ts : Include fees/revenue tracking dimensions (`dailyFees`, `dailyRevenue`, `dailySupplySideRevenue`) when the adapter also tracks fees/revenue, following guidelines in `fees/GUIDELINES.md` with appropriate breakdown labels and `breakdownMethodology`
Learnt from: CopsLikeDonuts
Repo: DefiLlama/dimension-adapters PR: 6353
File: fees/thorwallet/index.ts:18-23
Timestamp: 2026-04-08T11:58:26.321Z
Learning: In DefiLlama/dimension-adapters, THORWallet (`fees/thorwallet/index.ts`) collects only affiliate fees from swaps and perpetual close fees. There are no supply-side parties (no LPs, lenders, stakers, or external integrators), so 100% of collected fees are protocol revenue. `dailyRevenue = dailyFees` is correct and intentional. The `dailyProtocolRevenue` (~45%) and `dailyHoldersRevenue` (~50%) entries represent internal allocations, not cost-of-funds, so `dailySupplySideRevenue` should not be added to this adapter.
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:32:36.613Z
Learning: Applies to **/*adapters/**/*.{ts,js} : Do not use deprecated `dailyBribesRevenue` and `dailyTokenTaxes` fields; put these as sub-sections within `dailyHoldersRevenue` instead
Learnt from: DomCrogan
Repo: DefiLlama/dimension-adapters PR: 6406
File: fees/metronome-synth/index.ts:38-44
Timestamp: 2026-04-15T14:38:48.975Z
Learning: In `fees/metronome-synth/index.ts` (Metronome Synth adapter, DefiLlama/dimension-adapters), VELO rewards received by the protocol's Optimism multisigs from Protocol-Owned Liquidity (POL) positions are correctly classified as `dailyFees`/`dailyRevenue` (protocol revenue), NOT `dailyHoldersRevenue` or supply-side costs. The protocol is the LP itself, so VELO rewards represent yield on the protocol's own capital. The `fromAddressFilter` on EXTRA_INFLOWS entries correctly scopes these inflows to a specific sender (the VELO reward distributor).
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-04-15T09:34:16.435Z
Learning: Applies to **/fees/**/adapter.{js,ts} : For fees adapters: verify that all breakdown labels used in .add() calls have corresponding entries in breakdownMethodology object, and that breakdownMethodology is exported in the adapter
Learnt from: 0xCatalyst
Repo: DefiLlama/dimension-adapters PR: 6355
File: fees/neverland.ts:541-541
Timestamp: 2026-04-14T07:31:51.018Z
Learning: In DefiLlama/dimension-adapters, when adapters build the `FLASHLOAN_FEES` breakdown using the shared Aave V3 helper (`helpers/aave.ts` -> `getPoolFees`), ensure the `FLASHLOAN_FEES` breakdown text/description reflects only the `flashloanPremiumForProtocol` (i.e., the protocol/treasury portion derived from `FLASHLOAN_PREMIUM_TO_PROTOCOL`). Do NOT describe `FLASHLOAN_FEES` as gross flashloan fees or include the LP/lender share, since the LP portion accrues via the Aave liquidity index and is already accounted for in `BORROW_INTEREST`.
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:33:41.050Z
Learning: Applies to fees/**/*.ts : Avoid vague labels in new TypeScript adapters - do not use 'Protocol Fees', 'Fees', 'Revenue', 'Other', or 'Misc' and instead use specific source labels
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:32:36.613Z
Learning: For listing requirements, must provide all required dimensions for the adapter category, and for fees adapters must provide accurate `dailyFees` and `dailyRevenue`
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: open-interest/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:34:04.085Z
Learning: When implementing fee/revenue tracking in open-interest adapters, follow the guidelines in `fees/GUIDELINES.md`
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:33:41.050Z
Learning: Applies to fees/**/*.ts : If the adapter also tracks volume (dexs/ style metrics), follow the volume-specific rules in `dexs/GUIDELINES.md` in addition to fees guidelines
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: fees/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:33:41.050Z
Learning: Applies to fees/**/*.ts : Use clear, descriptive label names in TypeScript adapters - examples: 'Borrow Interest', 'GHO Borrow Interest', 'Liquidation Fees', 'Staking Rewards', 'Borrow Interest To Treasury', 'Borrow Interest To Lenders'
Learnt from: CR
Repo: DefiLlama/dimension-adapters PR: 0
File: bridge-aggregators/GUIDELINES.md:0-0
Timestamp: 2026-04-15T09:33:12.226Z
Learning: Applies to bridge-aggregators/**/bridge-aggregators/**/*.ts : If the bridge aggregator charges fees and the adapter returns fee/revenue dimensions, follow the guidelines in `fees/GUIDELINES.md` and include `dailyFees`, `dailyRevenue`, and `dailySupplySideRevenue` dimensions
|
The prestocks adapter exports: |
https://prestocks.com/