Skip to content

fix(defi-portfolio-scanner): correct HODLMM pool detection for current API shape#614

Open
gregoryford963-sys wants to merge 1 commit into
BitflowFinance:mainfrom
gregoryford963-sys:fix/defi-portfolio-scanner-hodlmm-detection
Open

fix(defi-portfolio-scanner): correct HODLMM pool detection for current API shape#614
gregoryford963-sys wants to merge 1 commit into
BitflowFinance:mainfrom
gregoryford963-sys:fix/defi-portfolio-scanner-hodlmm-detection

Conversation

@gregoryford963-sys
Copy link
Copy Markdown

Fixes #613.

What broke and why

scanBitflow() never detected any HODLMM positions due to four field-name mismatches between the scanner code and the current Bitflow API response shape.

Changes

1. Pools response key: resultsdata

The /api/app/v1/pools endpoint returns { data: [...], hasMore, nextCursor }. The scanner read pools?.results, which is undefined, so poolList was always [] and the per-pool bins query never executed.

- const poolList = Array.isArray(pools) ? pools : pools?.results ?? [];
+ const poolList = Array.isArray(pools) ? pools : pools?.data ?? pools?.results ?? [];

2. Pool ID field: poolId (camelCase)

Each pool object uses poolId, not id or pool_id.

- const poolId = pool.id ?? pool.pool_id ?? pool.name ?? "unknown";
+ const poolId = pool.poolId ?? pool.id ?? pool.pool_id ?? pool.name ?? "unknown";

3. Token symbols: pool.tokens.tokenX/Y.symbol

Current API nests symbols under tokens.tokenX.symbol / tokens.tokenY.symbol.

- const tokenA = pool.token_a_symbol ?? pool.tokenASymbol ?? pool.token0 ?? "?";
- const tokenB = pool.token_b_symbol ?? pool.tokenBSymbol ?? pool.token1 ?? "?";
+ const tokenA = pool.tokens?.tokenX?.symbol ?? pool.token_a_symbol ?? pool.tokenASymbol ?? pool.token0 ?? "?";
+ const tokenB = pool.tokens?.tokenY?.symbol ?? pool.token_b_symbol ?? pool.tokenBSymbol ?? pool.token1 ?? "?";

4. Hiro fallback filter: add "dlmm"

DLMM pool token contracts (SM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD.dlmm-pool-stx-usdcx-v-1-bps-10::pool-token) contain "dlmm" but not "bitflow" or "hodlmm", so the safety-net fallback silently skipped them.

- (lowerTokenId.includes("bitflow") || lowerTokenId.includes("hodlmm")) &&
+ (lowerTokenId.includes("bitflow") || lowerTokenId.includes("hodlmm") || lowerTokenId.includes("dlmm")) &&

Test plan

  • Run scan --address <address-with-dlmm-lp> and confirm protocols.bitflow.positions is non-empty
  • Confirm tokenA/tokenB show correct symbols (e.g. STX / USDCx) instead of "?"
  • Run against an address with no HODLMM positions — confirm positions: [] still returned cleanly
  • Run summary — confirm protocolBreakdown.Bitflow HODLMM shows non-zero estimatedUsd for active LP holders

🤖 Generated with Claude Code

…t API shape

The Bitflow /pools endpoint returns { data: [...] } but scanBitflow read
pools?.results, which is always undefined, so poolList was always empty
and the per-pool bins query never ran.

Three additional field-name mismatches with the current API response:
- Pool ID is poolId (camelCase), not id or pool_id
- Token symbols live at pool.tokens.tokenX/Y.symbol, not token_a/b_symbol
- DLMM pool token contracts contain "dlmm" in the contract name, not
  "bitflow" or "hodlmm", so the Hiro fallback filter silently skipped them

Fixes BitflowFinance#613

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

✅ Validation Passed

Skill: defi-portfolio-scanner
Errors: 0
Warnings: 0

All checks passed. This submission is ready for review.

@gregoryford963-sys
Copy link
Copy Markdown
Author

Hey @diegomey — CI is green, fixes #613. Four targeted field-name corrections to align scanBitflow() with the current Bitflow API response shape. Happy to adjust anything before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

defi-portfolio-scanner: HODLMM positions never detected (pools API key mismatch + fallback filter gap)

1 participant