Skip to content

test(eth): add SafeERC20 V1 USDT support and docker tests#2711

Open
shamardy wants to merge 2 commits intodevfrom
feat/safeerc20-v1-tests
Open

test(eth): add SafeERC20 V1 USDT support and docker tests#2711
shamardy wants to merge 2 commits intodevfrom
feat/safeerc20-v1-tests

Conversation

@shamardy
Copy link
Collaborator

@shamardy shamardy commented Feb 3, 2026

Summary

  • Update V1 swap contract bytecode and ABI with SafeERC20 support
  • Add docker tests for USDT V1 swaps

Fixes #408

Changes

Contract Updates

  • Update swap_contract_bytes with SafeERC20 V1 contract (OpenZeppelin 5.4.0)
  • Update swap_contract_abi.json to match simplified V1 contract (ETH/ERC20 only, NFT functions removed)

Test Infrastructure

  • Add usdt_contract_bytes and usdt_abi.json for USDT testing
  • Add USDT deployment and funding helpers in eth.rs

New Docker Tests (V1 swaps)

  • send_and_spend_usdt_maker_payment_legacy_gas_policy
  • send_and_spend_usdt_maker_payment_priority_fee
  • send_and_refund_usdt_maker_payment_legacy_gas_policy
  • send_and_refund_usdt_maker_payment_priority_fee
  • test_usdt_get_token_info

Why SafeERC20?

USDT's transfer/transferFrom don't return a boolean. The old code used require(token.transferFrom(...)) which fails because Solidity tries to decode a non-existent return value. SafeERC20 handles this correctly.

Related

- Update swap_contract_bytes and ABI for SafeERC20 V1 contract
  (compiled with OpenZeppelin 5.4.0)
- Add USDT contract bytecode and ABI for testing
- Add docker tests for USDT swaps (taker spend, maker refund)
- Add docker tests for ERC20 decimal handling (6, 8, 18 decimals)
- Update test helpers for USDT deployment and funding

The SafeERC20 changes enable USDT and other non-standard ERC20 tokens
that don't return bool from transfer/transferFrom.

Related: GLEECBTC/etomic-swap#11

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Fixes clippy::test_attr_in_doctest warning introduced in newer Rust.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@shamardy shamardy changed the title feat(eth): add SafeERC20 V1 USDT support and docker tests test(eth): add SafeERC20 V1 USDT support and docker tests Feb 3, 2026
Copy link
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will want to update the coins file and add the number of decimals to USDT-ERC20?

time_lock,
other_pubkey: &taker_pubkey,
secret_hash,
amount: BigDecimal::from_str("10").unwrap(), // 10 USDT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't go along with the comment above (1 = 0.000001 USDT)
amount of 10 should mean 0.00001 USDT in this case.

}

fn send_and_refund_usdt_maker_payment_impl(swap_txfee_policy: SwapGasFeePolicy) {
thread::sleep(Duration::from_secs(10));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there a 10-second sleep before any logic is even executed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants