Skip to content

Commit

Permalink
fix: SuperfluidDelegationsByValidatorDenom does not return equivalent…
Browse files Browse the repository at this point in the history
… staked amount (#7857)

* fix SuperfluidDelegationsByValidatorDenom query

* add changelog
  • Loading branch information
czarcas7ic authored Mar 27, 2024
1 parent c22daac commit f3ff198
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#7833](https://github.com/osmosis-labs/osmosis/pull/7883) Bump max gas wanted per tx to 6 mil
* [#7839](https://github.com/osmosis-labs/osmosis/pull/7839) Add ICA controller
* [#7527](https://github.com/osmosis-labs/osmosis/pull/7527) Add 30M gas limit to CW pool contract calls
* [#7857](https://github.com/osmosis-labs/osmosis/pull/7857) SuperfluidDelegationsByValidatorDenom query now returns equivalent staked amount

### SDK

Expand Down
20 changes: 14 additions & 6 deletions x/superfluid/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,9 @@ func (q Querier) SuperfluidDelegationsByDelegator(goCtx context.Context, req *ty
if err != nil {
return nil, err
}

coin := sdk.NewCoin(appparams.BaseCoinUnit, equivalentAmount)

if err != nil {
return nil, err
}
res.SuperfluidDelegationRecords = append(res.SuperfluidDelegationRecords,
types.SuperfluidDelegationRecord{
DelegatorAddress: req.DelegatorAddress,
Expand Down Expand Up @@ -428,11 +426,21 @@ func (q Querier) SuperfluidDelegationsByValidatorDenom(goCtx context.Context, re

for _, lock := range periodLocks {
lockedCoins := sdk.NewCoin(req.Denom, lock.GetCoins().AmountOf(req.Denom))
baseDenom := lock.Coins.GetDenomByIndex(0)

equivalentAmount, err := q.Keeper.GetSuperfluidOSMOTokens(ctx, baseDenom, lockedCoins.Amount)
if err != nil {
return nil, err
}

coin := sdk.NewCoin(appparams.BaseCoinUnit, equivalentAmount)

res.SuperfluidDelegationRecords = append(res.SuperfluidDelegationRecords,
types.SuperfluidDelegationRecord{
DelegatorAddress: lock.GetOwner(),
ValidatorAddress: req.ValidatorAddress,
DelegationAmount: lockedCoins,
DelegatorAddress: lock.GetOwner(),
ValidatorAddress: req.ValidatorAddress,
DelegationAmount: lockedCoins,
EquivalentStakedAmount: &coin,
},
)
}
Expand Down

0 comments on commit f3ff198

Please sign in to comment.