fix: swap and send to l1

This commit is contained in:
Anthony Laibe 2024-02-28 14:51:52 +01:00 committed by Anthony Laibe
parent e1c7c715aa
commit 2dfbe3099a
1 changed files with 16 additions and 3 deletions

View File

@ -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