Skip to content

Commit

Permalink
Add gas price to gas estimation request on ETH/ERC20 withdraw #643
Browse files Browse the repository at this point in the history
  • Loading branch information
artemii235 committed May 21, 2020
1 parent 584397d commit 96c3641
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mm2src/coins/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use futures01::Future;
use futures01::future::{Either as Either01};
use futures::compat::Future01CompatExt;
use futures::future::{Either, FutureExt, join_all, select, TryFutureExt};
use futures::{try_join};
use gstuff::slurp;
use http::StatusCode;
// #[cfg(test)]
Expand Down Expand Up @@ -373,17 +372,19 @@ async fn withdraw_impl(ctx: MmArc, coin: EthCoin, req: WithdrawRequest) -> Resul
},
Some(_) => return ERR!("Unsupported input fee type"),
None => {
let gas_price_fut = coin.get_gas_price().compat();
let gas_price = try_s!(coin.get_gas_price().compat().await);
let estimate_gas_req = CallRequest {
value: Some(eth_value),
data: Some(data.clone().into()),
from: Some(coin.my_address),
to: call_addr,
gas: None,
gas_price: None,
// gas price must be supplied because some smart contracts base their
// logic on gas price, e.g. TUSD: https://github.com/KomodoPlatform/atomicDEX-API/issues/643
gas_price: Some(gas_price),
};
let gas_fut = coin.web3.eth().estimate_gas(estimate_gas_req, None).map_err(|e| ERRL!("{}", e)).compat();
try_s!(try_join!(gas_fut, gas_price_fut))
(try_s!(gas_fut.await), gas_price)
}
};
let total_fee = gas * gas_price;
Expand Down

0 comments on commit 96c3641

Please sign in to comment.