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 return tx, err
} }
toNetwork := h.contractMaker.RPCClient.NetworkManager.Find(hopArgs.ChainID)
if toNetwork == nil {
return tx, err
}
txOpts := hopArgs.ToTransactOpts(signerFn) txOpts := hopArgs.ToTransactOpts(signerFn)
if token.IsNative() { if token.IsNative() {
txOpts.Value = (*big.Int)(hopArgs.Amount) txOpts.Value = (*big.Int)(hopArgs.Amount)
} }
now := time.Now() now := time.Now()
deadline := big.NewInt(now.Unix() + 604800) 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( tx, err = ammWrapper.SwapAndSend(
txOpts, txOpts,
big.NewInt(int64(hopArgs.ChainID)), big.NewInt(int64(hopArgs.ChainID)),
hopArgs.Recipient, hopArgs.Recipient,
hopArgs.Amount.ToInt(), hopArgs.Amount.ToInt(),
hopArgs.BonderFee.ToInt(), hopArgs.BonderFee.ToInt(),
big.NewInt(0), amountOutMin,
deadline,
big.NewInt(0),
deadline, deadline,
destinationAmountOutMin,
destinationDeadline,
) )
return tx, err return tx, err