Skip to content

EVM-16: EvmLargeTransferFilter domain service #155

@Puneethkumarck

Description

@Puneethkumarck

Context

The EVM indexer flags native currency transfers (ETH, MATIC, etc.) above a configurable threshold as "large transfers" for monitoring and analytics. This filter converts wei values to ether and compares against the threshold. It follows the same pattern as the existing Solana LargeTransferFilter — a stateless utility with a static method and a default threshold constant.

Specification

File

prism/src/main/java/com/stablebridge/prism/domain/service/EvmLargeTransferFilter.java

Implementation

public final class EvmLargeTransferFilter {
    private EvmLargeTransferFilter() {}

    /**
     * Default threshold: 1.0 ether (or equivalent native token).
     */
    public static final BigDecimal DEFAULT_THRESHOLD = new BigDecimal("1.0");

    /**
     * Check if a native transfer value (in wei) exceeds the threshold (in ether).
     * Uses strictly greater than comparison.
     *
     * @param valueWei       the transfer value in wei
     * @param thresholdEther the threshold in ether units
     * @return true if the transfer value exceeds the threshold
     */
    public static boolean isLargeTransfer(BigDecimal valueWei, BigDecimal thresholdEther) {
        var valueEther = EvmHex.weiToEther(valueWei.toBigInteger());
        return valueEther.compareTo(thresholdEther) > 0;
    }
}

Design decisions

  • final class with private constructor — stateless utility, same pattern as existing LargeTransferFilter
  • Strictly greater than (> 0) — transfers exactly equal to the threshold are NOT flagged
  • DEFAULT_THRESHOLD is 1.0 ether, configurable via IndexerConfig.LARGE_TRANSFER_THRESHOLD
  • Delegates wei-to-ether conversion to EvmHex.weiToEther() for consistency
  • No framework imports

Test class

prism/src/test/java/com/stablebridge/prism/domain/service/EvmLargeTransferFilterTest.java

Test cases:

  • Value above threshold returns true (e.g., 2.0 ETH with 1.0 threshold)
  • Value exactly at threshold returns false (strictly greater than)
  • Value below threshold returns false (e.g., 0.5 ETH with 1.0 threshold)
  • Zero value returns false
  • Very large value (e.g., 1000 ETH) returns true
  • Custom threshold works (e.g., 10.0 ETH threshold)
  • DEFAULT_THRESHOLD equals new BigDecimal("1.0")

Acceptance Criteria

  • EvmLargeTransferFilter class exists at the specified path
  • isLargeTransfer() correctly compares wei values against ether thresholds
  • Comparison is strictly greater than (not greater-or-equal)
  • DEFAULT_THRESHOLD is 1.0
  • Delegates to EvmHex.weiToEther() for conversion
  • Zero framework imports in domain layer
  • All test cases pass
  • ./gradlew build passes

Dependencies

References

Metadata

Metadata

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions