diff --git a/plugins/dex/list/hooks.go b/plugins/dex/list/hooks.go index ba979cf71..a6ea005fc 100644 --- a/plugins/dex/list/hooks.go +++ b/plugins/dex/list/hooks.go @@ -45,6 +45,10 @@ func (hooks ListHooks) OnProposalSubmitted(ctx sdk.Context, proposal gov.Proposa return errors.New("quote asset symbol should not be empty") } + if listParams.BaseAssetSymbol == listParams.QuoteAssetSymbol { + return errors.New("base token and quote token should not be the same") + } + if listParams.InitPrice <= 0 { return errors.New("init price should larger than zero") } diff --git a/plugins/dex/list/hooks_test.go b/plugins/dex/list/hooks_test.go index 6c4214d2e..1b5ed716e 100644 --- a/plugins/dex/list/hooks_test.go +++ b/plugins/dex/list/hooks_test.go @@ -84,6 +84,28 @@ func TestQuoteAssetEmpty(t *testing.T) { require.Contains(t, err.Error(), "quote asset symbol should not be empty") } +func TestEqualBaseAssetAndQuoteAsset(t *testing.T) { + hooks := NewListHooks(nil, nil) + + listParams := gov.ListTradingPairParams{ + BaseAssetSymbol: "BNB", + QuoteAssetSymbol: "BNB", + } + + listParamsBz, err := json.Marshal(listParams) + require.Nil(t, err, "marshal list params error") + + proposal := gov.TextProposal{ + ProposalType: gov.ProposalTypeListTradingPair, + Description: string(listParamsBz), + } + + err = hooks.OnProposalSubmitted(sdk.Context{}, &proposal) + require.NotNil(t, err, "err should not be nil") + + require.Contains(t, err.Error(), "base token and quote token should not be the same") +} + func TestWrongPrice(t *testing.T) { hooks := NewListHooks(nil, nil)