From 2dfbe3099a19cbe375ff908827360c7b9d452b53 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Wed, 28 Feb 2024 14:51:52 +0100 Subject: [PATCH] fix: swap and send to l1 --- services/wallet/bridge/hop.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/services/wallet/bridge/hop.go b/services/wallet/bridge/hop.go index c3e33ef63..633191f6e 100644 --- a/services/wallet/bridge/hop.go +++ b/services/wallet/bridge/hop.go @@ -292,22 +292,35 @@ func (h *HopBridge) swapAndSend(chainID uint64, hopArgs *HopTxArgs, signerFn bin return tx, err } + toNetwork := h.contractMaker.RPCClient.NetworkManager.Find(hopArgs.ChainID) + if toNetwork == nil { + return tx, err + } + txOpts := hopArgs.ToTransactOpts(signerFn) if token.IsNative() { txOpts.Value = (*big.Int)(hopArgs.Amount) } now := time.Now() deadline := big.NewInt(now.Unix() + 604800) + amountOutMin := big.NewInt(0) + destinationDeadline := big.NewInt(now.Unix() + 604800) + destinationAmountOutMin := big.NewInt(0) + + if toNetwork.Layer == 1 { + destinationDeadline = big.NewInt(0) + } + tx, err = ammWrapper.SwapAndSend( txOpts, big.NewInt(int64(hopArgs.ChainID)), hopArgs.Recipient, hopArgs.Amount.ToInt(), hopArgs.BonderFee.ToInt(), - big.NewInt(0), - deadline, - big.NewInt(0), + amountOutMin, deadline, + destinationAmountOutMin, + destinationDeadline, ) return tx, err