48 lines
1.6 KiB
Markdown
48 lines
1.6 KiB
Markdown
---
|
|
id: TASK-3
|
|
title: Port ConvictionVoting to Solidity
|
|
status: To Do
|
|
assignee: []
|
|
created_date: '2026-04-03 21:39'
|
|
labels:
|
|
- solidity
|
|
- core
|
|
- governance
|
|
dependencies:
|
|
- TASK-1
|
|
references:
|
|
- /home/jeffe/Github/myco-bonding-curve/src/primitives/conviction.py
|
|
priority: high
|
|
---
|
|
|
|
## Description
|
|
|
|
<!-- SECTION:DESCRIPTION:BEGIN -->
|
|
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
|
|
<!-- SECTION:DESCRIPTION:END -->
|
|
|
|
## Acceptance Criteria
|
|
<!-- AC:BEGIN -->
|
|
- [ ] #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
|
|
<!-- AC:END -->
|