diff --git a/services/wallet/bridge/transfer.go b/services/wallet/bridge/transfer.go index e7ee157cc..fc66add39 100644 --- a/services/wallet/bridge/transfer.go +++ b/services/wallet/bridge/transfer.go @@ -87,12 +87,36 @@ func (s *TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwork *par func (s *TransferBridge) BuildTx(network *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int) (*ethTypes.Transaction, error) { toAddr := types.Address(toAddress) + if strings.EqualFold(token.Symbol, "ETH") { + sendArgs := &TransactionBridge{ + TransferTx: &transactions.SendTxArgs{ + From: types.Address(fromAddress), + To: &toAddr, + Value: (*hexutil.Big)(amountIn), + Data: types.HexBytes("0x0"), + }, + ChainID: network.ChainID, + } + + return s.BuildTransaction(sendArgs) + } + abi, err := abi.JSON(strings.NewReader(ierc20.IERC20ABI)) + if err != nil { + return nil, err + } + input, err := abi.Pack("transfer", + toAddress, + amountIn, + ) + if err != nil { + return nil, err + } sendArgs := &TransactionBridge{ TransferTx: &transactions.SendTxArgs{ From: types.Address(fromAddress), To: &toAddr, - Value: (*hexutil.Big)(amountIn), - Data: types.HexBytes("0x0"), + Value: (*hexutil.Big)(big.NewInt(0)), + Data: input, }, ChainID: network.ChainID, } diff --git a/services/wallet/router.go b/services/wallet/router.go index 9cd444113..9d7024811 100644 --- a/services/wallet/router.go +++ b/services/wallet/router.go @@ -99,6 +99,10 @@ func (s SendType) isTransfer() bool { return s == Transfer || s.IsCollectiblesTransfer() } +func (s SendType) needL1Fee() bool { + return s != ENSRegister && s != ENSRelease && s != ENSSetPubKey && s != StickersBuy +} + func (s SendType) isAvailableBetween(from, to *params.Network) bool { if s.IsCollectiblesTransfer() { return from.ChainID == to.ChainID @@ -713,13 +717,16 @@ func (r *Router) suggestedRoutes( continue } - tx, err := bridge.BuildTx(network, addrFrom, addrTo, token, amountIn) - if err != nil { - continue - } + var l1GasFeeWei uint64 = 0 + if sendType.needL1Fee() { + tx, err := bridge.BuildTx(network, addrFrom, addrTo, token, amountIn) + if err != nil { + continue + } - l1GasFeeWei, _ := r.s.feesManager.getL1Fee(ctx, network.ChainID, tx) - l1GasFeeWei += l1ApprovalFee + l1GasFeeWei, _ = r.s.feesManager.getL1Fee(ctx, network.ChainID, tx) + l1GasFeeWei += l1ApprovalFee + } gasFees.L1GasFee = weiToGwei(big.NewInt(int64(l1GasFeeWei))) requiredNativeBalance := new(big.Int).Mul(gweiToWei(maxFees), big.NewInt(int64(gasLimit)))