Skip to content

feat(contracts): vote delegation for VotingEscrow (Governor Bravo over decaying ve-weight) #670

Closed

Description

@alpergundogdu

Motivation

ADR 009 § Delegation specifies a Governor Bravo delegate(address) pattern over ve-balance: a ve-locker may assign their (non-transferable) voting weight to another address for casting votes. DecdnGovernor currently ships without delegation — each voter votes their own ve-balance, read directly from VotingEscrow.balanceOfAt (see DecdnGovernor._getVotes). This issue tracks adding delegation.

This is not blocking governance: voting works today with self-weight. Delegation is a participation/UX enhancement, deferred to post-PoC.

Why it was deferred (the hard part)

Delegation here is materially harder than OpenZeppelin ERC20Votes/IVotes delegation. ERC20Votes checkpoints a static voting-unit count per delegate. ve-weight decays continuously (amount × remaining_lock / maxLock), so a delegate's weight at a snapshot is the time-varying sum of its delegators' decaying balances — not a static number. Correctly supporting getPastVotes(delegate, ts) therefore requires per-delegate bias/slope checkpointing inside VotingEscrow (aggregate a delegate's inbound delegations as a piecewise-linear curve, analogous to the existing global supply checkpoint with scheduled slope changes at lock expiries), plus moving a delegator's bias/slope between delegates on delegate() / re-delegation / lock changes.

Scope

  1. VotingEscrow delegation machinery:
    • delegate(address), delegateBySig(...) (EIP-712), delegates(address) views.
    • Per-delegate inbound aggregate checkpoints (bias, slope, scheduled slope changes) so delegatedBalanceOfAt(delegate, ts) returns the decayed sum of inbound delegations + the delegate's own undelegated ve-balance.
    • Move a delegator's bias/slope on delegate(), re-delegation, increaseAmount, increaseUnlockTime, and withdraw.
    • Events: DelegateChanged, DelegateVotesChanged (or ve-appropriate equivalents).
  2. DecdnGovernor rewire: _getVotes reads the delegated weight instead of balanceOfAt; quorum / proposalThreshold continue to use total ve-supply. Decide whether to adopt OZ IVotes/GovernorVotes (if the VE delegation surface is made IERC-5805-conformant) or keep the thin custom override. The Governor's external interface should be unaffected.

Acceptance criteria

  • ve-lockers can delegate/redelegate/revoke; effective at the next snapshot (ADR 009 § Delegation).
  • Delegated weight decays correctly over time (differential tests vs. summing balanceOfAt(delegator, ts) across delegators at multiple timestamps).
  • Lock mutations (increase amount / extend / withdraw) correctly update the delegate's aggregate.
  • DecdnGovernor counts delegated weight; quorum/threshold unchanged; no Governor interface change.
  • ADR 009 § Delegation and ADR 026 governance table flipped back from "Deferred" to "Supported".

References

  • contracts/src/DecdnGovernor.sol (current self-weight _getVotes)
  • contracts/src/VotingEscrow.sol (checkpoint/slope machinery to extend)
  • ADR 009 § Delegation; ADR 026 § Voting weight = ve-balance

Activity

  1. added
    kind:feature
    on May 22, 2026
  2. github-actions commented on May 22, 2026

    @github-actions

    🎯 Triage report

    This issue tracks adding Governor Bravo-style delegate(address) support to VotingEscrow and wiring DecdnGovernor._getVotes to use delegated weight instead of raw balanceOfAt. The hard part — already well-articulated — is that ve-weight decays continuously, so per-delegate checkpointing must track bias/slope curves (not static counts like ERC20Votes). Explicitly deferred to post-PoC; governance works today with self-weight only.

    📊 Assessment

    Dimension Value Reasoning
    Type Feature New delegation capability; existing governance remains functional
    Labels enhancement, technical, prod-blocking (already applied) Accurate — post-PoC enhancement with non-trivial Solidity complexity
    Coding agent Needs more info Scope and acceptance criteria are clear, but one open design decision remains unresolved: whether to implement IERC-5805/IVotes conformance in VotingEscrow and switch DecdnGovernor to OZ GovernorVotes, or keep the thin custom _getVotes override. This choice affects the full delegation API surface and should be settled before implementation begins.
    💡 Notes and suggestions

    Key design decision to resolve first:
    IVotes/IERC-5805 conformance vs. custom thin wrapper. The tradeoff:

    • IERC-5805 conformant: enables OZ GovernorVotes drop-in, tooling/wallet compatibility (eth_call getPastVotes), but getPastVotes(delegate, ts) must return a uint256 representing the decayed aggregate — semantically unusual compared to static-token delegates.
    • Custom thin override: DecdnGovernor._getVotes calls a new delegatedBalanceOfAt(delegate, ts) directly; no interface baggage; easier to audit. Probably the right default given the non-standard decay semantics.

    Implementation sub-tasks (suggested order):

    • VotingEscrow data structures: add mapping(address => address) public delegates and per-delegate Point checkpoint arrays + scheduled slope changes (mirror the global supply structure).
    • _moveDelegates(from, to, bias, slope, endTs): internal helper that removes inbound bias/slope from from's aggregate and applies it to to; used by all mutation paths.
    • delegate(address newDelegate) + delegateBySig (EIP-712 typed data): call _moveDelegates after updating the mapping.
    • Mutation hooks: patch createLock, increaseAmount, increaseUnlockTime, and withdraw to call _moveDelegates when the caller has a non-self delegate.
    • delegatedBalanceOfAt(address delegate, uint256 ts): binary-search the per-delegate checkpoint array and evaluate the piecewise-linear curve at ts (same algorithm as balanceOfAt but over the aggregate slope).
    • DecdnGovernor._getVotes: swap VotingEscrow.balanceOfAt(account, ts) → VotingEscrow.delegatedBalanceOfAt(account, ts).
    • Differential fuzz tests: for each snapshot timestamp, assert delegatedBalanceOfAt(delegate, ts) == Σ balanceOfAt(delegatori, ts) across all delegators.
    • ADR updates: flip ADR 009 § Delegation and ADR 026 governance table from "Deferred" to "Supported".

    Potential pitfalls:

    • Lock expiry scheduled slope changes must be maintained per-delegate (not just globally) to avoid phantom voting weight after locks expire.
    • Re-delegation (A→B then A→C) must first remove A's contribution from B before adding to C; a two-step _moveDelegates call.
    • withdraw must zero out the delegator's bias/slope from the delegate aggregate before unlocking tokens.
    • Gas: per-delegate checkpointing adds two SSTOREs per delegate()/lock-mutation; acceptable but worth noting in the PR.

    Reference art:

    • Curve's VotingEscrow.vy does not support delegation (by design); Frax's veFXS and Ribbon's veRBN both added delegation on top — their slope-bookkeeping patches are worth reviewing.
    • OZ ERC20Votes source is a useful structural template even if the static-checkpoint model doesn't apply directly.

    Generated by Agentic Triage for issue #670 · ● 1.5M · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:feature

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions