Skip to content

Conversation

@codyborn
Copy link

@codyborn codyborn commented Nov 13, 2025

Overview

This PR implements full support for ERC20ETH as an input token across all chains in Artemis. ERC20ETH is an ERC20 wrapper for native ETH that uses ERC-7914 for smart wallet compatibility. When Artemis receives an order with ERC20ETH as the input, we normalize it to native ETH (zero address) since that's what we'll receive during the callback.

ERC20ETH Address (all chains): 0x00000000e20E49e6dCeE6e8283A0C090578F0fb9

Key Changes

  1. Added ERC20ETH constant and normalization functions (src/shared.rs)

    • Added ERC20ETH_ADDRESS constant
    • Implemented normalize_erc20eth_to_native() for string-based token addresses
    • Implemented normalize_erc20eth_to_native_address() for Address type token addresses
  2. Updated route collection (src/collectors/uniswapx_route_collector.rs)

    • Modified resolve_address() to normalize ERC20ETH to "ETH" for the Uniswap routing API
  3. Updated order batching (3 strategy files)

    • src/strategies/priority_strategy.rs - Normalize token_in in get_order_batch()
    • src/strategies/dutchv3_strategy.rs - Normalize token_in in get_order_batches()
    • src/strategies/uniswapx_strategy.rs - Normalize token_in in get_order_batches()
  4. Updated transaction building (src/strategies/shared.rs)

    • Normalize token_in in build_fill() before use
    • Updated get_tokens_to_approve() to skip approval for ERC20ETH (treated as native ETH)

Files Modified

  • src/shared.rs - Added constant and helper functions, added tests
  • src/collectors/uniswapx_route_collector.rs - Updated resolve_address(), added tests
  • src/strategies/priority_strategy.rs - Updated get_order_batch(), added test
  • src/strategies/dutchv3_strategy.rs - Updated get_order_batches()
  • src/strategies/uniswapx_strategy.rs - Updated get_order_batches()
  • src/strategies/shared.rs - Updated build_fill() and get_tokens_to_approve()

Testing

  • Unit Tests: Added 15 comprehensive tests covering:
    • Normalization functions with various address formats (lowercase, uppercase, mixed case)
    • Route collection address resolution
    • Order batching normalization
    • All tests pass ✅

Design Decisions

  1. Early Normalization: ERC20ETH is normalized to native ETH during order batching, ensuring all downstream code receives the normalized address
  2. Case-Insensitive Matching: Uses eq_ignore_ascii_case() for robust address comparison
  3. Multiple Normalization Points: Defensive approach with normalization at order batching, route collection, and transaction building
  4. No Output Token Handling: ERC20ETH will never be an output token (swappers receive ETH directly), so no normalization needed for token_out

Backward Compatibility

✅ Fully backward compatible - only adds new handling without changing existing behavior for other tokens.

@codyborn codyborn merged commit fc4149b into main Nov 14, 2025
4 checks passed
@codyborn codyborn deleted the erc20_eth branch November 14, 2025 17:39
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