Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [1126](https://github.com/umee-network/umee/pull/1126) Update proto json tag from `APY` to `apy`.
- [1130](https://github.com/umee-network/umee/pull/1130) Update proto json tag to lower case.
- [1140](https://github.com/umee-network/umee/pull/1140) Rename MarketSize query to TotalSuppliedValue, and TokenMarketSize to TotalSupplied.
- [1188](https://github.com/umee-network/umee/pull/1188) Remove all individual queries which duplicate market_summary fields.

### Features

Expand All @@ -71,6 +72,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [1099](https://github.com/umee-network/umee/pull/1099) Added TotalBorrowed query.
- [1157](https://github.com/umee-network/umee/pull/1157) Added `PrintOrErr` util function optimizing the CLI code flow.
- [1159](https://github.com/umee-network/umee/pull/1159) Add `max_supply_utilization` and `min_collateral_liquidity` to the x/leverage token registry.
- [1188](https://github.com/umee-network/umee/pull/1188) Add `liquidity`, `maximum_borrow`, `maximum_collateral`, `minimum_liquidity`, `available_withdraw`, `available_collateralize`, and `utoken_supply` fields to market summary.

### Improvements

Expand Down
4 changes: 2 additions & 2 deletions proto/umee/leverage/v1/leverage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ message Token {
// Exponent is the power of ten by which to multiply, in order to convert
// an amount of the token denoted in its symbol denom to the actual amount
// of its base denom.
uint32 exponent = 11 [(gogoproto.moretags) = "yaml:\"exponent\""];
uint32 exponent = 11 [(gogoproto.moretags) = "yaml:\"exponent\""];

// Enable Msg Supply allows supplying for lending or collateral using this
// token. Note that withdrawing is always enabled. Disabling supplying would
Expand Down Expand Up @@ -156,7 +156,7 @@ message Token {
];

// Max Supply Utilization specifies the maximum supply utilization a token is
// allowed to reach as a direct result of user borrowing. New borrows are not allowed when
// allowed to reach as a direct result of user borrowing. New borrows are not allowed when
// the supply utilization is above `max_supply_utilization`.
// Valid values: 0-1.
string max_supply_utilization = 16 [
Expand Down
270 changes: 63 additions & 207 deletions proto/umee/leverage/v1/query.proto

Large diffs are not rendered by default.

251 changes: 0 additions & 251 deletions x/leverage/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,12 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
GetCmdQueryBorrowedValue(),
GetCmdQuerySupplied(),
GetCmdQuerySuppliedValue(),
GetCmdQueryReserveAmount(),
GetCmdQueryCollateral(),
GetCmdQueryCollateralValue(),
GetCmdQueryExchangeRate(),
GetCmdQuerySupplyAPY(),
GetCmdQueryBorrowAPY(),
GetCmdQueryTotalSuppliedValue(),
GetCmdQueryTotalSupplied(),
GetCmdQueryBorrowLimit(),
GetCmdQueryLiquidationThreshold(),
GetCmdQueryLiquidationTargets(),
GetCmdQueryMarketSummary(),
GetCmdQueryTotalCollateral(),
GetCmdQueryTotalBorrowed(),
)

return cmd
Expand Down Expand Up @@ -224,33 +216,6 @@ func GetCmdQuerySuppliedValue() *cobra.Command {
return cmd
}

// GetCmdQueryReserveAmount creates a Cobra command to query for the
// reserved amount of a specific token.
func GetCmdQueryReserveAmount() *cobra.Command {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of condensing queries, but why remove the specific ones?
Sometimes the user can need only part of that full information '-'

Copy link
Copy Markdown
Contributor Author

@toteki toteki Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but why remove the specific ones?

The idea is to reduce the API surface so there's less to maintain - that said, it's possible that this measure is a bit aggressive. We could keep the specific ones as well as the improved market summary.

edit: Also eliminates the possibility of the queries and the market summary ever being out of sync, and ensures that downstream every use case started with the same data.

The cons are of course doing extra computation when only one thing is needed (might be a gas problem in wasm?) and having to get the specific thing out of a struct field.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could increase the gas consumption if someone doesn't need all those fields, but I don't know if that is a big problem

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part of less to maintain is definitely significant on all sides...

cmd := &cobra.Command{
Use: "reserved [denom]",
Args: cobra.ExactArgs(1),
Short: "Query for the amount reserved of a specified denomination",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryReserveAmount{
Denom: args[0],
}
resp, err := queryClient.ReserveAmount(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdQueryCollateral creates a Cobra command to query for the amount of
// total collateral tokens for a given address.
func GetCmdQueryCollateral() *cobra.Command {
Expand Down Expand Up @@ -313,168 +278,6 @@ func GetCmdQueryCollateralValue() *cobra.Command {
return cmd
}

// GetCmdQueryExchangeRate creates a Cobra command to query for the
// exchange rate of a specific uToken.
func GetCmdQueryExchangeRate() *cobra.Command {
cmd := &cobra.Command{
Use: "exchange-rate [denom]",
Args: cobra.ExactArgs(1),
Short: "Query for the exchange rate of a specified denomination",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryExchangeRate{
Denom: args[0],
}
resp, err := queryClient.ExchangeRate(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdQueryAvailableBorrow creates a Cobra command to query for the
// available amount to borrow of a specific denom.
func GetCmdQueryAvailableBorrow() *cobra.Command {
cmd := &cobra.Command{
Use: "available-borrow [denom]",
Args: cobra.ExactArgs(1),
Short: "Query for the available amount to borrow of a specified denomination",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryAvailableBorrow{
Denom: args[0],
}
resp, err := queryClient.AvailableBorrow(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdQuerySupplyAPY creates a Cobra command to query for the
// supply APY of a specific uToken.
func GetCmdQuerySupplyAPY() *cobra.Command {
cmd := &cobra.Command{
Use: "supply-apy [denom]",
Args: cobra.ExactArgs(1),
Short: "Query for the supply APY of a specified denomination",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QuerySupplyAPY{
Denom: args[0],
}
resp, err := queryClient.SupplyAPY(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdQueryBorrowAPY creates a Cobra command to query for the
// borrow APY of a specific token.
func GetCmdQueryBorrowAPY() *cobra.Command {
cmd := &cobra.Command{
Use: "borrow-apy [denom]",
Args: cobra.ExactArgs(1),
Short: "Query for the borrow APY of a specified denomination",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryBorrowAPY{
Denom: args[0],
}
resp, err := queryClient.BorrowAPY(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdQueryTotalSuppliedValue creates a Cobra command to query for the
// total supply of a specific token.
func GetCmdQueryTotalSuppliedValue() *cobra.Command {
cmd := &cobra.Command{
Use: "total-supplied-value [denom]",
Args: cobra.ExactArgs(1),
Short: "Query for the USD value of the total supply of a specified denomination",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryTotalSuppliedValue{
Denom: args[0],
}
resp, err := queryClient.TotalSuppliedValue(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdQueryTotalSupplied creates a Cobra command to query for the
// Total Supplied of a specific token, measured in base tokens.
func GetCmdQueryTotalSupplied() *cobra.Command {
cmd := &cobra.Command{
Use: "total-supplied [denom]",
Args: cobra.ExactArgs(1),
Short: "Query for the total supply of a specified denomination measured in base tokens",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryTotalSupplied{
Denom: args[0],
}
resp, err := queryClient.TotalSupplied(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdQueryBorrowLimit creates a Cobra command to query for the
// borrow limit of a specific borrower.
func GetCmdQueryBorrowLimit() *cobra.Command {
Expand Down Expand Up @@ -580,57 +383,3 @@ func GetCmdQueryLiquidationTargets() *cobra.Command {

return cmd
}

// GetCmdQueryTotalCollateral creates a Cobra command to query for the
// total collateral amount of a specific token.
func GetCmdQueryTotalCollateral() *cobra.Command {
cmd := &cobra.Command{
Use: "total-collateral [denom]",
Args: cobra.ExactArgs(1),
Short: "Query for the total amount of collateral of a uToken denomination",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryTotalCollateral{
Denom: args[0],
}
resp, err := queryClient.TotalCollateral(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdQueryTotalBorrowed creates a Cobra command to query for the
// total borrowed amount of a specific token.
func GetCmdQueryTotalBorrowed() *cobra.Command {
cmd := &cobra.Command{
Use: "total-borrowed [denom]",
Args: cobra.ExactArgs(1),
Short: "Query for the total amount borrowed of a token denomination",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryTotalBorrowed{
Denom: args[0],
}
resp, err := queryClient.TotalBorrowed(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Loading