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

Account for unbonding balances when calculating withdrawn rewards #24

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

codchen
Copy link
Collaborator

@codchen codchen commented Jan 10, 2025

Describe your changes and provide context

Rewards that are withdrawn automatically because of undelegate/redelegate should be calculated as:

withdrawn rewards = bank balance - principals not delegated
                  = bank balance - (original total principals - withdrawn principals - delegated principals - unbonding principals)

Previously there was no way to query unbonding principals from a CW contract so we have been under-withdrawing. This PR fixes that.

Testing performed to validate your change

unit test
integration test with sei-chain (which now supports unbonding balance query)

deps.querier.update_balance(
mock_env().contract.address.clone(),
vec![Coin::new(48000000 - 1500000 + 100, "usei")],
);
// principal: 48000000 - 1500000 (delegations).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have tests for cases where there are no unbonding delegations?

@codchen codchen merged commit 3724915 into main Feb 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants