Skip to content

Increase defi coverage#23

Open
jpsains wants to merge 24 commits intomainfrom
increase-defi-coverage
Open

Increase defi coverage#23
jpsains wants to merge 24 commits intomainfrom
increase-defi-coverage

Conversation

@jpsains
Copy link
Copy Markdown
Collaborator

@jpsains jpsains commented Apr 14, 2026

Note

Medium Risk
Touches core categorization heuristics and protocol labeling, which can change user-visible transaction types/readables across multiple DeFi protocols; tests/fixtures reduce risk but coverage changes may cause unexpected recategorization.

Overview
Improves DeFi coverage in tx-categorize by adding new actions (COLLECT, MODIFY_LIQUIDITY + multi-asset variants) and wiring them into heuristic detection (new methodId/topicHash rules and additional contract determinants for Uniswap V3/V4, Curve pools, Convex reward/stake/claim, Aave staking, and MetaMask pooled staking).

Normalizes protocol/version attribution and toAddressName mappings (e.g., collapsing *_Vx protocols into a base protocol with version metadata for 0x/1inch/Paraswap/Uniswap/Aave/ENS/Tornado/MetaMask Bridge), updates/extends fixtures + test cases, and hardens snapshot tests (CI-default nock lockdown, skip empty hashes, and avoid circular AxiosError rethrows).

Reviewed by Cursor Bugbot for commit ce18731. Bugbot is set up for automated code reviews on this repo. Configure here.

@jpsains jpsains requested a review from a team as a code owner April 14, 2026 12:54
Comment thread packages/tx-categorize/src/txSchemas/evmCompatible.ts Outdated
Comment thread packages/tx-categorize/src/localization/locales/en/translation.json Outdated
Comment thread packages/tx-categorize/src/txSchemas/heuristicMap.ts Outdated
Copy link
Copy Markdown
Contributor

@blurpesec blurpesec left a comment

Choose a reason for hiding this comment

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

Can you add example txs for each tx type to the test-cases https://github.com/MetaMask/tx-categorize/blob/main/packages/tx-categorize/src/testCases.mock.ts

so that we maintain coverage in tests and can guarantee tx categorizations don't conflict?

@jpsains jpsains requested a review from blurpesec April 14, 2026 14:01
Comment thread packages/tx-categorize/src/txSchemas/heuristicMap.ts Outdated
Comment thread packages/tx-categorize/src/localization/locales/ko/translation.json
Comment thread packages/tx-categorize/src/txSchemas/heuristicMap.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ce18731. Configure here.

if (action === Action.WITHDRAW && receivedAssets.length > 1) return Action.WITHDRAW_MULTI
if (action === Action.COLLECT && receivedAssets.length > 1) return Action.COLLECT_MULTI
if (action === Action.MODIFY_LIQUIDITY && sentAssets.length >= 2) return Action.MODIFY_LIQUIDITY_MULTI_SENT
if (action === Action.MODIFY_LIQUIDITY && receivedAssets.length >= 2) return Action.MODIFY_LIQUIDITY_MULTI_RECV
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Inconsistent threshold style in multi-asset refinement checks

Low Severity

The MODIFY_LIQUIDITY checks use >= 2 while every other multi-asset check in refineActionForMultiAssets uses > 1. Although logically equivalent for integer lengths, this breaks the consistent style established by EXCHANGE, DEPOSIT, WITHDRAW, and COLLECT checks — all of which use > 1. Using a different comparison form for the same semantic intent increases cognitive load when reading and maintaining this function.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ce18731. Configure here.

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.

3 participants