From 6e6a7f65a0b1064fffb720415b6bdfcb95690e39 Mon Sep 17 00:00:00 2001 From: kenta-elys Date: Fri, 24 Nov 2023 07:54:20 +0000 Subject: [PATCH] chore: add exception handling in amm price query and fix price feeder tx issue --- config.yml | 2 ++ x/amm/client/wasm/query_amm_price_by_denom.go | 9 +++++++++ x/oracle/client/cli/tx_price_feeder.go | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config.yml b/config.yml index dbd473a71..d45b68926 100644 --- a/config.yml +++ b/config.yml @@ -419,6 +419,8 @@ genesis: priceFeeders: - feeder: "elys12tzylat4udvjj56uuhu3vj2n4vgp7cf9fwna9w" is_active: true + - feeder: "elys1v30pe777dj9mgsnlv0j2c5wh05m0ya0nlhuv7t" + is_active: true prices: - asset: USDT price: "1.00" diff --git a/x/amm/client/wasm/query_amm_price_by_denom.go b/x/amm/client/wasm/query_amm_price_by_denom.go index e20c2c206..08bd0c465 100644 --- a/x/amm/client/wasm/query_amm_price_by_denom.go +++ b/x/amm/client/wasm/query_amm_price_by_denom.go @@ -17,6 +17,15 @@ func (oq *Querier) queryAmmPriceByDenom(ctx sdk.Context, query *ammtypes.QueryAM return nil, errorsmod.Wrapf(aptypes.ErrAssetProfileNotFound, "denom: %s", denom) } + // If amount is zero + if query.TokenIn.Amount.IsZero() { + responseBytes, err := json.Marshal(sdk.ZeroDec()) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize in route by denom response") + } + return responseBytes, nil + } + // uses asset profile denom usdcDenom := assetProfile.Denom diff --git a/x/oracle/client/cli/tx_price_feeder.go b/x/oracle/client/cli/tx_price_feeder.go index 4f027b724..8d95e58b5 100644 --- a/x/oracle/client/cli/tx_price_feeder.go +++ b/x/oracle/client/cli/tx_price_feeder.go @@ -21,7 +21,7 @@ func CmdSetPriceFeeder() *cobra.Command { return err } - isActive, err := strconv.ParseBool(args[1]) + isActive, err := strconv.ParseBool(args[0]) if err != nil { return err }