Fix memoless amount reference extraction when pool decimals are unset & Add ERC-20 memoless swap simulation

Summary

This MR fixes memoless amount-based reference extraction for non-gas assets when pool.Decimals is unset (0), which could produce incorrect reference IDs and cause valid memoless swaps to be refunded.

Root cause

For non-gas assets, ExtractReferenceFromAmount reads pool.Decimals. When pool.Decimals == 0, the old logic treated it as literal 0-decimal precision and applied an extra / 1e8 normalization before modulo extraction.

In EVM token flows, 0 is used as a sentinel for THOR default precision (1e8), not literal 0 decimals. That mismatch caused wrong refs (e.g. for 626500002 amount, expected 00002, extracted 00006) and failed memo resolution.

Fix

  • In ExtractReferenceFromAmount, for non-gas assets:
    • map pool.Decimals == 0 to THORChainDecimals (8)
    • skip erroneous extra normalization
    • preserve existing behavior for explicit decimals <8 and for gas assets

Added Tests

  • Added unit test for zero pool-decimal handling:
    • amount=626500002 now extracts 00002 (expected)
  • Also added simulation updates to broaden memoless swap coverage (including ERC20 token flows and non-8 decimal assets).
  • Existing memoless decimal precision tests continue to pass.

Test plan

  • make test passes
  • make lint passes
  • make test-simulation passes

Merge request reports

Loading
Loading