fix: improve handling of zero volume on InsightX - #8674
Conversation
Change off-chain adapter to mantle adapter
Resolve the issue where the process cannot be executed due to the error caused by zero transaction volume.
Summary by CodeRabbit
WalkthroughInsightX fetch validation now rejects only absent API responses. Missing or falsy ChangesInsightX volume handling
Estimated code review effort: 2 (Simple) | ~5 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 10 | ❌ 5❌ Failed checks (5 warnings)
✅ Passed checks (10 passed)
✨ Finishing Touches✨ 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 insightx 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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@dexs/insightx/index.ts`:
- Around line 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.
- Line 38: Update the InsightXDailyStats interface to mark volume as optional,
matching the fallback handling in dailyVolume.addUSDValue and the API’s possible
omission of this field.
🪄 Autofix
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 Plus
Run ID: 993f872b-72d8-4c09-b87f-6cd43f5db869
📒 Files selected for processing (1)
dexs/insightx/index.ts
| if (!data) { | ||
| throw new Error(`insightx api returned no volume for ${options.dateString}`); |
There was a problem hiding this comment.
📐 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.
There was a problem hiding this comment.
0 volume is a normal occurrence, while the error thrown prevents the process from executing.
There was a problem hiding this comment.
@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.
|
@Peipak thanks for the PR |
@bheluga The volume is generated by off-chain trading on InsightX platform, and the order operations are signed through smart contract and recorded on the on-chain of Mantle |
Can we get relevant contract addresses on Mantle |
|
hi @Peipak |
|
Hi @g1nt0ki I might not have fully understood what you meant by "bridge address". |
|
@Peipak where do users deposit funds to trade on the platform? |
NOTE
Please enable "Allow edits by maintainers" while putting up the PR.
package.json/package-lock.jsonfile as part of your changesName (to be shown on DefiLlama): InsightX
Twitter Link: https://x.com/InsightXHQ
List of audit links if any:
Website Link: https://app.insightx.finance/
Logo (High resolution, will be shown with rounded borders): https://pbs.twimg.com/profile_images/2056251692086366208/jaRjMLop_400x400.jpg
Current TVL: $10,742.05
Treasury Addresses (if the protocol has treasury) https://mantlescan.xyz/address/0x117420b0c145c60bccb62003414367f9f2384279
Chain: Mantle
Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed): (https://api.coingecko.com/api/v3/coins/list)
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed): (https://api.coinmarketcap.com/data-api/v3/map/all?listing_status=active,inactive,untracked&start=1&limit=10000)
Short Description (to be shown on DefiLlama): InsightX is an AI-native InfoFi prediction market protocol that transforms real-world information, expectations and market signals into tradable, verifiable, and yield-generating on-chain assets.
Token address and ticker if any:
Category (full list at https://defillama.com/categories) *Please choose only one: Prediction Market
Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.):
Implementation Details: Briefly describe how the oracle is integrated into your project:
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
forkedFrom (Does your project originate from another project):
methodology (what is being counted as tvl, how is tvl being calculated):
Github org/user (Optional, if your code is open source, we can track activity): https://github.com/insightx-finance
Does this project have a referral program?