Skip to content

Commit

Permalink
fix: CallEVM(addLiquidityETH) wrong parameter call (#1311)
Browse files Browse the repository at this point in the history
* fix wrong addLiquidityETH params

* modify unit test params

* remove unused package

---------

Co-authored-by: Lucas Bertrand <[email protected]>
  • Loading branch information
lukema95 and lumtis authored Oct 19, 2023
1 parent 161406e commit 4935c30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 4935c30

Please sign in to comment.