Skip to content

Commit

Permalink
chore: add exception handling in amm price query and fix price feeder…
Browse files Browse the repository at this point in the history
… tx issue
  • Loading branch information
kenta-elys committed Nov 24, 2023
1 parent b810796 commit 6e6a7f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ genesis:
priceFeeders:
- feeder: "elys12tzylat4udvjj56uuhu3vj2n4vgp7cf9fwna9w"
is_active: true
- feeder: "elys1v30pe777dj9mgsnlv0j2c5wh05m0ya0nlhuv7t"
is_active: true
prices:
- asset: USDT
price: "1.00"
Expand Down
9 changes: 9 additions & 0 deletions x/amm/client/wasm/query_amm_price_by_denom.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion x/oracle/client/cli/tx_price_feeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 6e6a7f6

Please sign in to comment.