From 4935c30da9414694e07ebdff48c9c10451ffb66c Mon Sep 17 00:00:00 2001 From: Luke Ma <867273263@qq.com> Date: Fri, 20 Oct 2023 02:07:28 +0800 Subject: [PATCH] fix: CallEVM(addLiquidityETH) wrong parameter call (#1311) * fix wrong addLiquidityETH params * modify unit test params * remove unused package --------- Co-authored-by: Lucas Bertrand --- x/crosschain/keeper/gas_payment_test.go | 6 +++--- x/fungible/keeper/gas_coin_and_pool.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index d15bf96e94..014cc3278d 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -217,7 +217,7 @@ var ( // gasLimit = big.NewInt(21_000) - value used in SetupChainGasCoinAndPool for gas limit initialization withdrawFee uint64 = 1000 gasPrice uint64 = 2 - inputAmount uint64 = 100000 + inputAmount uint64 = 1e16 ) func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { @@ -258,10 +258,10 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { } // total fees must be 21000*2+1000=43000 - // if the input amount of the cctx is 100000, the output amount must be 100000-43000=57000 + // if the input amount of the cctx is 1e16, the output amount must be 1e16-43000=9999999999957000 err = k.PayGasNativeAndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount)) require.NoError(t, err) - require.Equal(t, uint64(57000), cctx.GetCurrentOutTxParam().Amount.Uint64()) + require.Equal(t, uint64(9999999999957000), cctx.GetCurrentOutTxParam().Amount.Uint64()) require.Equal(t, uint64(21_000), cctx.GetCurrentOutTxParam().OutboundTxGasLimit) require.Equal(t, "2", cctx.GetCurrentOutTxParam().OutboundTxGasPrice) }) diff --git a/x/fungible/keeper/gas_coin_and_pool.go b/x/fungible/keeper/gas_coin_and_pool.go index ce725743cb..d33c3ddec6 100644 --- a/x/fungible/keeper/gas_coin_and_pool.go +++ b/x/fungible/keeper/gas_coin_and_pool.go @@ -107,7 +107,7 @@ func (k Keeper) SetupChainGasCoinAndPool( // address to, // uint deadline //) external payable returns (uint amountToken, uint amountETH, uint liquidity); - res, err := k.CallEVM(ctx, *routerABI, types.ModuleAddressEVM, routerAddress, amount, big.NewInt(5_000_000), true, false, + res, err := k.CallEVM(ctx, *routerABI, types.ModuleAddressEVM, routerAddress, amountAZeta, big.NewInt(5_000_000), true, false, "addLiquidityETH", zrc20Addr, amount, BigIntZero, BigIntZero, types.ModuleAddressEVM, amountAZeta) if err != nil { return ethcommon.Address{}, sdkerrors.Wrapf(err, "failed to CallEVM method addLiquidityETH(%s, %s)", zrc20Addr.String(), amountAZeta.String())