第十二章:治理与DAO

学习目标

  • 理解 DAO 的核心概念和组织形式
  • 掌握链上治理机制和投票系统
  • 学习代币经济学和激励设计
  • 了解多签钱包和治理安全
  • 探索 DAO 工具栈和最佳实践

关键词:DAO、链上治理、投票机制、代币经济学、多签钱包、Governor、Snapshot

12.1 什么是 DAO?

DAO 的定义

DAO (Decentralized Autonomous Organization,去中心化自治组织) 是一种基于智能合约的组织形式,通过代码和社区共识进行决策和运营。

传统组织 vs DAO 🏢 传统组织 (Traditional Org) 治理结构: • 等级制 (Hierarchical) • CEO/董事会决策 • 股东投票 (年度) 透明度: 财务不公开 决策过程不透明 执行方式: • 人工执行 • 可能被操纵 • 需要信任中介 准入门槛: 高 (需要许可、KYC) 🌐 DAO (去中心化组织) 治理结构: • 扁平化 (Flat) • 社区投票决策 • 持续提案 (24/7) 透明度: 所有交易链上公开 智能合约代码开源 投票结果实时可见 执行方式: • 智能合约自动执行 • 不可篡改 • 无需信任 (Trustless) 准入门槛: 低 (持有代币即可)

DAO 的发展历史

年份 事件 意义
2016 The DAO 黑客事件 $60M 被盗,导致以太坊硬分叉 (ETH/ETC)
2018 MakerDAO 成立 第一个成功的 DeFi DAO,管理 DAI 稳定币
2020 Compound 发币 开启 DeFi Summer,治理代币成为标配
2021 Constitution DAO 众筹 $47M 竞拍美国宪法副本 (失败但证明潜力)
2023 ARB Airdrop Arbitrum DAO 空投 $10B 代币,最大规模治理代币分发
2025 DAO 工具成熟 Snapshot、Tally、Safe 等工具广泛采用

DAO 的类型

  1. 协议 DAO (Protocol DAO): Uniswap, Aave, Compound - 管理 DeFi 协议
  2. 投资 DAO (Investment DAO): The LAO, MetaCartel Ventures - 集体投资决策
  3. 收藏 DAO (Collector DAO): PleasrDAO, Flamingo DAO - 购买 NFT/艺术品
  4. 社交 DAO (Social DAO): Friends with Benefits (FWB) - 社区成员协作
  5. 服务 DAO (Service DAO): RaidGuild, LexDAO - 提供专业服务
  6. 媒体 DAO (Media DAO): BanklessDAO - 内容创作和分发

12.2 链上治理机制

Governor 合约:OpenZeppelin 标准

链上治理流程 (Governor 合约) 1. 提案创建 (Propose) • 需要最低代币量 (如 100,000 UNI) 2. 投票延迟 (Voting Delay) ⏰ 1-2 天 防止闪电贷攻击 3. 投票期 (Voting Period) ⏰ 3-7 天 🗳️ For / Against / Abstain 4. 结果 (Tally) ✅ 达到 法定人数 5. 时间锁 (Timelock) ⏰ 2 天等待期 允许用户退出 (如果不同意) 6. 执行 (Execute) 🤖 智能合约自动执行 ❌ 提案未通过: • 未达法定人数 (Quorum) • 反对票 > 赞成票 → 提案失败,不执行 关键治理参数 (Governance Parameters) 1. 提案门槛 (Proposal Threshold): • Uniswap: 2.5M UNI (总供应量的 0.25%) • Compound: 100,000 COMP (1%) 2. 法定人数 (Quorum): • Uniswap: 40M UNI (4%) • Aave: 320,000 AAVE (动态调整) 3. 投票权重 (Voting Power): • 1 代币 = 1 票 (Token-weighted) 4. 委托 (Delegation): • 可将投票权委托给专业人士

Governor 合约实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/governance/Governor.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorSettings.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorTimelockControl.sol";

