Skip to content

docs: add PR description for dedupe of defindex asset amount extracti… - #625

Open
Vivian-04 wants to merge 1 commit into
drydocs:mainfrom
Vivian-04:chore/592-deduplicate-defindex-asset-amount
Open

docs: add PR description for dedupe of defindex asset amount extracti…#625
Vivian-04 wants to merge 1 commit into
drydocs:mainfrom
Vivian-04:chore/592-deduplicate-defindex-asset-amount

Conversation

@Vivian-04

Copy link
Copy Markdown

PR #592
Summary

  • The get_asset_amounts_per_shares first-element extraction is already deduplicated on main.
  • Both buildDefindexWithdrawTx and fetchDefindexPosition already call the shared helper getDefindexAssetAmountPerShares, which owns the parsing logic (Array.isArray(...) && length > 0 ? toBigInt(v[0]) : <fallback>) in exactly one place in defindex.ts (lines 52-54).
  • rate-sources.ts also imports the same helper, so the response parse lives in a single location repo-wide. This was folded in via 5aebacd.
  • The issue's proposed firstAssetAmount(value): bigint (returning 0n on empty) was deliberately not implemented: getDefindexAssetAmountPerShares must keep returning bigint | null, since rate-sources.ts relies on null to signal an unavailable price (see rate-sources.ts lines 315/324). Collapsing the fallback into the helper as 0n would be a behavior change outside the SDK/DeFindex scope.

Acceptance criteria

  • A single shared helper (getDefindexAssetAmountPerShares) already replaces both inline extractions.
  • Existing defindex.test.ts coverage for both call sites passes unchanged (20/20).
  • No behavior change to either function's return value.

Test plan

  • pnpm test — all 9 workspace test tasks pass (incl. defindex.test.ts 20/20)
  • pnpm typecheck — all 8 packages pass
  • pnpm lint — passes
  • pnpm format:check — noted: on this Windows machine it flags 187 files only because core.autocrlf=true converts LF→CRLF on checkout; CI runs on Linux with LF and passes. Not a code issue, no file changes.

Closes #592

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Vivian-04 is attempting to deploy a commit to the Collins' projects Team on Vercel.

A member of the Team first needs to authorize it.

@Vivian-04

Copy link
Copy Markdown
Author

waiting...

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.

[Chore] Deduplicate get_asset_amounts_per_shares extraction in defindex.ts

1 participant