@@ -2,6 +2,7 @@ package v1
22
33import (
44 "errors"
5+ "fmt"
56 "math/big"
67
78 sdkmath "cosmossdk.io/math"
@@ -29,33 +30,57 @@ func (a *Asset) Validate() error {
2930 return errors .New ("decimals cannot be negative" )
3031 }
3132
32- if a .BaseAssetDenom == "" {
33- return errors .New ("base_asset_denom cannot be empty" )
33+ if a .ProtoRevPoolRequest . BaseDenom == "" {
34+ return errors .New ("base_denom cannot be empty" )
3435 }
3536
36- if a .QuoteAssetDenom == "" {
37- return errors .New ("quote_asset_denom cannot be empty" )
37+ if err := sdk .ValidateDenom (a .ProtoRevPoolRequest .BaseDenom ); err != nil {
38+ return fmt .Errorf ("invalid base_denom: %w" , err )
39+ }
40+
41+ if a .ProtoRevPoolRequest .OtherDenom == "" {
42+ return errors .New ("other_denom cannot be empty" )
43+ }
44+
45+ if err := sdk .ValidateDenom (a .ProtoRevPoolRequest .OtherDenom ); err != nil {
46+ return fmt .Errorf ("invalid other_denom: %w" , err )
47+ }
48+
49+ if a .ProtoRevPoolRequest .BaseDenom == a .ProtoRevPoolRequest .OtherDenom {
50+ return errors .New ("base_denom and other_denom cannot be the same" )
3851 }
3952
40- if a .BaseAssetDenom == a .QuoteAssetDenom {
41- return errors .New ("base_asset_denom and quote_asset_denom cannot be same" )
53+ if a .SpotPriceRequest .BaseAssetDenom == "" {
54+ return errors .New ("base_asset_denom cannot be empty" )
55+ }
56+
57+ if err := sdk .ValidateDenom (a .SpotPriceRequest .BaseAssetDenom ); err != nil {
58+ return fmt .Errorf ("invalid base_asset_denom: %w" , err )
4259 }
4360
44- if a .Price . IsNil () {
45- return errors .New ("price cannot be nil " )
61+ if a .SpotPriceRequest . QuoteAssetDenom == "" {
62+ return errors .New ("quote_asset_denom cannot be empty " )
4663 }
4764
48- if a . Price . IsNegative () {
49- return errors . New ( "price cannot be negative" )
65+ if err := sdk . ValidateDenom ( a . SpotPriceRequest . QuoteAssetDenom ); err != nil {
66+ return fmt . Errorf ( "invalid quote_asset_denom: %w" , err )
5067 }
5168
52- if a .Price . IsZero () {
53- return errors .New ("price cannot be zero " )
69+ if a .SpotPriceRequest . BaseAssetDenom == a . SpotPriceRequest . QuoteAssetDenom {
70+ return errors .New ("base_asset_denom and quote_asset_denom cannot be the same " )
5471 }
5572
5673 if a .Height < 0 {
5774 return errors .New ("height cannot be negative" )
5875 }
5976
77+ if a .SpotPrice .IsNil () {
78+ return errors .New ("spot_price cannot be nil" )
79+ }
80+
81+ if a .SpotPrice .IsNegative () {
82+ return errors .New ("spot_price cannot be negative" )
83+ }
84+
6085 return nil
6186}
0 commit comments