Skip to content

Conversation

@skushagra9
Copy link
Collaborator

@skushagra9 skushagra9 commented Aug 29, 2025

🚀 feat: Complete VUSD Mint Adapter & Core Engine Fixes

🔧 New VUSD Mint Adapter

  • Created vusd-mint.ts adapter to track Mint events with full metadata capture
  • Added example configuration vusd-mint.absinthe.json for Ethereum mainnet
  • Integrated VUSD token pricing via Vesper VDollar CoinGecko feed

🏗️ Dual Sink Architecture

  • Implemented API Sink for production Absinthe API integration
  • Configured proper batching and error handling for API submissions

⚙️ Transaction Processing Fixes

  • Fixed transaction data capture by adding transaction: true to log subscriptions
  • Enhanced event processing to include gasUsed, gasPrice, from/to fields (previously incorrect)
  • Resolved transaction context extraction for complete gas fee analysis
  • Added proper logIndex handling for event ordering (previously incorrect)

💰 Pricing & ValueUSD Resolution

  • Fixed valueUSD calculations with robust price lookup mechanisms (previously incorrect for txn events)
  • Integrated ETH pric for gas fee USD calculations

📊 Time-Weighted Balance Schema Refinement

  • Updated balance key structure: bal:{asset}:{user}:{contractAddress}
  • Fixed contract-specific window processing and isolation
  • Improved window cleanup and state management per contract

🔄 Configuration Enhancements

  • Enhanced block range handling (if toBlock = 0, it would continue till the latest block)
  • Streamlined environment variable loading (for absintheApiClient)

🛠️ Core Engine Improvements

  • Fixed contract address normalization (consistent lowercase)
  • Enhanced asset discovery with automatic Redis tracking
  • Improved multi-contract support with proper isolation

📈 Event Enrichment Pipeline

(done because we don't have startTs and endTs for txn events, we can make it a single function in future)

Added enrichEventsWithAssetPrice for asset price resolution

  • Purpose: Calculates USD value for each event's asset amount
  • Process:
    • Fetches asset metadata (decimals) from cache
    • Converts raw amount to display amount using decimals
    • Queries Redis time-series for asset price at event timestamp
    • Implements fallback to last known price if exact timestamp unavailable
    • Sets displayAmount and valueUsd fields on events

Added enrichEventsWithGasPricing for gas fee USD calculations

  • Purpose: Calculates transaction gas costs in USD for comprehensive cost analysis

  • Process:

    • Uses WETH address (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) as gas token
    • Fetches ETH price from Redis at transaction timestamp
    • Calculates: gasFeeWei = gasPrice × gasUsed
    • Converts: gasFeeNative = gasFeeWei ÷ 10^18 (Wei to ETH)
    • Final: gasFeeUsd = gasFeeNative × ethPrice
    • Sets gasFeeUsd field on events
  • Enhanced buildEvents with eventName field and proper timestamp handling

  • Improved cleanup pipeline for API-ready data formatting

🔍 Data Structure Fixes

  • Added base field to RawEvent interface for enriched data
  • Enhanced event metadata with complete transaction context
  • Fixed field sanitization before API submission
  • Improved type consistency across processing pipeline

📝 Important Note: Asset Configuration Requirement
Token Address vs Contract Address Clarification:
Required: VUSD token address (0x677ddbd918637E5F2c79e164D402454dE7dA8619) must be explicitly configured in main.ts and feed config
Why: The pricing engine needs the actual token address to fetch metadata (decimals, symbol) for proper amount calculations
Previous confusion: Initially attempted using the minting contract address, which doesn't contain token metadata
Recommendation: This pattern should be better documented as it's not immediately obvious that token addresses (not contract addresses) are required for asset configuration
This distinction is crucial for proper decimal handling and price resolution in the enrichment pipeline.

…rocessing

- Introduced new project 'ichi' for Hemi staking protocol.
- Implemented BatchProcessor for handling staking events and maintaining time-weighted balances.
- Added GraphQL schema definitions for ActiveBalances and PoolProcessState.
- Integrated with Absinthe API for data transmission and crash recovery.
- Established database models and utility functions for managing active balances and process state.
- Included token metadata for supported tokens and helper functions for balance management.
- Updated ioredis to version 5.7.0 in package.json and pnpm-lock.yaml.
- Added @types/ioredis as a development dependency.
- Introduced a new file emain.ts for handling balance updates and event processing using Redis.
- Modified processor.ts to include temporary configurations for the Hemi staking protocol.
- Reformatted code for better readability by adjusting indentation and spacing.
- Enhanced the constructor and method definitions for clarity.
- Updated comments for better understanding of the logic and flow.
- Maintained existing functionality while improving overall code organization.
- Added PositionToggle type to TwbAdapter for future event handling.
- Implemented indexPriceData method for price data indexing.
- Introduced enrichers for processing time-weighted balance events.
- Updated onEvent method to include positionToggle handling.
- Improved comments and todos for better clarity and future development.
- Introduced Price and PriceStore types for managing price data.
- Added PriceProvider interface for computing prices on cache misses.
- Implemented PriceService class for retrieving or computing prices.
- Updated TwbAdapter and TwbEngine to accommodate new price handling logic.
- Improved enrichers for processing time-weighted balance events with clearer structure and comments.
- Enhanced overall code readability and organization.
…clarity

- Added comments to clarify the purpose of methods and logic within the run function.
- Introduced backfillPriceDataForBatch method for more efficient price data backfilling.
- Updated existing comments and todos for better readability and future development.
- Removed the indexPriceData method and adjusted related logic to streamline processing.
- Enhanced overall structure and organization of the TwbEngine class.
… and event processing

- Updated TwbAdapter methods to return Promises for better asynchronous handling.
- Refactored priceAsset method to accept timestamp and asset directly.
- Improved flushPeriodic logic to handle final block and backfilling scenarios more efficiently.
- Enhanced enrichers to properly compute time-weighted averages for price data.
- Added file system logging for enriched windows data.
- Cleaned up comments and todos for clarity and future development.
…prove data handling and fixed pricing bug when no data was in the last bucket (uses last known value)
…richers, including new event types and improved data structure for protocol metadata
…on ingestion in Engine with gas fee analysis
…enhancing data processing and metadata handling
@skushagra9 skushagra9 changed the base branch from andrew/eng-2009 to develop-new August 30, 2025 21:19
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