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

feat(v0.4.x): unbond tokens when dissolving the alliance #294

Closed
wants to merge 14 commits into from

Conversation

emidev98
Copy link
Contributor

@emidev98 emidev98 commented Dec 19, 2023

This pull request allow Alliances to be deleted even when there are still tokens staked. The flow starts when DeleteAllianceProposal is executed:

  • if there is no stake: it will just delete the alliance,
  • else: will set the alliance to dissolving state.

In the ABCI#EndBlocker from x/alliance: iterates the alliances in search of the ones with the dissolving flag enabled, when an alliance with the dissolving flag is found, all delegations are iterated matching the Denom of the delegation with the Denom of the alliance; when a match is found it will delegate that stake and assign to the alliance the allianceDissolutionTime as the completion time of the unbonding.

  • If no delegations are found in the last round of iterations for a specific alliance it skips iterating the delegations in the next round by setting the isInitialised property from alliance to false (the alliance will also not receive more rewards when the flag is set to false.

@emidev98 emidev98 changed the title wip(v0.4.x): unbond tokens when removing the alliance wip(v0.4.x): unbond tokens when dissolving the alliance Dec 21, 2023
@emidev98 emidev98 changed the base branch from release/v0.3.x to release/v0.4.x December 21, 2023 17:06
@emidev98 emidev98 changed the title wip(v0.4.x): unbond tokens when dissolving the alliance feat(v0.4.x): unbond tokens when dissolving the alliance Dec 21, 2023
@emidev98 emidev98 marked this pull request as ready for review December 21, 2023 17:10
if err != nil {
return nil, err
if asset.TotalTokens.GT(math.ZeroInt()) {
asset.IsDissolving = true
Copy link
Member

@javiersuweijie javiersuweijie Feb 29, 2024

Choose a reason for hiding this comment

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

WHen deleting an asset, we should make it such that we disable the rewards as well. I'm thinking we set the reward weight to be zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm.... Good point!

// the alliance has never had delegations or that all the delegations have been unbonded already,
// so going back to the line 52 of this file we avoid doing unnecessary comput.
if amountOfUndelegationsExecuted == 0 {
dereferencedAsset.IsInitialized = false
Copy link
Member

Choose a reason for hiding this comment

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

Here we should delete the alliance asset instead of setting IsInitialized to be false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@javiersuweijie shouldn't the alliance be deleted only when all the tokens have been unbonded?

@emidev98 emidev98 closed this Mar 14, 2024
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