From 47717bc0f0630245b936afa4836317f68b6c86d3 Mon Sep 17 00:00:00 2001 From: Amit Yadav Date: Mon, 15 Jul 2024 18:24:24 +0530 Subject: [PATCH] [Tier]: Add query to get consolidated price (#650) * add consolidated price function * resp proto * fix typo * handle zero lev amount --- docs/static/openapi.yml | 219 +++++--- proto/elys/tier/query.proto | 14 + x/leveragelp/keeper/position_close.go | 21 +- x/tier/client/cli/query.go | 2 + .../cli/query_get_consolidated_price.go | 46 ++ x/tier/keeper/hooks_amm.go | 6 +- x/tier/keeper/hooks_perpetual.go | 14 +- x/tier/keeper/hooks_stable_stake.go | 4 +- x/tier/keeper/hooks_staking.go | 2 +- x/tier/keeper/msg_server_set_portfolio.go | 2 +- x/tier/keeper/portfolio.go | 34 +- x/tier/keeper/portfolio_test.go | 6 +- x/tier/keeper/query_get_consolidated_price.go | 27 + x/tier/keeper/query_leverage_lp_total.go | 2 +- x/tier/keeper/query_liquid_total.go | 2 +- x/tier/keeper/query_perpetual.go | 2 +- x/tier/keeper/query_rewards_total.go | 2 +- x/tier/keeper/query_staked_pool.go | 2 +- x/tier/types/errors.go | 3 +- x/tier/types/query.pb.go | 506 +++++++++++++++--- x/tier/types/query.pb.gw.go | 101 ++++ 21 files changed, 854 insertions(+), 163 deletions(-) create mode 100644 x/tier/client/cli/query_get_consolidated_price.go create mode 100644 x/tier/keeper/query_get_consolidated_price.go diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 53505c8e7..8618b2cf5 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -41525,43 +41525,51 @@ paths: items: type: object properties: - address: - type: string - collateral: + position: type: object properties: - denom: - type: string - amount: + address: type: string - description: >- - Coin defines a token with a denomination and an amount. + collateral: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. - NOTE: The amount field is an Int which implements the - custom method + NOTE: The amount field is an Int which implements + the custom method - signatures required by gogoproto. - liabilities: - type: string - title: For recording - interest_paid: - type: string - title: For recording - leverage: - type: string - title: For recording - leveraged_lp_amount: - type: string - position_health: - type: string - id: - type: string - format: uint64 - amm_pool_id: + signatures required by gogoproto. + liabilities: + type: string + title: For recording + interest_paid: + type: string + title: For recording + leverage: + type: string + title: For recording + leveraged_lp_amount: + type: string + position_health: + type: string + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + stop_loss_price: + type: string + interest_rate_hour: type: string - format: uint64 - stop_loss_price: + interest_rate_hour_usd: type: string pagination: type: object @@ -44999,6 +45007,40 @@ paths: format: int32 tags: - Query + /elys-network/elys/tier/get_consolidated_price/{denom}: + get: + summary: Queries a list of GetConsolidatedPrice items. + operationId: ElysTierGetConsolidatedPrice + responses: + '200': + description: A successful response. + schema: + type: object + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: denom + in: path + required: true + type: string + tags: + - Query /elys-network/elys/tier/leverage_lp_total/{user}: get: summary: Queries a list of LeverageLpTotal items. @@ -87207,6 +87249,54 @@ definitions: format: uint64 stop_loss_price: type: string + elys.leveragelp.PositionAndInterest: + type: object + properties: + position: + type: object + properties: + address: + type: string + collateral: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + liabilities: + type: string + title: For recording + interest_paid: + type: string + title: For recording + leverage: + type: string + title: For recording + leveraged_lp_amount: + type: string + position_health: + type: string + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + stop_loss_price: + type: string + interest_rate_hour: + type: string + interest_rate_hour_usd: + type: string elys.leveragelp.PositionResponse: type: object properties: @@ -87333,43 +87423,50 @@ definitions: items: type: object properties: - address: - type: string - collateral: + position: type: object properties: - denom: - type: string - amount: + address: type: string - description: >- - Coin defines a token with a denomination and an amount. + collateral: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Int which implements the custom - method + NOTE: The amount field is an Int which implements the custom + method - signatures required by gogoproto. - liabilities: - type: string - title: For recording - interest_paid: - type: string - title: For recording - leverage: - type: string - title: For recording - leveraged_lp_amount: - type: string - position_health: - type: string - id: - type: string - format: uint64 - amm_pool_id: + signatures required by gogoproto. + liabilities: + type: string + title: For recording + interest_paid: + type: string + title: For recording + leverage: + type: string + title: For recording + leveraged_lp_amount: + type: string + position_health: + type: string + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + stop_loss_price: + type: string + interest_rate_hour: type: string - format: uint64 - stop_loss_price: + interest_rate_hour_usd: type: string pagination: type: object @@ -89555,6 +89652,8 @@ definitions: properties: total: type: string + elys.tier.QueryGetConsolidatedPriceResponse: + type: object elys.tier.QueryGetPortfolioResponse: type: object properties: diff --git a/proto/elys/tier/query.proto b/proto/elys/tier/query.proto index e8ed19bfd..a15eeeabb 100644 --- a/proto/elys/tier/query.proto +++ b/proto/elys/tier/query.proto @@ -70,6 +70,12 @@ service Query { option (google.api.http).get = "/elys-network/elys/tier/get_amm_price/{denom}/{decimal}"; } + + // Queries a list of GetConsolidatedPrice items. + rpc GetConsolidatedPrice (QueryGetConsolidatedPriceRequest) returns (QueryGetConsolidatedPriceResponse) { + option (google.api.http).get = "/elys-network/elys/tier/get_consolidated_price/{denom}"; + + } } // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} @@ -158,3 +164,11 @@ message QueryGetAmmPriceResponse { string total = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; } +message QueryGetConsolidatedPriceRequest { + string denom = 1; +} + +message QueryGetConsolidatedPriceResponse { + string price = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + diff --git a/x/leveragelp/keeper/position_close.go b/x/leveragelp/keeper/position_close.go index a5082ee18..312e3e52c 100644 --- a/x/leveragelp/keeper/position_close.go +++ b/x/leveragelp/keeper/position_close.go @@ -12,15 +12,26 @@ func (k Keeper) ForceCloseLong(ctx sdk.Context, position types.Position, pool ty return sdk.ZeroInt(), types.ErrInvalidCloseSize } + // Old debt + oldDebt := k.stableKeeper.GetDebt(ctx, position.GetPositionAddress()) + + if position.LeveragedLpAmount.IsZero() { + err := k.masterchefKeeper.ClaimRewards(ctx, position.GetPositionAddress(), []uint64{position.AmmPoolId}, sdk.AccAddress(position.Address)) + if err != nil { + return sdk.ZeroInt(), err + } + err = k.DestroyPosition(ctx, position.Address, position.Id, oldDebt.Borrowed.Add(oldDebt.InterestStacked).Sub(oldDebt.InterestPaid)) + if err != nil { + return sdk.ZeroInt(), err + } + } + // Exit liquidity with collateral token exitCoins, err := k.amm.ExitPool(ctx, position.GetPositionAddress(), position.AmmPoolId, lpAmount, sdk.Coins{}, position.Collateral.Denom) if err != nil { return sdk.ZeroInt(), err } - // Old debt - oldDebt := k.stableKeeper.GetDebt(ctx, position.GetPositionAddress()) - // Repay with interest debt := k.stableKeeper.UpdateInterestStackedByAddress(ctx, position.GetPositionAddress()) @@ -75,12 +86,12 @@ func (k Keeper) ForceCloseLong(ctx sdk.Context, position types.Position, pool ty if err != nil { return sdk.ZeroInt(), err } - err = k.DestroyPosition(ctx, position.Address, position.Id, oldDebt.Borrowed.Add(debt.InterestStacked).Sub(debt.InterestPaid)) + err = k.DestroyPosition(ctx, position.Address, position.Id, oldDebt.Borrowed.Add(oldDebt.InterestStacked).Sub(oldDebt.InterestPaid)) if err != nil { return sdk.ZeroInt(), err } } else { - k.SetPosition(ctx, &position, oldDebt.Borrowed.Add(debt.InterestStacked).Sub(debt.InterestPaid)) + k.SetPosition(ctx, &position, oldDebt.Borrowed.Add(oldDebt.InterestStacked).Sub(oldDebt.InterestPaid)) } // Hooks after leveragelp position closed diff --git a/x/tier/client/cli/query.go b/x/tier/client/cli/query.go index b16f327b6..ed18b08c2 100644 --- a/x/tier/client/cli/query.go +++ b/x/tier/client/cli/query.go @@ -41,6 +41,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdGetAmmPrice()) + cmd.AddCommand(CmdGetConsolidatedPrice()) + // this line is used by starport scaffolding # 1 return cmd diff --git a/x/tier/client/cli/query_get_consolidated_price.go b/x/tier/client/cli/query_get_consolidated_price.go new file mode 100644 index 000000000..51c67219c --- /dev/null +++ b/x/tier/client/cli/query_get_consolidated_price.go @@ -0,0 +1,46 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/elys-network/elys/x/tier/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdGetConsolidatedPrice() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-consolidated-price [denom]", + Short: "Query get-consolidated-price", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqDenom := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetConsolidatedPriceRequest{ + + Denom: reqDenom, + } + + res, err := queryClient.GetConsolidatedPrice(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/tier/keeper/hooks_amm.go b/x/tier/keeper/hooks_amm.go index d5a697fad..029b571b7 100644 --- a/x/tier/keeper/hooks_amm.go +++ b/x/tier/keeper/hooks_amm.go @@ -12,18 +12,18 @@ func (k Keeper) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId // AfterJoinPool is called after JoinPool, JoinSwapExternAmountIn, and JoinSwapShareAmountOut func (k Keeper) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount math.Int) { - k.RetreiveAllPortfolio(ctx, sender.String()) + k.RetrieveAllPortfolio(ctx, sender.String()) } // AfterExitPool is called after ExitPool, ExitSwapShareAmountIn, and ExitSwapExternAmountOut func (k Keeper) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount math.Int, exitCoins sdk.Coins) error { - k.RetreiveAllPortfolio(ctx, sender.String()) + k.RetrieveAllPortfolio(ctx, sender.String()) return nil } // AfterSwap is called after SwapExactAmountIn and SwapExactAmountOut func (k Keeper) AfterSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) error { - k.RetreiveAllPortfolio(ctx, sender.String()) + k.RetrieveAllPortfolio(ctx, sender.String()) return nil } diff --git a/x/tier/keeper/hooks_perpetual.go b/x/tier/keeper/hooks_perpetual.go index 7e3280b3b..63b87ee59 100644 --- a/x/tier/keeper/hooks_perpetual.go +++ b/x/tier/keeper/hooks_perpetual.go @@ -7,35 +7,35 @@ import ( ) func (k Keeper) AfterPerpetualPositionOpen(ctx sdk.Context, ammPool ammtypes.Pool, perpetualPool perpetualtypes.Pool, sender string) { - k.RetreiveAllPortfolio(ctx, sender) + k.RetrieveAllPortfolio(ctx, sender) } func (k Keeper) AfterPerpetualPositionModified(ctx sdk.Context, ammPool ammtypes.Pool, perpetualPool perpetualtypes.Pool, sender string) { - k.RetreiveAllPortfolio(ctx, sender) + k.RetrieveAllPortfolio(ctx, sender) } func (k Keeper) AfterPerpetualPositionClosed(ctx sdk.Context, ammPool ammtypes.Pool, perpetualPool perpetualtypes.Pool, sender string) { - k.RetreiveAllPortfolio(ctx, sender) + k.RetrieveAllPortfolio(ctx, sender) } // AfterPoolCreated is called after CreatePool func (k Keeper) AfterAmmPoolCreated(ctx sdk.Context, ammPool ammtypes.Pool, sender string) { - k.RetreiveAllPortfolio(ctx, sender) + k.RetrieveAllPortfolio(ctx, sender) } // AfterJoinPool is called after JoinPool, JoinSwapExternAmountIn, and JoinSwapShareAmountOut func (k Keeper) AfterAmmJoinPool(ctx sdk.Context, ammPool ammtypes.Pool, perpetualPool perpetualtypes.Pool, sender string) { - k.RetreiveAllPortfolio(ctx, sender) + k.RetrieveAllPortfolio(ctx, sender) } // AfterExitPool is called after ExitPool, ExitSwapShareAmountIn, and ExitSwapExternAmountOut func (k Keeper) AfterAmmExitPool(ctx sdk.Context, ammPool ammtypes.Pool, perpetualPool perpetualtypes.Pool, sender string) { - k.RetreiveAllPortfolio(ctx, sender) + k.RetrieveAllPortfolio(ctx, sender) } // AfterSwap is called after SwapExactAmountIn and SwapExactAmountOut func (k Keeper) AfterAmmSwap(ctx sdk.Context, ammPool ammtypes.Pool, perpetualPool perpetualtypes.Pool, sender string) { - k.RetreiveAllPortfolio(ctx, sender) + k.RetrieveAllPortfolio(ctx, sender) } // Hooks wrapper struct for tvl keeper diff --git a/x/tier/keeper/hooks_stable_stake.go b/x/tier/keeper/hooks_stable_stake.go index 09d103c5d..36593ebe6 100644 --- a/x/tier/keeper/hooks_stable_stake.go +++ b/x/tier/keeper/hooks_stable_stake.go @@ -7,12 +7,12 @@ import ( ) func (k Keeper) AfterBond(ctx sdk.Context, sender string, shareAmount math.Int) error { - k.RetreiveAllPortfolio(ctx, sender) + k.RetrieveAllPortfolio(ctx, sender) return nil } func (k Keeper) AfterUnbond(ctx sdk.Context, sender string, shareAmount math.Int) error { - k.RetreiveAllPortfolio(ctx, sender) + k.RetrieveAllPortfolio(ctx, sender) return nil } diff --git a/x/tier/keeper/hooks_staking.go b/x/tier/keeper/hooks_staking.go index a33f04c72..10282e96c 100644 --- a/x/tier/keeper/hooks_staking.go +++ b/x/tier/keeper/hooks_staking.go @@ -12,7 +12,7 @@ func (k Keeper) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, // Updating portfolio on delegation changes func (k Keeper) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { - k.RetreiveAllPortfolio(ctx, delAddr.String()) + k.RetrieveAllPortfolio(ctx, delAddr.String()) return nil } diff --git a/x/tier/keeper/msg_server_set_portfolio.go b/x/tier/keeper/msg_server_set_portfolio.go index 3976aaec3..794faf2be 100644 --- a/x/tier/keeper/msg_server_set_portfolio.go +++ b/x/tier/keeper/msg_server_set_portfolio.go @@ -9,7 +9,7 @@ import ( func (k msgServer) SetPortfolio(goCtx context.Context, msg *types.MsgSetPortfolio) (*types.MsgSetPortfolioResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - k.RetreiveAllPortfolio(ctx, msg.User) + k.RetrieveAllPortfolio(ctx, msg.User) return &types.MsgSetPortfolioResponse{}, nil } diff --git a/x/tier/keeper/portfolio.go b/x/tier/keeper/portfolio.go index 37d6a20a3..86ca1f2bd 100644 --- a/x/tier/keeper/portfolio.go +++ b/x/tier/keeper/portfolio.go @@ -17,7 +17,7 @@ import ( "github.com/elys-network/elys/x/tier/types" ) -func (k Keeper) RetreiveAllPortfolio(ctx sdk.Context, user string) { +func (k Keeper) RetrieveAllPortfolio(ctx sdk.Context, user string) { // set today + user -> amount sender := sdk.MustAccAddressFromBech32(user) todayDate := k.GetDateFromBlock(ctx.BlockTime()) @@ -30,23 +30,23 @@ func (k Keeper) RetreiveAllPortfolio(ctx sdk.Context, user string) { totalValue := sdk.NewDec(0) // Liquid assets - liq := k.RetreiveLiquidAssetsTotal(ctx, sender) + liq := k.RetrieveLiquidAssetsTotal(ctx, sender) totalValue = totalValue.Add(liq) // Rewards - rew := k.RetreiveRewardsTotal(ctx, sender) + rew := k.RetrieveRewardsTotal(ctx, sender) totalValue = totalValue.Add(rew) // Perpetual - perp := k.RetreivePerpetualTotal(ctx, sender) + perp := k.RetrievePerpetualTotal(ctx, sender) totalValue = totalValue.Add(perp) // Staked+Pool assets - staked := k.RetreiveStakedAndPoolTotal(ctx, sender) + staked := k.RetrieveStakedAndPoolTotal(ctx, sender) totalValue = totalValue.Add(staked) // LeverageLp - lev := k.RetreiveLeverageLpTotal(ctx, sender) + lev := k.RetrieveLeverageLpTotal(ctx, sender) totalValue = totalValue.Add(lev) k.SetPortfolio(ctx, todayDate, sender.String(), types.Portfolio{ @@ -55,7 +55,7 @@ func (k Keeper) RetreiveAllPortfolio(ctx sdk.Context, user string) { }) } -func (k Keeper) RetreiveStakedAndPoolTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { +func (k Keeper) RetrieveStakedAndPoolTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { totalValue := sdk.NewDec(0) commitments := k.commitement.GetCommitments(ctx, user.String()) for _, commitment := range commitments.CommittedTokens { @@ -116,7 +116,7 @@ func (k Keeper) RetreiveStakedAndPoolTotal(ctx sdk.Context, user sdk.AccAddress) return totalValue } -func (k Keeper) RetreiveRewardsTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { +func (k Keeper) RetrieveRewardsTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { totalValue := sdk.NewDec(0) estaking, err1 := k.estaking.Rewards(ctx, &estakingtypes.QueryRewardsRequest{Address: user.String()}) masterchef, err2 := k.masterchef.UserPendingReward(ctx, &mastercheftypes.QueryUserPendingRewardRequest{User: user.String()}) @@ -159,7 +159,7 @@ func (k Keeper) RetreiveRewardsTotal(ctx sdk.Context, user sdk.AccAddress) sdk.D return totalValue } -func (k Keeper) RetreivePerpetualTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { +func (k Keeper) RetrievePerpetualTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { totalValue := sdk.NewDec(0) perpetuals, _, err := k.perpetual.GetMTPsForAddress(ctx, user, &query.PageRequest{}) if err == nil { @@ -179,7 +179,7 @@ func (k Keeper) RetreivePerpetualTotal(ctx sdk.Context, user sdk.AccAddress) sdk return totalValue } -func (k Keeper) RetreiveLiquidAssetsTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { +func (k Keeper) RetrieveLiquidAssetsTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { balances := k.bankKeeper.GetAllBalances(ctx, user) totalValue := sdk.NewDec(0) // Get eden from AmmBalance @@ -205,7 +205,7 @@ func (k Keeper) RetreiveLiquidAssetsTotal(ctx sdk.Context, user sdk.AccAddress) return totalValue } -func (k Keeper) RetreiveLeverageLpTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { +func (k Keeper) RetrieveLeverageLpTotal(ctx sdk.Context, user sdk.AccAddress) sdk.Dec { positions, _, err := k.leveragelp.GetPositionsForAddress(ctx, user, &query.PageRequest{}) totalValue := sdk.NewDec(0) if err == nil { @@ -222,6 +222,18 @@ func (k Keeper) RetreiveLeverageLpTotal(ctx sdk.Context, user sdk.AccAddress) sd return totalValue } +func (k Keeper) RetrieveConsolidatedPrice(ctx sdk.Context, denom string) (sdk.Dec, error) { + tokenPrice := k.oracleKeeper.GetAssetPriceFromDenom(ctx, denom) + asset, found := k.assetProfileKeeper.GetEntryByDenom(ctx, denom) + if !found { + return sdk.ZeroDec(), types.ErrNotFound + } + if tokenPrice == sdk.ZeroDec() { + tokenPrice = k.CalcAmmPrice(ctx, asset.Denom, asset.Decimals) + } + return tokenPrice, nil +} + func (k Keeper) CalcAmmPrice(ctx sdk.Context, denom string, decimal uint64) sdk.Dec { usdcDenom, found := k.assetProfileKeeper.GetUsdcDenom(ctx) if !found { diff --git a/x/tier/keeper/portfolio_test.go b/x/tier/keeper/portfolio_test.go index 90f20e625..72347d6fa 100644 --- a/x/tier/keeper/portfolio_test.go +++ b/x/tier/keeper/portfolio_test.go @@ -119,7 +119,7 @@ func TestGetPortfolioNative(t *testing.T) { err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ammtypes.ModuleName, addr[0], coins) require.NoError(t, err) - tier.RetreiveAllPortfolio(ctx, addr[0].String()) + tier.RetrieveAllPortfolio(ctx, addr[0].String()) portfolio, found := tier.GetPortfolio(ctx, addr[0].String(), tier.GetDateFromBlock(ctx.BlockTime())) require.True(t, found) @@ -193,7 +193,7 @@ func TestGetPortfolioAmm(t *testing.T) { require.NoError(t, err) require.Equal(t, resp.PoolID, uint64(1)) - tier.RetreiveAllPortfolio(ctx, addr[0].String()) + tier.RetrieveAllPortfolio(ctx, addr[0].String()) portfolio, found := tier.GetPortfolio(ctx, addr[0].String(), tier.GetDateFromBlock(ctx.BlockTime())) require.True(t, found) @@ -298,7 +298,7 @@ func TestGetPortfolioPerpetual(t *testing.T) { SumCollateral: sdk.ZeroInt(), }) - tier.RetreiveAllPortfolio(ctx, addr[0].String()) + tier.RetrieveAllPortfolio(ctx, addr[0].String()) portfolio, found := tier.GetPortfolio(ctx, addr[0].String(), tier.GetDateFromBlock(ctx.BlockTime())) require.True(t, found) diff --git a/x/tier/keeper/query_get_consolidated_price.go b/x/tier/keeper/query_get_consolidated_price.go new file mode 100644 index 000000000..6522b0fc9 --- /dev/null +++ b/x/tier/keeper/query_get_consolidated_price.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/tier/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) GetConsolidatedPrice(goCtx context.Context, req *types.QueryGetConsolidatedPriceRequest) (*types.QueryGetConsolidatedPriceResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + resp, err := k.RetrieveConsolidatedPrice(ctx, req.Denom) + if err != nil { + return nil, err + } + + return &types.QueryGetConsolidatedPriceResponse{ + Price: resp, + }, nil +} diff --git a/x/tier/keeper/query_leverage_lp_total.go b/x/tier/keeper/query_leverage_lp_total.go index 8bd146e40..310fcfd6a 100644 --- a/x/tier/keeper/query_leverage_lp_total.go +++ b/x/tier/keeper/query_leverage_lp_total.go @@ -16,7 +16,7 @@ func (k Keeper) LeverageLpTotal(goCtx context.Context, req *types.QueryLeverageL ctx := sdk.UnwrapSDKContext(goCtx) sender := sdk.MustAccAddressFromBech32(req.User) - total := k.RetreiveLeverageLpTotal(ctx, sender) + total := k.RetrieveLeverageLpTotal(ctx, sender) return &types.QueryLeverageLpTotalResponse{ Total: total, diff --git a/x/tier/keeper/query_liquid_total.go b/x/tier/keeper/query_liquid_total.go index 88ce9e89d..e2e768267 100644 --- a/x/tier/keeper/query_liquid_total.go +++ b/x/tier/keeper/query_liquid_total.go @@ -16,7 +16,7 @@ func (k Keeper) LiquidTotal(goCtx context.Context, req *types.QueryLiquidTotalRe ctx := sdk.UnwrapSDKContext(goCtx) sender := sdk.MustAccAddressFromBech32(req.User) - total := k.RetreiveLiquidAssetsTotal(ctx, sender) + total := k.RetrieveLiquidAssetsTotal(ctx, sender) return &types.QueryLiquidTotalResponse{ Total: total, diff --git a/x/tier/keeper/query_perpetual.go b/x/tier/keeper/query_perpetual.go index 8d16ba88f..c07850334 100644 --- a/x/tier/keeper/query_perpetual.go +++ b/x/tier/keeper/query_perpetual.go @@ -16,7 +16,7 @@ func (k Keeper) Perpetual(goCtx context.Context, req *types.QueryPerpetualReques ctx := sdk.UnwrapSDKContext(goCtx) sender := sdk.MustAccAddressFromBech32(req.User) - total := k.RetreivePerpetualTotal(ctx, sender) + total := k.RetrievePerpetualTotal(ctx, sender) return &types.QueryPerpetualResponse{ Total: total, diff --git a/x/tier/keeper/query_rewards_total.go b/x/tier/keeper/query_rewards_total.go index 5d9de3616..b7302dd3c 100644 --- a/x/tier/keeper/query_rewards_total.go +++ b/x/tier/keeper/query_rewards_total.go @@ -16,7 +16,7 @@ func (k Keeper) RewardsTotal(goCtx context.Context, req *types.QueryRewardsTotal ctx := sdk.UnwrapSDKContext(goCtx) sender := sdk.MustAccAddressFromBech32(req.User) - total := k.RetreiveRewardsTotal(ctx, sender) + total := k.RetrieveRewardsTotal(ctx, sender) return &types.QueryRewardsTotalResponse{ Total: total, diff --git a/x/tier/keeper/query_staked_pool.go b/x/tier/keeper/query_staked_pool.go index 88974e190..ad677b9f3 100644 --- a/x/tier/keeper/query_staked_pool.go +++ b/x/tier/keeper/query_staked_pool.go @@ -16,7 +16,7 @@ func (k Keeper) StakedPool(goCtx context.Context, req *types.QueryStakedPoolRequ ctx := sdk.UnwrapSDKContext(goCtx) sender := sdk.MustAccAddressFromBech32(req.User) - total := k.RetreiveStakedAndPoolTotal(ctx, sender) + total := k.RetrieveStakedAndPoolTotal(ctx, sender) return &types.QueryStakedPoolResponse{ Total: total, diff --git a/x/tier/types/errors.go b/x/tier/types/errors.go index 92a0a8044..ff5318d52 100644 --- a/x/tier/types/errors.go +++ b/x/tier/types/errors.go @@ -8,5 +8,6 @@ import ( // x/tier module sentinel errors var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrNotFound = sdkerrors.Register(ModuleName, 1101, "asset not found in asset profiler") ) diff --git a/x/tier/types/query.pb.go b/x/tier/types/query.pb.go index c7ddf2e94..fc4f98cb5 100644 --- a/x/tier/types/query.pb.go +++ b/x/tier/types/query.pb.go @@ -904,6 +904,87 @@ func (m *QueryGetAmmPriceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryGetAmmPriceResponse proto.InternalMessageInfo +type QueryGetConsolidatedPriceRequest struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryGetConsolidatedPriceRequest) Reset() { *m = QueryGetConsolidatedPriceRequest{} } +func (m *QueryGetConsolidatedPriceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetConsolidatedPriceRequest) ProtoMessage() {} +func (*QueryGetConsolidatedPriceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_461504ebf74c9a97, []int{20} +} +func (m *QueryGetConsolidatedPriceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetConsolidatedPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetConsolidatedPriceRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetConsolidatedPriceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetConsolidatedPriceRequest.Merge(m, src) +} +func (m *QueryGetConsolidatedPriceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetConsolidatedPriceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetConsolidatedPriceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetConsolidatedPriceRequest proto.InternalMessageInfo + +func (m *QueryGetConsolidatedPriceRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type QueryGetConsolidatedPriceResponse struct { + Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` +} + +func (m *QueryGetConsolidatedPriceResponse) Reset() { *m = QueryGetConsolidatedPriceResponse{} } +func (m *QueryGetConsolidatedPriceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetConsolidatedPriceResponse) ProtoMessage() {} +func (*QueryGetConsolidatedPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_461504ebf74c9a97, []int{21} +} +func (m *QueryGetConsolidatedPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetConsolidatedPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetConsolidatedPriceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetConsolidatedPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetConsolidatedPriceResponse.Merge(m, src) +} +func (m *QueryGetConsolidatedPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetConsolidatedPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetConsolidatedPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetConsolidatedPriceResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "elys.tier.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "elys.tier.QueryParamsResponse") @@ -925,76 +1006,82 @@ func init() { proto.RegisterType((*QueryLiquidTotalResponse)(nil), "elys.tier.QueryLiquidTotalResponse") proto.RegisterType((*QueryGetAmmPriceRequest)(nil), "elys.tier.QueryGetAmmPriceRequest") proto.RegisterType((*QueryGetAmmPriceResponse)(nil), "elys.tier.QueryGetAmmPriceResponse") + proto.RegisterType((*QueryGetConsolidatedPriceRequest)(nil), "elys.tier.QueryGetConsolidatedPriceRequest") + proto.RegisterType((*QueryGetConsolidatedPriceResponse)(nil), "elys.tier.QueryGetConsolidatedPriceResponse") } func init() { proto.RegisterFile("elys/tier/query.proto", fileDescriptor_461504ebf74c9a97) } var fileDescriptor_461504ebf74c9a97 = []byte{ - // 1018 bytes of a gzipped FileDescriptorProto + // 1076 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x97, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0xc7, 0xe3, 0xb4, 0x09, 0xec, 0x6c, 0x45, 0xd5, 0x21, 0x2d, 0xa9, 0x49, 0xb7, 0xad, 0x83, - 0x92, 0x34, 0x4d, 0xec, 0x66, 0x83, 0x44, 0x11, 0xe2, 0x47, 0x7e, 0x28, 0x11, 0x52, 0x0e, 0xcb, - 0xd2, 0x13, 0x07, 0x96, 0xd9, 0xdd, 0xc1, 0xb5, 0x62, 0x7b, 0x1c, 0xcf, 0x6c, 0xcb, 0x2a, 0xca, - 0xa5, 0x17, 0x0e, 0x48, 0x80, 0xc4, 0x81, 0x0b, 0xea, 0x7f, 0xc0, 0xff, 0xd1, 0x03, 0x87, 0x4a, - 0x5c, 0x10, 0x87, 0x08, 0x25, 0xfc, 0x21, 0xc8, 0x33, 0xcf, 0x5e, 0x7b, 0xed, 0xf5, 0x2e, 0xd2, - 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3, 0xf6, 0x7f, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x06, 0x10, 0x42, 0xea, 0xf3, 0x0c, 0x00, 0x00, + 0x14, 0xc7, 0xe3, 0xb4, 0x09, 0xe4, 0xa5, 0x50, 0x75, 0xd8, 0x96, 0xd4, 0xa4, 0xdb, 0xc4, 0x41, + 0x49, 0x9a, 0x1f, 0x76, 0xb3, 0x41, 0x10, 0x84, 0x28, 0xe4, 0x87, 0x12, 0x21, 0xe5, 0xb0, 0x2c, + 0x3d, 0x71, 0x60, 0x99, 0x5d, 0x0f, 0xae, 0x15, 0xdb, 0xe3, 0xd8, 0xb3, 0x2d, 0xab, 0x28, 0x12, + 0xea, 0x85, 0x03, 0x12, 0x20, 0x71, 0xe0, 0x82, 0xfa, 0x1f, 0x70, 0xe0, 0xbf, 0xe8, 0xb1, 0x12, + 0x17, 0xc4, 0xa1, 0x42, 0x09, 0x7f, 0x08, 0xf2, 0xcc, 0xd8, 0x6b, 0xaf, 0xbd, 0xde, 0xa5, 0xda, + 0xd3, 0xda, 0xe3, 0xef, 0x7b, 0xef, 0x33, 0xf3, 0x66, 0xe6, 0xab, 0x85, 0x9b, 0xc4, 0xe9, 0x86, + 0x06, 0xb3, 0x49, 0x60, 0x9c, 0x76, 0x48, 0xd0, 0xd5, 0xfd, 0x80, 0x32, 0x8a, 0x66, 0xa2, 0x61, + 0x3d, 0x1a, 0x56, 0x2b, 0x16, 0xb5, 0x28, 0x1f, 0x35, 0xa2, 0x27, 0x21, 0x50, 0xe7, 0x2d, 0x4a, + 0x2d, 0x87, 0x18, 0xd8, 0xb7, 0x0d, 0xec, 0x79, 0x94, 0x61, 0x66, 0x53, 0x2f, 0x94, 0x5f, 0xd7, + 0xda, 0x34, 0x74, 0x69, 0x68, 0xb4, 0x70, 0x48, 0x44, 0x5e, 0xe3, 0xf1, 0x56, 0x8b, 0x30, 0xbc, + 0x65, 0xf8, 0xd8, 0xb2, 0x3d, 0x2e, 0x96, 0xda, 0x5b, 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0xf3, 0x95, 0x64, 0x4f, 0x89, 0xc7, 0x0a, 0xb3, 0x29, + 0x67, 0x7b, 0x6c, 0x9f, 0x76, 0x6c, 0x73, 0x68, 0xb7, 0xbe, 0x96, 0xdd, 0xcd, 0xc8, 0xc7, 0x0a, + 0xf4, 0x99, 0x04, 0x3a, 0x22, 0x6c, 0xd7, 0x75, 0xeb, 0x81, 0xdd, 0x8e, 0x6f, 0x11, 0x54, 0x81, + 0x29, 0x93, 0x78, 0xd4, 0x95, 0x44, 0xe2, 0x05, 0xcd, 0xc1, 0x6b, 0x26, 0x69, 0xdb, 0x2e, 0x76, + 0xf8, 0xf1, 0x99, 0x6a, 0xc4, 0xaf, 0x09, 0x6c, 0x26, 0xd5, 0x58, 0x61, 0x77, 0x60, 0x21, 0xae, + 0xb0, 0x4f, 0xbd, 0x90, 0x3a, 0xb6, 0x89, 0x19, 0x31, 0x87, 0x53, 0x6b, 0x36, 0x2c, 0x96, 0x44, + 0xf6, 0x20, 0xfd, 0x68, 0xe0, 0x55, 0x21, 0x79, 0x70, 0xed, 0xbb, 0x37, 0x60, 0x8a, 0xd7, 0x42, + 0x5d, 0x98, 0x16, 0x56, 0x84, 0xee, 0xa4, 0xee, 0xd4, 0xbc, 0xc7, 0xa9, 0xd5, 0x41, 0x9f, 0x05, + 0x98, 0x76, 0xff, 0xe9, 0x9f, 0xff, 0xfe, 0x32, 0xb9, 0x86, 0x56, 0x8d, 0x48, 0xb7, 0xe9, 0x11, + 0xf6, 0x84, 0x06, 0x27, 0xfc, 0xc5, 0x70, 0x89, 0xdb, 0x22, 0x41, 0xf8, 0xc8, 0xf6, 0x53, 0x66, + 0x8b, 0x9e, 0x29, 0x30, 0x93, 0x5c, 0xde, 0x68, 0xa9, 0x3f, 0x7f, 0x81, 0x09, 0xaa, 0xef, 0x96, + 0x8b, 0x24, 0xca, 0x21, 0x47, 0xf9, 0x14, 0x3d, 0x18, 0x01, 0x25, 0x0e, 0x36, 0xce, 0xa2, 0xcd, + 0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, 0x0e, 0x89, 0x21, 0x7e, 0x50, 0x60, 0x36, 0x65, + 0x2b, 0x28, 0x37, 0xd9, 0xbc, 0x45, 0xa9, 0x4b, 0xa5, 0x9a, 0x11, 0x4e, 0x9f, 0xd8, 0x33, 0x3c, + 0x28, 0xdb, 0x9c, 0x5f, 0x15, 0x98, 0x4d, 0xf9, 0x46, 0x9e, 0x26, 0xef, 0x4f, 0xea, 0x52, 0xa9, + 0x46, 0xd2, 0x7c, 0xc2, 0x69, 0x3e, 0x44, 0x1f, 0x0c, 0xa2, 0xb1, 0x08, 0x6b, 0x62, 0xd7, 0x6d, + 0xf2, 0xcb, 0xdb, 0x38, 0xe3, 0x76, 0x71, 0x1e, 0xfd, 0x72, 0x53, 0x3b, 0x47, 0x7f, 0x28, 0x50, + 0x29, 0x72, 0x0d, 0xb4, 0x5e, 0x50, 0x7e, 0x90, 0x2b, 0xa9, 0x1b, 0xa3, 0x89, 0x25, 0xf4, 0x03, + 0x0e, 0xbd, 0x83, 0xde, 0x2f, 0x83, 0x6e, 0xa7, 0xc2, 0xb3, 0xf4, 0x7b, 0xfb, 0xcf, 0x2f, 0xaa, + 0xca, 0x8b, 0x8b, 0xaa, 0xf2, 0xcf, 0x45, 0x55, 0xf9, 0xf9, 0xb2, 0x3a, 0xf1, 0xe2, 0xb2, 0x3a, + 0xf1, 0xd7, 0x65, 0x75, 0xe2, 0xcb, 0x7b, 0x29, 0x2f, 0xcb, 0xe7, 0xfe, 0x56, 0x64, 0xe7, 0x96, + 0xd6, 0x9a, 0xe6, 0xff, 0xca, 0xb6, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x33, 0x47, 0xe0, 0x22, + 0x4c, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1028,6 +1115,8 @@ type QueryClient interface { LiquidTotal(ctx context.Context, in *QueryLiquidTotalRequest, opts ...grpc.CallOption) (*QueryLiquidTotalResponse, error) // Queries a list of GetAmmPrice items. GetAmmPrice(ctx context.Context, in *QueryGetAmmPriceRequest, opts ...grpc.CallOption) (*QueryGetAmmPriceResponse, error) + // Queries a list of GetConsolidatedPrice items. + GetConsolidatedPrice(ctx context.Context, in *QueryGetConsolidatedPriceRequest, opts ...grpc.CallOption) (*QueryGetConsolidatedPriceResponse, error) } type queryClient struct { @@ -1128,6 +1217,15 @@ func (c *queryClient) GetAmmPrice(ctx context.Context, in *QueryGetAmmPriceReque return out, nil } +func (c *queryClient) GetConsolidatedPrice(ctx context.Context, in *QueryGetConsolidatedPriceRequest, opts ...grpc.CallOption) (*QueryGetConsolidatedPriceResponse, error) { + out := new(QueryGetConsolidatedPriceResponse) + err := c.cc.Invoke(ctx, "/elys.tier.Query/GetConsolidatedPrice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -1149,6 +1247,8 @@ type QueryServer interface { LiquidTotal(context.Context, *QueryLiquidTotalRequest) (*QueryLiquidTotalResponse, error) // Queries a list of GetAmmPrice items. GetAmmPrice(context.Context, *QueryGetAmmPriceRequest) (*QueryGetAmmPriceResponse, error) + // Queries a list of GetConsolidatedPrice items. + GetConsolidatedPrice(context.Context, *QueryGetConsolidatedPriceRequest) (*QueryGetConsolidatedPriceResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1185,6 +1285,9 @@ func (*UnimplementedQueryServer) LiquidTotal(ctx context.Context, req *QueryLiqu func (*UnimplementedQueryServer) GetAmmPrice(ctx context.Context, req *QueryGetAmmPriceRequest) (*QueryGetAmmPriceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetAmmPrice not implemented") } +func (*UnimplementedQueryServer) GetConsolidatedPrice(ctx context.Context, req *QueryGetConsolidatedPriceRequest) (*QueryGetConsolidatedPriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetConsolidatedPrice not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1370,6 +1473,24 @@ func _Query_GetAmmPrice_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Query_GetConsolidatedPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetConsolidatedPriceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetConsolidatedPrice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.tier.Query/GetConsolidatedPrice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetConsolidatedPrice(ctx, req.(*QueryGetConsolidatedPriceRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "elys.tier.Query", HandlerType: (*QueryServer)(nil), @@ -1414,6 +1535,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "GetAmmPrice", Handler: _Query_GetAmmPrice_Handler, }, + { + MethodName: "GetConsolidatedPrice", + Handler: _Query_GetConsolidatedPrice_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "elys/tier/query.proto", @@ -2083,6 +2208,69 @@ func (m *QueryGetAmmPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *QueryGetConsolidatedPriceRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetConsolidatedPriceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetConsolidatedPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetConsolidatedPriceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetConsolidatedPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetConsolidatedPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Price.Size() + i -= size + if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2357,6 +2545,30 @@ func (m *QueryGetAmmPriceResponse) Size() (n int) { return n } +func (m *QueryGetConsolidatedPriceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetConsolidatedPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Price.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4141,6 +4353,172 @@ func (m *QueryGetAmmPriceResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetConsolidatedPriceRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetConsolidatedPriceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetConsolidatedPriceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetConsolidatedPriceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetConsolidatedPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetConsolidatedPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tier/types/query.pb.gw.go b/x/tier/types/query.pb.gw.go index 1a2e68e4f..bd498265c 100644 --- a/x/tier/types/query.pb.gw.go +++ b/x/tier/types/query.pb.gw.go @@ -563,6 +563,60 @@ func local_request_Query_GetAmmPrice_0(ctx context.Context, marshaler runtime.Ma } +func request_Query_GetConsolidatedPrice_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetConsolidatedPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := client.GetConsolidatedPrice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetConsolidatedPrice_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetConsolidatedPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := server.GetConsolidatedPrice(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -799,6 +853,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_GetConsolidatedPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetConsolidatedPrice_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetConsolidatedPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1040,6 +1117,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_GetConsolidatedPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetConsolidatedPrice_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetConsolidatedPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1063,6 +1160,8 @@ var ( pattern_Query_LiquidTotal_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"elys-network", "elys", "tier", "liquid_total", "user"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_GetAmmPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"elys-network", "elys", "tier", "get_amm_price", "denom", "decimal"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetConsolidatedPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"elys-network", "elys", "tier", "get_consolidated_price", "denom"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1085,4 +1184,6 @@ var ( forward_Query_LiquidTotal_0 = runtime.ForwardResponseMessage forward_Query_GetAmmPrice_0 = runtime.ForwardResponseMessage + + forward_Query_GetConsolidatedPrice_0 = runtime.ForwardResponseMessage )