Skip to content
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

fix(valset): withdraw rewards #6949

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#6814](https://github.com/osmosis-labs/osmosis/pull/6814) Add EstimateTradeBasedOnPriceImpact to stargate whitelist
* [#6859](https://github.com/osmosis-labs/osmosis/pull/6859) Add hooks to core CL operations (position creation/withdrawal and swaps)
* [#6937](https://github.com/osmosis-labs/osmosis/pull/6937) Update wasmd to v0.45.0 and wasmvm to v1.5.0
* [#6949](https://github.com/osmosis-labs/osmosis/pull/6949) Valset withdraw rewards now considers all validators user is delegated to instead of valset

### Misc Improvements

Expand Down
6 changes: 3 additions & 3 deletions x/valset-pref/validator_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,14 @@ func (k Keeper) getValTargetAndSource(ctx sdk.Context, valSource, valTarget stri
return validatorSource, validatorTarget, nil
}

// WithdrawDelegationRewards withdraws all the delegation rewards from the validator in the val-set.
// WithdrawDelegationRewards withdraws all the delegation rewards from all validators the user is delegated to, disregarding the val-set.
// If the valset does not exist, it withdraws from existing staking position.
// Delegation reward is collected by the validator and in doing so, they can charge commission to the delegators.
// Rewards are calculated per period, and is updated each time validator delegation changes. For ex: when a delegator
// receives new delgation the rewards can be calculated by taking (total rewards before new delegation - the total current rewards).
func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delegatorAddr string) error {
// get the existingValSet if it exists, if not check existingStakingPosition and return it
existingSet, err := k.GetDelegationPreferences(ctx, delegatorAddr)
// Get all validators the user is delegated to, and create a set from it.
existingSet, err := k.GetValSetPreferencesWithDelegations(ctx, delegatorAddr)
if err != nil {
return types.NoValidatorSetOrExistingDelegationsError{DelegatorAddr: delegatorAddr}
}
Expand Down