fix_: unblocking the router calculation if an approval is required for the gas estimation

This commit is contained in:
Sale Djenic 2024-05-28 12:29:02 +02:00 committed by saledjenic
parent 74b1dfd694
commit dd7b3d1af8
1 changed files with 8 additions and 1 deletions

View File

@ -216,7 +216,14 @@ func (h *HopBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.N
estimation, err := ethClient.EstimateGas(context.Background(), msg)
if err != nil {
return 0, err
if !token.IsNative() {
// TODO: this is a temporary solution until we find a better way to estimate the gas
// hardcoding the estimation for other than ETH, cause we cannot get a proper estimation without having an approval placed first
// this is an error we're facing otherwise: `execution reverted: ERC20: transfer amount exceeds allowance`
estimation = 350000
} else {
return 0, err
}
}
increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor