diff --git a/mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs b/mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs index 992e053951..b8aa3aaf71 100644 --- a/mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs +++ b/mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs @@ -18,6 +18,15 @@ use web3::types::TransactionId; const ETH_MAKER_PAYMENT: &str = "ethMakerPayment"; const ERC20_MAKER_PAYMENT: &str = "erc20MakerPayment"; +/// state index for `MakerPayment` structure from `EtomicSwapMakerV2.sol` +/// +/// struct MakerPayment { +/// bytes20 paymentHash; +/// uint32 paymentLockTime; +/// MakerPaymentState state; +/// } +const MAKER_PAYMENT_STATE_INDX: usize = 2; + struct MakerPaymentArgs { taker_address: Address, taker_secret_hash: [u8; 32], @@ -127,7 +136,7 @@ impl EthCoin { Token::FixedBytes(swap_id.clone()), &MAKER_SWAP_V2, EthPaymentType::MakerPayments, - 2, + MAKER_PAYMENT_STATE_INDX, ) .await?; diff --git a/mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs b/mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs index 997cce1eb5..621d9df743 100644 --- a/mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs +++ b/mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs @@ -21,6 +21,16 @@ const ETH_TAKER_PAYMENT: &str = "ethTakerPayment"; const ERC20_TAKER_PAYMENT: &str = "erc20TakerPayment"; const TAKER_PAYMENT_APPROVE: &str = "takerPaymentApprove"; +/// state index for `TakerPayment` structure from `EtomicSwapTakerV2.sol` +/// +/// struct TakerPayment { +/// bytes20 paymentHash; +/// uint32 preApproveLockTime; +/// uint32 paymentLockTime; +/// TakerPaymentState state; +/// } +const TAKER_PAYMENT_STATE_INDX: usize = 3; + struct TakerFundingArgs { dex_fee: U256, payment_amount: U256, @@ -147,7 +157,7 @@ impl EthCoin { Token::FixedBytes(swap_id.clone()), &TAKER_SWAP_V2, EthPaymentType::TakerPayments, - 3, + TAKER_PAYMENT_STATE_INDX, ) .await?; @@ -220,7 +230,7 @@ impl EthCoin { decoded[0].clone(), &TAKER_SWAP_V2, EthPaymentType::TakerPayments, - 3, + TAKER_PAYMENT_STATE_INDX, ) .await ); @@ -371,7 +381,7 @@ impl EthCoin { decoded[0].clone(), // id from takerPaymentApprove &TAKER_SWAP_V2, EthPaymentType::TakerPayments, - 3, + TAKER_PAYMENT_STATE_INDX, ) .await .map_err(|e| SearchForFundingSpendErr::Internal(ERRL!("{}", e)))?; @@ -403,7 +413,7 @@ impl EthCoin { decoded[0].clone(), &TAKER_SWAP_V2, EthPaymentType::TakerPayments, - 3, + TAKER_PAYMENT_STATE_INDX, ) .await ); @@ -446,7 +456,7 @@ impl EthCoin { decoded[0].clone(), // id from spendTakerPayment &TAKER_SWAP_V2, EthPaymentType::TakerPayments, - 3, + TAKER_PAYMENT_STATE_INDX, ) .await?; if taker_status == U256::from(TakerPaymentStateV2::MakerSpent as u8) {