feat(positions): add --defi flag with grouped DeFi view#77
Merged
Conversation
Shorthand for --positions defi that returns a richer response grouped by dapp -> group_id -> tokens. Loans net against deposits in per-protocol totals. LP positions sharing a group_id collapse into a single pool row. Pretty output adds position_type badges colored by polarity: deposit/staked green, loan red, reward yellow, locked cyan. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Describes the new --defi shorthand on `zerion positions`, the protocol/ group_id rollup, loan-netting in net_value vs gross_value, and the conflicting_flags error. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--defiflag onzerion positions— shorthand for--positions defiplus a DeFi-aware JSON shape (protocols[] → groups[] → tokens[]) grouped by dapp.group_idcollapse into a single pool entry. Loans are netted against deposits in per-protocol totals so the displayed value matches what the user "actually owns."[position_type]badges colored by polarity: deposit/staked green, loan red, reward yellow, locked cyan.API mapping
Uses the existing
filter[positions]=only_complexroute. Enrichment pullsprotocol,protocol_module,position_type,group_id,pool_address, andapplication_metadatafrom each position's attributes.Output shape (
--defi, JSON){ "wallet": {...}, "filter": "defi", "summary": { "total_value": 4200, "gross_value": 4500, "protocols": 2, "positions": 4 }, "protocols": [ { "dapp": "Aave V3", "module": "lending", "net_value": 3700, "groups": [ { "position_type": "deposit", "value": 4000, "tokens": [...] }, { "position_type": "loan", "value": 300, "tokens": [...] } ]} ] }Conflict handling
--defi --positions all|simple→conflicting_flagserror.--defi --positions defiis fine (treated as the same intent).Test plan
npm test— 173 unit tests pass (6 new forformatDefiPositions)node cli/zerion.js positions vitalik.eth --defi --pretty— manual smokenode cli/zerion.js positions <addr> --defi --chain ethereum— chain filter still appliesnode cli/zerion.js positions <addr> --defi --positions all— verify conflict error--positions defi --prettyoutput to confirm grouping reads better🤖 Generated with Claude Code