Skip to content

Commit

Permalink
set 1000 sats as minimum amount that can be withdrawn
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Jun 20, 2024
1 parent 2bb6f7b commit a6e845a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion x/crosschain/keeper/evm_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/zeta-chain/zetacore/cmd/zetacored/config"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/pkg/constant"
"github.com/zeta-chain/zetacore/x/crosschain/types"
fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
Expand Down Expand Up @@ -327,7 +328,7 @@ func ValidateZrc20WithdrawEvent(event *zrc20.ZRC20Withdrawal, chainID int64) err
// The event was parsed; that means the user has deposited tokens to the contract.

if chains.IsBitcoinChain(chainID) {
if event.Value.Cmp(big.NewInt(0)) <= 0 {
if event.Value.Cmp(big.NewInt(constant.BTCWithdrawalDustAmount)) <= 0 {
return fmt.Errorf("ParseZRC20WithdrawalEvent: invalid amount %s", event.Value.String())
}
addr, err := chains.DecodeBtcAddress(string(event.To), chainID)
Expand Down
5 changes: 4 additions & 1 deletion x/crosschain/keeper/evm_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/zeta-chain/zetacore/cmd/zetacored/config"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/constant"
keepertest "github.com/zeta-chain/zetacore/testutil/keeper"
"github.com/zeta-chain/zetacore/testutil/sample"
crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper"
Expand Down Expand Up @@ -169,7 +170,9 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) {
*sample.GetValidZRC20WithdrawToBTC(t).Logs[3],
)
require.NoError(t, err)
btcMainNetWithdrawalEvent.Value = big.NewInt(0)

// 1000 satoshis is the minimum amount that can be withdrawn
btcMainNetWithdrawalEvent.Value = big.NewInt(constant.BTCWithdrawalDustAmount - 1)
err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BitcoinMainnet.ChainId)
require.ErrorContains(t, err, "ParseZRC20WithdrawalEvent: invalid amount")
})
Expand Down

0 comments on commit a6e845a

Please sign in to comment.