Skip to content

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)

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.

3 participants