Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CallEVM(addLiquidityETH) wrong parameter call #1311

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions x/crosschain/keeper/gas_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion x/fungible/keeper/gas_coin_and_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading