-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding queries for chain and pools tvl * updating query response * upgrading go version to 1.22.7 * changing testnet upgrade height 2 days later (50,000 blocks later) * changing testnet upgrade height 3 days later (75000 blocks later)
- Loading branch information
Showing
12 changed files
with
4,302 additions
and
714 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/elys-network/elys | ||
|
||
go 1.22.6 | ||
go 1.22.7 | ||
|
||
require ( | ||
cosmossdk.io/api v0.7.5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
"cosmossdk.io/math" | ||
ptypes "github.com/elys-network/elys/x/parameter/types" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/elys-network/elys/x/masterchef/types" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
func (k Keeper) AllLiquidityPoolTVL(goCtx context.Context, req *types.QueryAllLiquidityPoolTVLRequest) (*types.QueryAllLiquidityPoolTVLResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "invalid request") | ||
} | ||
|
||
ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
||
allPools := k.amm.GetAllPool(ctx) | ||
poolsTVL := math.LegacyZeroDec() | ||
totalTVL := math.ZeroInt() | ||
|
||
for _, pool := range allPools { | ||
tvl, err := pool.TVL(ctx, k.oracleKeeper, k.accountedPoolKeeper) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
poolsTVL = poolsTVL.Add(tvl) | ||
} | ||
totalTVL = totalTVL.Add(poolsTVL.TruncateInt()) | ||
|
||
entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) | ||
if !found { | ||
return nil, status.Error(codes.NotFound, "asset profile not found") | ||
} | ||
|
||
stableStakeTVL := k.stableKeeper.TVL(ctx, k.oracleKeeper, entry.Denom) | ||
totalTVL = totalTVL.Add(stableStakeTVL.TruncateInt()) | ||
|
||
return &types.QueryAllLiquidityPoolTVLResponse{ | ||
Total: totalTVL, | ||
Pools: poolsTVL.TruncateInt(), | ||
UsdcStaking: stableStakeTVL.TruncateInt(), | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
"cosmossdk.io/math" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
ptypes "github.com/elys-network/elys/x/parameter/types" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/elys-network/elys/x/masterchef/types" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
func (k Keeper) ChainTVL(goCtx context.Context, req *types.QueryChainTVLRequest) (*types.QueryChainTVLResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "invalid request") | ||
} | ||
|
||
ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
||
allPools := k.amm.GetAllPool(ctx) | ||
poolsTVL := math.LegacyZeroDec() | ||
totalTVL := math.ZeroInt() | ||
|
||
for _, pool := range allPools { | ||
tvl, err := pool.TVL(ctx, k.oracleKeeper, k.accountedPoolKeeper) | ||
if err != nil { | ||
return nil, err | ||
} | ||
poolsTVL = poolsTVL.Add(tvl) | ||
} | ||
totalTVL = totalTVL.Add(poolsTVL.TruncateInt()) | ||
|
||
baseCurrencyEntry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) | ||
if !found { | ||
return nil, status.Error(codes.NotFound, "asset profile not found") | ||
} | ||
|
||
stableStakeTVL := k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrencyEntry.Denom) | ||
totalTVL = totalTVL.Add(stableStakeTVL.TruncateInt()) | ||
|
||
elysPrice := k.amm.GetTokenPrice(ctx, ptypes.Elys, baseCurrencyEntry.Denom) | ||
|
||
stakedElys := k.bankKeeper.GetBalance(ctx, authtypes.NewModuleAddress(stakingtypes.BondedPoolName), ptypes.Elys).Amount | ||
stakedElysValue := elysPrice.MulInt(stakedElys) | ||
totalTVL = totalTVL.Add(stakedElysValue.TruncateInt()) | ||
|
||
commitmentParams := k.commitmentKeeper.GetParams(ctx) | ||
stakedEden := commitmentParams.TotalCommitted.AmountOf(ptypes.Eden) | ||
stakedEdenValue := elysPrice.MulInt(stakedEden) | ||
totalTVL = totalTVL.Add(stakedEdenValue.TruncateInt()) | ||
|
||
return &types.QueryChainTVLResponse{ | ||
Total: totalTVL, | ||
Pools: poolsTVL.TruncateInt(), | ||
UsdcStaking: stableStakeTVL.TruncateInt(), | ||
StakedElys: stakedElysValue.TruncateInt(), | ||
StakedEden: stakedEdenValue.TruncateInt(), | ||
}, nil | ||
} |
Oops, something went wrong.