Skip to content

Commit

Permalink
actually include any non-zero redeem gas estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed Feb 16, 2023
1 parent 74554b5 commit ba8b9fa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/asset/eth/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,9 @@ type gasEstimate struct {
// IF the redeem asset is a fee-family asset. Otherwise Redeem and RedeemAdd
// are zero.
dexeth.Gases
// Additional fields are based on live estimates of the swap.
// Additional fields may be based on live estimates of the swap. Both oneGas
// and nGas will include both swap and redeem gas, but note that the redeem
// gas may be zero if the redeemed asset is not ETH or an ETH token.
oneGas, nGas, nSwap, nRedeem uint64
}

Expand All @@ -1412,14 +1414,16 @@ func (w *assetWallet) initGasEstimate(n int, initVer, redeemVer, redeemAssetID u
return nil, fmt.Errorf("error calculating swap gas: %w", err)
}

est.oneGas = est.Swap + est.Redeem
est.nGas = est.nSwap + est.nRedeem
est.oneGas = est.Swap
est.nGas = est.nSwap

if redeemW := w.wallet(redeemAssetID); redeemW != nil {
est.Redeem, est.nRedeem, err = redeemW.redeemGas(n, redeemVer)
if err != nil {
return nil, fmt.Errorf("error calculating fee-family redeem gas: %w", err)
}
est.oneGas += est.Redeem
est.nGas += est.nRedeem
}

return
Expand Down

0 comments on commit ba8b9fa

Please sign in to comment.