README.md
3.67 Kb · 123 lines
Governance
Decentralized protocol governance via GNS staking and voting.
Overview
Governance system enables GNS holders to stake for xGNS voting power, create proposals, and vote on protocol changes. For more details, check out docs.
Configuration
The governance.Config type defines the core governance parameters. All values can be modified through governance proposals. This type can be found in the config.gno file.
| Field | Description | Default |
|---|---|---|
VotingStartDelay |
Delay before voting starts after proposal creation | 1 day |
VotingPeriod |
Duration for collecting votes | 7 days |
VotingWeightSmoothingDuration |
Period for averaging voting weight (prevents flash loans) | 1 day |
Quorum |
Percentage of active xGNS required for proposal passage | 50% |
ProposalCreationThreshold |
Minimum GNS balance required to create a proposal | 1,000 GNS |
ExecutionDelay |
Waiting period after voting ends before execution | 1 day |
ExecutionWindow |
Time window during which an approved proposal can be executed | 30 days |
Core Mechanics
Staking Flow
1GNS → Stake → xGNS (voting power) → Delegate → Vote
- Stake GNS to receive equal xGNS
- Delegate voting power (can be self)
- Vote on proposals with delegated power
- 7-day lockup for undelegation
Proposal Types
- Text: Signal proposals without execution
- CommunityPoolSpend: Treasury disbursements
- ParameterChange: Protocol parameter updates
Proposal Lifecycle
Creation
- Requires 1,000 GNS balance
- One active proposal per address
- Valid type and parameters required
Voting
- 1 day delay before voting starts
- 7 days voting period
- Weight = 24hr average delegation (prevents flash loans)
Execution
A proposal is considered valid and executable when:
- The voting period has ended
- Total votes meet the quorum threshold (50% of xGNS total supply)
- The execution delay period (configured via
ExecutionDelaydefault: 24 hours) has passed after voting ends - Within the execution window period (configured via
ExecutionWindowdefault: 30 days)ExecutionDelayandExecutionWindoware configured through thegovernance.Configtype.
- Anyone can trigger execution once conditions are met
Technical Details
Vote Weight Calculation
1// 24-hour average prevents manipulation
2snapshot1 = getDelegationAt(proposalTime - 24hr)
3snapshot2 = getDelegationAt(proposalTime)
4voteWeight = (snapshot1 + snapshot2) / 2
Quorum Calculation
1activeXGNS = totalXGNS - launchpadXGNS
2quorumAmount = activeXGNS * quorumPercent / 100 // quorumPercent defaults to 50
The quorum threshold is calculated based on the Quorum percentage (default: 50%) of the active xGNS supply at the time of proposal creation. A proposal passes when either the accumulated YES or NO votes reach or exceed this quorum amount.
Rewards Distribution
xGNS holders earn protocol fees:
1userShare = (userXGNS / totalXGNS) * protocolFees
Usage
1// Stake GNS for xGNS
2Delegate(amount, delegateTo)
3
4// Create proposal
5ProposeText(title, description, body)
6ProposeCommunityPoolSpend(recipient, amount)
7ProposeParameterChange(params)
8
9// Vote on proposal
10Vote(proposalId, true) // YES
11Vote(proposalId, false) // NO
12
13// Execute after timelock
14Execute(proposalId)
15
16// Undelegate (7-day lockup)
17Undelegate()
Security
- Flash loan protection via vote smoothing
- Sybil resistance through stake weighting
- Timelock prevents rushed execution
- Single proposal limit per address
- Dynamic quorum excludes inactive xGNS