Skip to content
4 changes: 2 additions & 2 deletions dexs/insightx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ const fetch = async (options: FetchOptions) => {

const data: InsightXDailyStats = response;

if (!data || !data.volume) {
if (!data) {
throw new Error(`insightx api returned no volume for ${options.dateString}`);
Comment on lines +31 to 32

@coderabbitai coderabbitai Bot Aug 10, 2026

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the missing-response error message.

This condition rejects only an absent data response. It does not detect a response with no volume. Use an error message such as insightx api returned no response for ${options.dateString} so logs identify the actual failure.

🤖 Prompt for 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.

In `@dexs/insightx/index.ts` around lines 31 - 32, Update the missing-response
error message in the data validation block to state that no response was
returned, using the existing options.dateString context; do not describe the
failure as missing volume because this condition only checks whether data is
absent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

0 volume is a normal occurrence, while the error thrown prevents the process from executing.

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.

@Peipak, agreed. Zero volume is valid and must not fail the fetch.

The current condition permits zero volume. It throws only when the API returns no response. My comment applies only to the error text, which should describe the absent response rather than missing volume.

🐇


✏️ Learnings added
Learnt from: Peipak
Repo: DefiLlama/dimension-adapters PR: 8674
File: dexs/insightx/index.ts:31-32
Timestamp: 2026-08-10T03:29:17.496Z
Learning: In `dexs/insightx/index.ts`, a zero `volume` from the InsightX daily stats API is a valid result and must be recorded as zero without throwing. Only an absent API response is an error.

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: Shaileshkhote
Repo: DefiLlama/dimension-adapters PR: 7173
File: dexs/fulcrom-finance-derivatives.ts:46-52
Timestamp: 2026-05-24T20:51:03.000Z
Learning: In this repository’s adapter fetch functions (e.g., files under `dexs/`), if the subgraph response yields empty arrays or missing entries (such as `volumeStats[0]` / `tradingStats[0]` being `undefined`), do not fall back to returning `0` values. Returning zeros creates incorrect historical chart data. Instead, fail by letting the code throw (or explicitly throw on missing data) so the infrastructure marks the day as unavailable/missing.

Learnt from: Shaileshkhote
Repo: DefiLlama/dimension-adapters PR: 7255
File: dexs/sunperp/index.ts:11-23
Timestamp: 2026-05-27T20:15:23.682Z
Learning: In DefiLlama/dimension-adapters, when a per-contract kline fetch fails inside a PromisePool callback (e.g., in a dexs/*/index.ts adapter), do not catch the error and return a sentinel value like `0`. Returning `0` creates incorrect historical volume data. Instead, let the error propagate so the job infrastructure can mark the corresponding day as unavailable/missing. Follow the repo principle: "no data is better than wrong data."

You are interacting with an AI system.

}

const dailyVolume = options.createBalances();
const dailyFees = options.createBalances();

dailyVolume.addUSDValue(data.volume);
dailyVolume.addUSDValue(data.volume || 0);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
dailyFees.addUSDValue(data.fees || 0);

return {
Expand Down
Loading