contract MyGovernor is
Governor,
GovernorSettings,
GovernorCountingSimple,
GovernorVotes,
GovernorVotesQuorumFraction,
GovernorTimelockControl
{
constructor(
IVotes _token,
TimelockController _timelock
)
Governor("MyGovernor")
GovernorSettings(
7200, /* 投票延迟: 1 天 (假设 12s/block) */
50400, /* 投票期: 7 天 */
100e18 /* 提案门槛: 100 代币 */
)
GovernorVotes(_token)
GovernorVotesQuorumFraction(4) /* 法定人数: 4% */
GovernorTimelockControl(_timelock)
{}

// 创建提案
function propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description
) public override(Governor) returns (uint256) {
return super.propose(targets, values, calldatas, description);
}

// 投票: 0 = Against, 1 = For, 2 = Abstain
function castVote(uint256 proposalId, uint8 support)
public
override(Governor)
returns (uint256)
{
return super.castVote(proposalId, support);
}

// 执行提案
function execute(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public payable override(Governor) returns (uint256) {
return super.execute(targets, values, calldatas, descriptionHash);
}

// 以下为必需的覆盖函数
function votingDelay() public view override(Governor, GovernorSettings) returns (uint256) {
return super.votingDelay();
}

function votingPeriod() public view override(Governor, GovernorSettings) returns (uint256) {
return super.votingPeriod();
}

function quorum(uint256 blockNumber)
public
view
override(Governor, GovernorVotesQuorumFraction)
returns (uint256)
{
return super.quorum(blockNumber);
}

function proposalThreshold()
public
view
override(Governor, GovernorSettings)
returns (uint256)
{
return super.proposalThreshold();
}

function state(uint256 proposalId)
public
view
override(Governor, GovernorTimelockControl)
returns (ProposalState)
{
return super.state(proposalId);
}

function _execute(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl) {
super._execute(proposalId, targets, values, calldatas, descriptionHash);
}

function _cancel(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl) returns (uint256) {
return super._cancel(targets, values, calldatas, descriptionHash);
}

function _executor()
internal
view
override(Governor, GovernorTimelockControl)
returns (address)
{
return super._executor();
}
}

治理代币:ERC-20Votes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";

contract GovernanceToken is ERC20, ERC20Permit, ERC20Votes {
constructor() ERC20("MyToken", "MTK") ERC20Permit("MyToken") {
_mint(msg.sender, 10_000_000 * 10**18); // 1000万代币
}

// 委托投票权
// 用户可以将投票权委托给其他地址 (如专业投票者)
function delegate(address delegatee) public override {
super.delegate(delegatee);
}

// 查询某地址在特定区块的投票权
function getPastVotes(address account, uint256 blockNumber)
public
view
override
returns (uint256)
{
return super.getPastVotes(account, blockNumber);
}

// 必需的覆盖函数
function _update(address from, address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._update(from, to, amount);
}

function nonces(address owner)
public
view
override(ERC20Permit, Nonces)
returns (uint256)
{
return super.nonces(owner);
}
}

12.3 链下治理:Snapshot

Snapshot 是一个链下投票平台,具有以下优势:

  • 零 Gas 费用:投票签名链下存储
  • 灵活投票策略:支持多种代币权重计算
  • 快速部署:无需部署智能合约
链上治理 vs 链下治理 (Snapshot) ⛓️ 链上治理 (On-Chain) 优点: 自动执行 (Trustless) 不可篡改 完全去中心化 缺点: 高 Gas 费 ($50-500/投票) 投票率低 (通常 < 10%) 部署复杂 适用场景: • 高价值决策 (如协议升级) • 需要强制执行的提案 📸 链下治理 (Snapshot) 优点: 零 Gas 费 (签名投票) 高投票率 (20-40%) 快速部署 (无需合约) 灵活投票策略 缺点: 不自动执行 (需人工) 依赖中心化服务器 适用场景: • 温度检测 (Sentiment Check) • 非关键性决策 (如品牌设计)

