-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query osmo equivilent is staked via superfluid #1632
Changes from 11 commits
fe85343
d6bbe3f
7f8a6e0
f56f2bd
a30de47
5407105
9aa7a2c
7b25e2f
70b4906
891ebc4
6254da7
32edd8e
5b0a13f
1bbc74d
260f0c5
e900eb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -187,6 +187,10 @@ message SuperfluidDelegationsByDelegatorResponse { | |||||
(gogoproto.nullable) = false, | ||||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" | ||||||
]; | ||||||
cosmos.base.v1beta1.Coin total_equivilent_staked_amount = 3 [ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank u xD i changed that |
||||||
(gogoproto.nullable) = false, | ||||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" | ||||||
]; | ||||||
} | ||||||
|
||||||
message SuperfluidUndelegationsByDelegatorRequest { | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,6 +11,8 @@ import ( | |||||||||
"google.golang.org/grpc/codes" | ||||||||||
"google.golang.org/grpc/status" | ||||||||||
|
||||||||||
appparams "github.com/osmosis-labs/osmosis/v7/app/params" | ||||||||||
|
||||||||||
lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types" | ||||||||||
"github.com/osmosis-labs/osmosis/v7/x/superfluid/types" | ||||||||||
) | ||||||||||
|
@@ -195,6 +197,7 @@ func (q Querier) SuperfluidDelegationsByDelegator(goCtx context.Context, req *ty | |||||||||
res := types.SuperfluidDelegationsByDelegatorResponse{ | ||||||||||
SuperfluidDelegationRecords: []types.SuperfluidDelegationRecord{}, | ||||||||||
TotalDelegatedCoins: sdk.NewCoins(), | ||||||||||
TotalEquivilentStakedAmount: sdk.NewCoin(appparams.BaseCoinUnit, sdk.ZeroInt()), | ||||||||||
} | ||||||||||
|
||||||||||
syntheticLocks := q.Keeper.lk.GetAllSyntheticLockupsByAddr(ctx, delAddr) | ||||||||||
|
@@ -213,17 +216,25 @@ func (q Querier) SuperfluidDelegationsByDelegator(goCtx context.Context, req *ty | |||||||||
baseDenom := periodLock.Coins.GetDenomByIndex(0) | ||||||||||
lockedCoins := sdk.NewCoin(baseDenom, periodLock.GetCoins().AmountOf(baseDenom)) | ||||||||||
valAddr, err := ValidatorAddressFromSyntheticDenom(syntheticLock.SynthDenom) | ||||||||||
|
||||||||||
// Find how many osmo tokens this delegation is worth at superfluids current risk adjustment | ||||||||||
// and twap of the denom. | ||||||||||
equivilentAmount := q.Keeper.GetSuperfluidOSMOTokens(ctx, baseDenom, lockedCoins.Amount) | ||||||||||
coin := sdk.NewCoin(appparams.BaseCoinUnit, equivilentAmount) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
minor nit |
||||||||||
|
||||||||||
if err != nil { | ||||||||||
return nil, err | ||||||||||
} | ||||||||||
res.SuperfluidDelegationRecords = append(res.SuperfluidDelegationRecords, | ||||||||||
types.SuperfluidDelegationRecord{ | ||||||||||
DelegatorAddress: req.DelegatorAddress, | ||||||||||
ValidatorAddress: valAddr, | ||||||||||
DelegationAmount: lockedCoins, | ||||||||||
DelegatorAddress: req.DelegatorAddress, | ||||||||||
ValidatorAddress: valAddr, | ||||||||||
DelegationAmount: lockedCoins, | ||||||||||
EquivilentStakedAmount: &coin, | ||||||||||
}, | ||||||||||
) | ||||||||||
res.TotalDelegatedCoins = res.TotalDelegatedCoins.Add(lockedCoins) | ||||||||||
res.TotalEquivilentStakedAmount = res.TotalEquivilentStakedAmount.Add(coin) | ||||||||||
} | ||||||||||
|
||||||||||
return &res, nil | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be regenerated due to the typo