smart-contracts/backlog/tasks/task-3 - Port-ConvictionVot...

1.6 KiB

id title status assignee created_date labels dependencies references priority
TASK-3 Port ConvictionVoting to Solidity To Do
2026-04-03 21:39
solidity
core
governance
TASK-1
/home/jeffe/Github/myco-bonding-curve/src/primitives/conviction.py
high

Description

Translate src/primitives/conviction.py to Solidity.

Core functions:

  • stake(voter, proposalId, amount) — stake governance tokens on a proposal
  • unstake(voter, proposalId, amount) — remove stake
  • tick() — advance epoch, update all conviction values, check triggers
  • trigger_threshold(supply, requested_share) — calculate threshold: rho*S / ((1-alpha)(beta-share)^2)
  • update_conviction(current, staked, alpha) — y_{t+1} = alpha * y_t + staked
  • getProposal(id) — view conviction, trigger, passed status

Design decisions:

  • Alpha stored as WAD fraction (e.g., 0.9e18)
  • Proposals have min_age before they can pass
  • Conviction calculated per-proposal from aggregate stakes
  • Events: ProposalCreated, Staked, Unstaked, ProposalPassed, EpochAdvanced
  • Consider gas optimization: batch epoch updates, lazy evaluation
  • Integrate with OpenZeppelin Governor as extension or standalone

Acceptance Criteria

  • #1 Conviction accumulates correctly per epoch (matches Python model within 0.01%)
  • #2 Trigger threshold formula matches Python implementation
  • #3 Proposals pass only after min_age AND conviction > trigger
  • #4 Staking respects voter token balance
  • #5 Gas cost per tick() < 200k for 10 proposals