Snapshot 投票策略示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Snapshot 投票策略配置 (snapshot.org)
{
"symbol": "UNI",
"name": "Uniswap",
"network": "1", // Ethereum Mainnet
"strategies": [
{
"name": "erc20-balance-of",
"params": {
"address": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
"symbol": "UNI",
"decimals": 18
}
},
{
"name": "delegation", // 支持委托
"params": {
"symbol": "UNI (delegated)",
"strategies": [
{
"name": "erc20-balance-of",
"params": {
"address": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"
}
}
]
}
}
],
"voting": {
"delay": 86400, // 1 天延迟
"period": 604800, // 7 天投票期
"type": "single-choice", // 单选
"quorum": 40000000 // 法定人数: 4000万 UNI
}
}

12.4 代币经济学与激励设计

代币分配模型 (Tokenomics) 25% 社区 20% 团队 15% 投资人 10% 生态 15% 流动性 15% 财库 释放时间表 (Vesting Schedule) 社区 (25%): • 立即释放 50% (空投/流动性挖矿) • 剩余 50% 线性释放 (4 年) 团队 (20%): • 1 年锁定 (Cliff) • 然后 3 年线性释放 投资人 (15%): • 6 个月锁定 • 然后 2 年线性释放 财库 (15%): • DAO 多签控制 • 用于生态激励、合作伙伴 • 需治理投票批准使用 总供应量: 10 亿代币 通胀率: 每年 2% (用于质押奖励)

代币价值捕获机制

机制 说明 示例
治理权 代币持有者可投票决策 UNI, AAVE, COMP
协议收入分红 协议收入分配给质押者 GMX (30% 手续费), veCRV
回购销毁 用协议收入回购并销毁代币 MKR, BNB
质押奖励 质押代币获得通胀奖励 ETH 2.0 (4-5% APR)
ve 模型 锁定越久投票权越高 Curve (veCRV), Balancer (veBAL)

ve (Vote-Escrowed) 代币经济学

Curve 的 veCRV 模型:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 简化版 ve 模型
pragma solidity ^0.8.20;

contract VotingEscrow {
struct LockedBalance {
uint256 amount; // 锁定的代币数量
uint256 unlockTime; // 解锁时间
}

mapping(address => LockedBalance) public locked;

uint256 constant MAX_LOCK_TIME = 4 * 365 days; // 最长 4 年

// 锁定代币获得 veCRV
function createLock(uint256 amount, uint256 lockDuration) external {
require(lockDuration <= MAX_LOCK_TIME, "Lock too long");

locked[msg.sender] = LockedBalance({
amount: amount,
unlockTime: block.timestamp + lockDuration
});

// 转入代币
// token.transferFrom(msg.sender, address(this), amount);
}

// 计算投票权 (线性衰减)
function balanceOf(address user) public view returns (uint256) {
LockedBalance memory userLock = locked[user];

if (block.timestamp >= userLock.unlockTime) {
return 0; // 已解锁,无投票权
}

// 投票权 = 锁定数量 × 剩余时间 / 最长锁定时间
uint256 remainingTime = userLock.unlockTime - block.timestamp;
return userLock.amount * remainingTime / MAX_LOCK_TIME;
}

// 提前解锁 (罚金)
function earlyUnlock() external {
LockedBalance memory userLock = locked[msg.sender];

// 罚金 50%
uint256 penalty = userLock.amount / 2;
uint256 amountToReturn = userLock.amount - penalty;

delete locked[msg.sender];

// 返还代币
// token.transfer(msg.sender, amountToReturn);
// token.transfer(treasury, penalty); // 罚金进入财库
}
}

12.5 多签钱包与治理安全

Gnosis Safe:行业标准

多签钱包工作流程 (Gnosis Safe) 👥 签名者 (Signers) Alice Bob Charlie 3-of-5 多签 (需要 3 个签名) Step 1: Alice 创建交易 提议: 从财库转账 100 ETH 到开发团队 Step 2: Bob & Charlie 签名 ✅ Alice (1/3) → ✅ Bob (2/3) → ✅ Charlie (3/3) ✅ 交易执行 常见配置 2-of-3: 小团队 3-of-5: 中型项目 5-of-9: 大型 DAO 优势: • 防止单点故障 • 透明审计 ⚠️ 安全风险 共谋攻击 → 需要可信签名者 密钥丢失 → 备份恢复方案 延迟攻击 → 设置交易过期时间

Safe 多签合约简化版

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
pragma solidity ^0.8.20;

contract MultiSigWallet {
address[] public owners;
uint256 public required; // 需要的签名数

struct Transaction {
address to;
uint256 value;
bytes data;
bool executed;
uint256 confirmations;
}

Transaction[] public transactions;
mapping(uint256 => mapping(address => bool)) public confirmations;

modifier onlyOwner() {
bool isOwner = false;
for (uint i = 0; i < owners.length; i++) {
if (owners[i] == msg.sender) {
isOwner = true;
break;
}
}
require(isOwner, "Not owner");
_;
}

constructor(address[] memory _owners, uint256 _required) {
require(_owners.length >= _required, "Invalid required");
require(_required > 0, "Required must be > 0");

owners = _owners;
required = _required;
}

// 提交交易
function submitTransaction(address to, uint256 value, bytes memory data)
public
onlyOwner
returns (uint256)
{
uint256 txId = transactions.length;

transactions.push(Transaction({
to: to,
value: value,
data: data,
executed: false,
confirmations: 0
}));

return txId;
}

// 确认交易
function confirmTransaction(uint256 txId) public onlyOwner {
require(!confirmations[txId][msg.sender], "Already confirmed");

confirmations[txId][msg.sender] = true;
transactions[txId].confirmations++;

// 自动执行
if (transactions[txId].confirmations >= required) {
executeTransaction(txId);
}
}

// 执行交易
function executeTransaction(uint256 txId) public {
Transaction storage txn = transactions[txId];

require(!txn.executed, "Already executed");
require(txn.confirmations >= required, "Not enough confirmations");

txn.executed = true;

(bool success,) = txn.to.call{value: txn.value}(txn.data);
require(success, "Transaction failed");
}

// 撤销确认
function revokeConfirmation(uint256 txId) public onlyOwner {
require(confirmations[txId][msg.sender], "Not confirmed");
require(!transactions[txId].executed, "Already executed");

confirmations[txId][msg.sender] = false;
transactions[txId].confirmations--;
}

receive() external payable {}
}

12.6 DAO 工具栈

DAO 工具生态系统 🗳️ 治理工具 Snapshot: 链下投票 (零 Gas) Tally: 链上治理仪表板 Boardroom: 治理聚合器 Governor (OZ): 智能合约标准 💰 财库管理 Gnosis Safe: 多签钱包 Llama: 财库分析 & 策略 Parcel: 批量支付 Hedgey: 代币释放管理 💬 协作 & 沟通 Discord: 社区讨论 (Collabland 验证) Commonwealth: 论坛 & 提案讨论 Discourse: 长篇讨论平台 Notion: 知识库 & 文档 Coordinape: 贡献者奖励分配 ⚙️ 运营工具 Dework: 任务管理 & 赏金 Sourcecred: 贡献度量化 Utopia Labs: 支付自动化 Collab.Land: 代币门控 (Token Gating) Guild.xyz: 角色管理 📊 案例: Uniswap DAO 工具栈 治理: • 链上: Governor 合约 (Ethereum) + Timelock • 链下: Snapshot (温度检测) + Tally (数据展示) 财库: • Gnosis Safe (多签钱包,5-of-9) • Llama (财库分析,$4B+ TVL) 沟通: • Discord (100,000+ 成员) • Discourse 论坛 (提案讨论) 运营: • Grants 计划 (资助生态项目) • 委托制度 (Delegation 给专业投票者)

真实 DAO 统计数据 (2025)

DAO 财库价值 代币持有者 投票率 治理方式
Uniswap $4.2B 400,000+ 8-12% Governor + Snapshot
Arbitrum $3.5B 1,200,000+ 15-20% Governor (ARB)
Optimism $2.8B 800,000+ 18-25% Optimism Collective
MakerDAO $1.5B 120,000+ 25-35% Governor + MKR
Compound $800M 250,000+ 10-15% Governor Bravo
0%