Skip to content

Commit

Permalink
updating query for net staking amount
Browse files Browse the repository at this point in the history
  • Loading branch information
avkr003 committed Jan 20, 2025
1 parent 7f443c4 commit 8817466
Show file tree
Hide file tree
Showing 6 changed files with 540 additions and 543 deletions.
808 changes: 404 additions & 404 deletions api/elys/masterchef/query.pulsar.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion proto/elys/leveragelp/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ service Msg {
rpc Dewhitelist(MsgDewhitelist) returns (MsgDewhitelistResponse);
rpc UpdateStopLoss(MsgUpdateStopLoss) returns (MsgUpdateStopLossResponse);
rpc ClosePositions(MsgClosePositions) returns (MsgClosePositionsResponse);
rpc UpdateEnabledPools(MsgUpdateEnabledPools) returns (MsgUpdateEnabledPoolsResponse);
rpc UpdateEnabledPools(MsgUpdateEnabledPools)
returns (MsgUpdateEnabledPoolsResponse);
}
message MsgOpen {
option (cosmos.msg.v1.signer) = "creator";
Expand Down
2 changes: 1 addition & 1 deletion proto/elys/masterchef/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ message QueryChainTVLResponse {
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
repeated cosmos.base.v1beta1.Coin borrowed = 6 [
repeated cosmos.base.v1beta1.Coin net_stakings = 6 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
Expand Down
4 changes: 2 additions & 2 deletions proto/elys/perpetual/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ service Msg {
rpc ClosePositions(MsgClosePositions) returns (MsgClosePositionsResponse);
rpc UpdateTakeProfitPrice(MsgUpdateTakeProfitPrice)
returns (MsgUpdateTakeProfitPriceResponse);
rpc UpdateEnabledPools(MsgUpdateEnabledPools) returns (MsgUpdateEnabledPoolsResponse);

rpc UpdateEnabledPools(MsgUpdateEnabledPools)
returns (MsgUpdateEnabledPoolsResponse);
}
message MsgOpen {
option (cosmos.msg.v1.signer) = "creator";
Expand Down
6 changes: 1 addition & 5 deletions x/masterchef/keeper/query_chain_tvl.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ func (k Keeper) ChainTVL(goCtx context.Context, req *types.QueryChainTVLRequest)
return nil, status.Error(codes.NotFound, "asset profile not found")
}

baseCurrencyPrice := k.oracleKeeper.GetAssetPriceFromDenom(ctx, baseCurrencyEntry.Denom)

stableStakeTVL := k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrencyEntry.Denom)
totalTVL = totalTVL.Add(stableStakeTVL.TruncateInt())

Expand All @@ -55,16 +53,14 @@ func (k Keeper) ChainTVL(goCtx context.Context, req *types.QueryChainTVLRequest)
stakedEdenValue := elysPrice.MulInt(stakedEden)
totalTVL = totalTVL.Add(stakedEdenValue.TruncateInt())

stableStakeParams := k.stableKeeper.GetParams(ctx)
stableStakeBalance := k.bankKeeper.GetBalance(ctx, authtypes.NewModuleAddress(stablestaketypes.ModuleName), baseCurrencyEntry.Denom)
borrowed := stableStakeParams.TotalValue.Sub(stableStakeBalance.Amount)

return &types.QueryChainTVLResponse{
Total: totalTVL,
Pools: poolsTVL.TruncateInt(),
UsdcStaking: stableStakeTVL.TruncateInt(),
StakedElys: stakedElysValue.TruncateInt(),
StakedEden: stakedEdenValue.TruncateInt(),
Borrowed: sdk.NewCoins(sdk.NewCoin(baseCurrencyEntry.DisplayName, baseCurrencyPrice.MulInt(borrowed).TruncateInt())),
NetStakings: sdk.NewCoins(sdk.NewCoin(baseCurrencyEntry.DisplayName, stableStakeBalance.Amount)),
}, nil
}
Loading

0 comments on commit 8817466

Please sign in to comment.