IMPORTANT: After completing the task below, you MUST output a JSON object in a [code]…
- User
IMPORTANT: After completing the task below, you MUST output a JSON object in a ```json code fence at the very end of your response. Do NOT forget this — the workflow fails without it.
Implement the current Spectraplex packet.
Follow:
- CLAUDE.md
- design/SPECTRAPLEX_STRATEGY_AND_EXECUTION_PLAN.md
- design/PHASED_IMPLEMENTATION_PLAN.md
Current coordination:
- phase: Phase 3: Expand Silver Into Reusable Datasets
- work packet: P3-W4: Hyperliquid reusable datasets
- objective: Add first-class Silver datasets for Hyperliquid fills, funding payments, and position changes, with materializers and repository methods following the P3-W2/P3-W3 Silver dataset pattern.
- branch: p3-w4-hyperliquid-datasets
- stage: new packet implementation
- existing PR:
Repo touchpoints:
- core/src/materializer.rs
- adapters/src/hyperliquid_parser.rs
- adapters/src/v2_repo.rs
- adapters/src/lib.rs
- migrations/
Implementation steps:
- Define HlFill, HlFundingPayment, and HlPositionChange Silver structs in core/src/materializer.rs following DecodedEvent/TokenTransfer pattern (no wallet-specific fields)
- Add hl_fills, hl_funding_payments, and hl_position_changes migration with IF NOT EXISTS guards and nullable FKs
- Implement extraction functions in adapters/src/hyperliquid_parser.rs for each dataset from Bronze raw_transactions metadata
- Add HlFillMaterializer, HlFundingPaymentMaterializer, and HlPositionChangeMaterializer with unique parser hashes
- Add repository bulk insert and query methods (save/get) in adapters/src/v2_repo.rs
- Export new materializers in adapters/src/lib.rs and add to global hash uniqueness test
- Add comprehensive unit tests for extraction, serialization, and repository query builders
Verification expectations:
- cargo fmt --all --check
- cargo clippy --workspace --all-targets -- -D warnings
- cargo test --workspace (all tests pass, 0 failures)
- Verify all materializer parser hashes remain globally distinct (should reach 13 total)
- Verify Silver structs have no wallet_address or user_id fields
- Verify migrations use IF NOT EXISTS and nullable FKs
- Verify existing evm_logs, blocks, and hl_fills extension tables are untouched
Tracked review artifacts required in the PR:
- No tracked review artifact required.
Outstanding validation or review feedback: No outstanding validation or review feedback.
Assistant
Now let me read the existing patterns and design docs in parallel:
Assistant
Now let me read the v2_repo.rs file fully and check the existing patterns for token_transfers and decoded_events repository methods, plus the existing migration patterns:
Assistant
Now let me read the rest of the v2_repo.rs for the Silver table methods:
Assistant
Now I have a thorough understanding of the existing patterns. Let me also check if the existing hl_fills migration and table is already there (mentioned as an existing extension table):
Assistant
Now I have a thorough understanding of the codebase patterns. Let me implement the P3-W4 work packet. I'll work through each touchpoint systematically.
Let me start with the core structs and migration:
Assistant
Now add the tests for the new structs. I'll add them at the end of the test module:
Assistant
Now create the migration file:
Assistant
Now update
adapters/src/hyperliquid_parser.rswith the extraction functions and materializers:Assistant
Now add the extraction functions and materializers after the existing native balance delta materializer:
Assistant
Now add tests for the new extraction functions and materializers in the same file:
Assistant
Now update
adapters/src/v2_repo.rswith the new Silver table repository methods. First, update the imports:Assistant
Now add the row mapping helpers and query builders. I need to add them after the decoded_events query builder and before the Repository impl:
Assistant
Now add the repository save and query methods to the impl block. I'll add them after the DecodedEvents section:
Assistant
Now add the tests for the new query builders and repository methods at the end of the tests module:
Assistant
Now update
adapters/src/lib.rsto export the new materializers and update the global hash uniqueness test:Assistant
Now update the
all_silver_materializer_descriptors_are_validtest too:Assistant
Now let's run the verification commands:
Assistant
Formatting is clean. Now run clippy:
Assistant
Clippy passes. Now run tests:
Assistant
All tests pass. Let me also verify the key counts and hash totals:
Assistant
Let me also verify the existing hl_fills migration is untouched:
Assistant
No changes to existing extension tables. Let me verify the Silver structs have no wallet_address or user_id fields:
Assistant
All 6 no-wallet-specific-fields tests pass. Let me verify the migration uses IF NOT EXISTS and nullable FKs:
Assistant
20 IF NOT EXISTS guards (3 CREATE TABLE + 17 CREATE INDEX) and 6 FK references (2 per table: raw_transactions and dataset_versions). All FK columns are nullable (UUID type without NOT NULL).
Now let me create the commit. Let me first check git status:
Assistant
Clean working tree, commit successful. Let me get the full SHA:
Assistant
All verifications passed. Here's a summary of what was implemented:
P3-W4: Hyperliquid reusable datasets — Added three first-class Silver datasets for Hyperliquid: