Skip to content

fix: show delegatable balance in delegate modal, not current voting power#22

Open
marinom2 wants to merge 2 commits into
lightchain-protocol:mainfrom
marinom2:fix/delegate-show-delegatable-balance
Open

fix: show delegatable balance in delegate modal, not current voting power#22
marinom2 wants to merge 2 commits into
lightchain-protocol:mainfrom
marinom2:fix/delegate-show-delegatable-balance

Conversation

@marinom2

Copy link
Copy Markdown
Contributor

Summary

The modal displayed current voting power (getVotes) as the amount being delegated. That is incorrect: delegating moves the weight of the tokens you hold (your balance), not the votes currently counted for you. This shows balance and voting power as separate values, surfaces incoming delegations, and disables the action when there is nothing to delegate.

The bug

getVotes and balance diverge once you delegate away or receive delegations from others:

  • A wallet that delegated its votes to someone else has getVotes 0 but can still re-delegate the weight of its balance. The old UI showed "0 to delegate", which is wrong.
  • A wallet holding 0 tokens but holding votes delegated to it by others has getVotes greater than 0 but can delegate nothing, since incoming delegations are not transitive. The old UI showed an amount it cannot actually delegate.

The number that matters for delegating is always your token balance.

Changes

  • Two rows: "Your LCAI balance" (what you delegate) and "Your voting power" (what currently counts for you).
  • A "Delegated to you" row appears when others have delegated to you.
  • The "Currently delegated to" line now shows the delegated amount.
  • The action note is driven by balance; when balance is 0 it becomes a warning and the button is disabled, since there is nothing to delegate.

Note on stacking

This is stacked on #21 (the "Return votes to yourself" relabel). Until #21 merges, this PR's diff includes that commit as well, so review the second commit (show delegatable balance...) here. Once #21 is merged I will rebase so this shows only its own change.

Scope

One file, components/delegation/delegate-modal.tsx.

marinom2 added 2 commits July 1, 2026 00:19
… delegated

When a wallet is currently delegated to another address, the "Delegate to
yourself" option is really an undelegate action. Rename it to "Return votes
to yourself" in that case, with a subtitle explaining it restores your own
voting power, and label the action button "Return votes". When the wallet is
self-delegated, the wording stays "Delegate to yourself" as before.

This is wording only; there is no change to the delegation logic.
…ower

The modal displayed current voting power (getVotes) as the amount being
delegated. That is wrong: delegating moves the weight of the tokens you
hold (your balance), not the votes currently counted for you. The two
diverge once you delegate away or receive delegations from others.

On the native-votes chain this produced misleading numbers:
- a wallet that delegated its votes away showed "0 to delegate" even
  though it can still re-delegate the weight of its balance
- a wallet holding 0 tokens but holding votes delegated to it showed an
  amount it cannot actually delegate, since incoming delegations are not
  transitive

Changes:
- show "Your LCAI balance" (what you delegate) and "Your voting power"
  (what currently counts for you) as separate rows
- add a "Delegated to you" row when others have delegated to you
- show the delegated amount on the "Currently delegated to" line
- drive the action note off balance, and when balance is 0 switch to a
  warning and disable the button since there is nothing to delegate
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@marinom2 is attempting to deploy a commit to the Lightchain AI Team on Vercel.

A member of the Team first needs to authorize it.

lightchainaidev
lightchainaidev previously approved these changes Jul 1, 2026
@marinom2 marinom2 dismissed lightchainaidev’s stale review July 1, 2026 11:14

The merge-base changed after approval.

lightchainaidev
lightchainaidev previously approved these changes Jul 1, 2026
@marinom2 marinom2 dismissed lightchainaidev’s stale review July 1, 2026 11:24

The merge-base changed after approval.

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