Skip to content

Commit

Permalink
Fix open position counter, Remove extra arg from show-portfolio (#652)
Browse files Browse the repository at this point in the history
* set open position count

* remove extra arg from show-portfolio
  • Loading branch information
amityadav0 authored Jul 15, 2024
1 parent f38140f commit d6a3881
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 153 deletions.
3 changes: 1 addition & 2 deletions proto/elys/tier/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ service Query {

// Queries a list of Portfolio items.
rpc Portfolio (QueryGetPortfolioRequest) returns (QueryGetPortfolioResponse) {
option (google.api.http).get = "/elys-network/elys/membershiptier/portfolio/{user}/{assetType}";
option (google.api.http).get = "/elys-network/elys/membershiptier/portfolio/{user}";

}
rpc PortfolioAll (QueryAllPortfolioRequest) returns (QueryAllPortfolioResponse) {
Expand Down Expand Up @@ -89,7 +89,6 @@ message QueryParamsResponse {

message QueryGetPortfolioRequest {
string user = 1;
string assetType = 2;
}

message QueryGetPortfolioResponse {
Expand Down
4 changes: 4 additions & 0 deletions x/leveragelp/migrations/v7_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ func (m Migrator) V7Migration(ctx sdk.Context) error {
m.keeper.DeletePoolPosIdsLiquidationSorted(ctx, pool.AmmPoolId)
m.keeper.DeletePoolPosIdsStopLossSorted(ctx, pool.AmmPoolId)
}
openCount := uint64(0)
for _, position := range positions {
m.keeper.SetSortedLiquidationAndStopLoss(ctx, position)
openCount++
}

m.keeper.SetOpenPositionCount(ctx, openCount)

// Liquidate <1.1 positions
// Q: What will happen if there won't be enough liquidity to return to users(as health for some positions must be below 1) ? Do we need to fill the pool ?
for _, pool := range pools {
Expand Down
8 changes: 3 additions & 5 deletions x/tier/client/cli/query_portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func CmdListPortfolio() *cobra.Command {

func CmdShowPortfolio() *cobra.Command {
cmd := &cobra.Command{
Use: "show-portfolio [user] [asset-type]",
Use: "show-portfolio [user]",
Short: "shows a portfolio",
Args: cobra.ExactArgs(2),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
Expand All @@ -58,11 +58,9 @@ func CmdShowPortfolio() *cobra.Command {
queryClient := types.NewQueryClient(clientCtx)

argUser := args[0]
argType := args[1]

params := &types.QueryGetPortfolioRequest{
User: argUser,
AssetType: argType,
User: argUser,
}

res, err := queryClient.Portfolio(cmd.Context(), params)
Expand Down
3 changes: 1 addition & 2 deletions x/tier/keeper/query_portfolio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ func TestPortfolioQuerySingle(t *testing.T) {
// TODO: update, should be empty
desc: "KeyNotFound",
request: &types.QueryGetPortfolioRequest{
User: strconv.Itoa(100000),
AssetType: strconv.Itoa(100000),
User: strconv.Itoa(100000),
},
err: status.Error(codes.NotFound, "not found"),
},
Expand Down
189 changes: 68 additions & 121 deletions x/tier/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d6a3881

Please sign in to comment.