Skip to content

Commit

Permalink
Tier Module: Add hooks and queries (#609)
Browse files Browse the repository at this point in the history
* add amm hooks for portfolio calc

* add perp hooks

* refactor

* add queries

* update

* get amm price

* add liquid query

* fix

* add amm price

* refactor and add more hooks

* fix

* fix
  • Loading branch information
amityadav0 authored Jun 24, 2024
1 parent e4587f6 commit 657663e
Show file tree
Hide file tree
Showing 31 changed files with 3,907 additions and 452 deletions.
14 changes: 9 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,6 @@ func NewElysApp(
)
masterchefModule := masterchefmodule.NewAppModule(appCodec, app.MasterchefKeeper, app.AccountKeeper, app.BankKeeper)

app.StablestakeKeeper = *app.StablestakeKeeper.SetHooks(stablestakekeeper.NewMultiStableStakeHooks(
app.MasterchefKeeper.StableStakeHooks(),
))
stablestakeModule := stablestake.NewAppModule(appCodec, app.StablestakeKeeper, app.AccountKeeper, app.BankKeeper)

app.IncentiveKeeper = *incentivemodulekeeper.NewKeeper(
appCodec,
keys[incentivemoduletypes.StoreKey],
Expand Down Expand Up @@ -1064,12 +1059,19 @@ func NewElysApp(

// register hooks after all modules have been initialized

app.StablestakeKeeper = *app.StablestakeKeeper.SetHooks(stablestakekeeper.NewMultiStableStakeHooks(
app.MasterchefKeeper.StableStakeHooks(),
app.TierKeeper.StableStakeHooks(),
))
stablestakeModule := stablestake.NewAppModule(appCodec, app.StablestakeKeeper, app.AccountKeeper, app.BankKeeper)

app.EstakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(
// insert staking hooks receivers here
app.SlashingKeeper.Hooks(),
app.DistrKeeper.Hooks(),
app.EstakingKeeper.StakingHooks(),
app.TierKeeper.StakingHooks(),
),
)

Expand All @@ -1085,6 +1087,7 @@ func NewElysApp(
app.PerpetualKeeper.AmmHooks(),
app.LeveragelpKeeper.AmmHooks(),
app.MasterchefKeeper.AmmHooks(),
app.TierKeeper.AmmHooks(),
),
)
ammModule := ammmodule.NewAppModule(appCodec, app.AmmKeeper, app.AccountKeeper, app.BankKeeper)
Expand All @@ -1104,6 +1107,7 @@ func NewElysApp(
perpetualmoduletypes.NewMultiPerpetualHooks(
// insert perpetual hooks receivers here
app.AccountedPoolKeeper.PerpetualHooks(),
app.TierKeeper.PerpetualHooks(),
),
)
perpetualModule := perpetualmodule.NewAppModule(appCodec, app.PerpetualKeeper, app.AccountKeeper, app.BankKeeper)
Expand Down
209 changes: 209 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44884,6 +44884,45 @@ paths:
type: string
tags:
- Query
/elys-network/elys/tier/get_amm_price/{denom}/{decimal}:
get:
summary: Queries a list of GetAmmPrice items.
operationId: ElysTierGetAmmPrice
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
- name: decimal
in: path
required: true
type: integer
format: int32
tags:
- Query
/elys-network/elys/tier/leverage_lp_total/{user}:
get:
summary: Queries a list of LeverageLpTotal items.
Expand Down Expand Up @@ -44921,6 +44960,154 @@ paths:
type: string
tags:
- Query
/elys-network/elys/tier/liquid_total/{user}:
get:
summary: Queries a list of LiquidTotal items.
operationId: ElysTierLiquidTotal
responses:
'200':
description: A successful response.
schema:
type: object
properties:
total:
type: string
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: user
in: path
required: true
type: string
tags:
- Query
/elys-network/elys/tier/perpetual/{user}:
get:
summary: Queries a list of Perpetual items.
operationId: ElysTierPerpetual
responses:
'200':
description: A successful response.
schema:
type: object
properties:
total:
type: string
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: user
in: path
required: true
type: string
tags:
- Query
/elys-network/elys/tier/rewards_total/{user}:
get:
summary: Queries a list of RewardsTotal items.
operationId: ElysTierRewardsTotal
responses:
'200':
description: A successful response.
schema:
type: object
properties:
total:
type: string
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: user
in: path
required: true
type: string
tags:
- Query
/elys-network/elys/tier/staked_pool/{user}:
get:
summary: Queries a list of StakedPool items.
operationId: ElysTierStakedPool
responses:
'200':
description: A successful response.
schema:
type: object
properties:
total:
type: string
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: user
in: path
required: true
type: string
tags:
- Query
/elys-network/elys/tokenomics/airdrop:
get:
operationId: ElysTokenomicsAirdropAll
Expand Down Expand Up @@ -89252,6 +89439,8 @@ definitions:
type: string
portfolio:
type: string
elys.tier.QueryGetAmmPriceResponse:
type: object
elys.tier.QueryGetPortfolioResponse:
type: object
properties:
Expand All @@ -89262,13 +89451,33 @@ definitions:
properties:
total:
type: string
elys.tier.QueryLiquidTotalResponse:
type: object
properties:
total:
type: string
elys.tier.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
elys.tier.QueryPerpetualResponse:
type: object
properties:
total:
type: string
elys.tier.QueryRewardsTotalResponse:
type: object
properties:
total:
type: string
elys.tier.QueryStakedPoolResponse:
type: object
properties:
total:
type: string
elys.tokenomics.Airdrop:
type: object
properties:
Expand Down
78 changes: 73 additions & 5 deletions proto/elys/tier/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,36 @@ service Query {
option (google.api.http).get = "/elys-network/elys/tier/leverage_lp_total/{user}";

}

// Queries a list of RewardsTotal items.
rpc RewardsTotal (QueryRewardsTotalRequest) returns (QueryRewardsTotalResponse) {
option (google.api.http).get = "/elys-network/elys/tier/rewards_total/{user}";

}

// Queries a list of StakedPool items.
rpc StakedPool (QueryStakedPoolRequest) returns (QueryStakedPoolResponse) {
option (google.api.http).get = "/elys-network/elys/tier/staked_pool/{user}";

}

// Queries a list of Perpetual items.
rpc Perpetual (QueryPerpetualRequest) returns (QueryPerpetualResponse) {
option (google.api.http).get = "/elys-network/elys/tier/perpetual/{user}";

}

// Queries a list of LiquidTotal items.
rpc LiquidTotal (QueryLiquidTotalRequest) returns (QueryLiquidTotalResponse) {
option (google.api.http).get = "/elys-network/elys/tier/liquid_total/{user}";

}

// Queries a list of GetAmmPrice items.
rpc GetAmmPrice (QueryGetAmmPriceRequest) returns (QueryGetAmmPriceResponse) {
option (google.api.http).get = "/elys-network/elys/tier/get_amm_price/{denom}/{decimal}";

}
}
// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}
Expand Down Expand Up @@ -80,13 +110,51 @@ message QueryCalculateDiscountResponse {
}

message QueryLeverageLpTotalRequest {
string user = 1;
string user = 1;
}

message QueryLeverageLpTotalResponse {
string total = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string total = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

message QueryRewardsTotalRequest {
string user = 1;
}

message QueryRewardsTotalResponse {
string total = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

message QueryStakedPoolRequest {
string user = 1;
}

message QueryStakedPoolResponse {
string total = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

message QueryPerpetualRequest {
string user = 1;
}

message QueryPerpetualResponse {
string total = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

message QueryLiquidTotalRequest {
string user = 1;
}

message QueryLiquidTotalResponse {
string total = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

message QueryGetAmmPriceRequest {
string denom = 1;
int32 decimal = 2;
}

message QueryGetAmmPriceResponse {
string total = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

Loading

0 comments on commit 657663e

Please sign in to comment.