Protocol Pool Module (x/protocolpool)
Thex/protocolpool module provides enhanced community pool functionality for Cosmos SDK chains. It offers a separate module account for tracking community pool assets, continuous funding mechanisms, and better integration with governance and distribution modules.
Overview
Starting with Cosmos SDK v0.53, thex/protocolpool module can replace the community pool functionality of x/distribution. It provides:
- Dedicated module account for community pool assets
- Continuous fund streams for recurring payments to recipients
- Better fund tracking and management
- Governance integration for spending decisions
x/distribution community pool.
Key Concepts
Module Accounts
The protocol pool uses two module accounts:- protocolpool: Main community pool storage
- protocolpool-escrow: Intermediate account for distribution
ContinuousFund
A continuous fund is a recurring payment stream to a specific recipient:- Funds accumulate in the escrow account from block rewards
- In
BeginBlock, the keeper calculates each recipient’s share based on percentage - Funds are transferred to recipients
- Remaining funds go to the main community pool
Keeper Functions
FundCommunityPool
Allow any account to fund the community pool:DistributeFromCommunityPool
Distribute funds from the pool to a recipient:GetCommunityPool
Retrieve the current community pool balance:Message Handlers
MsgFundCommunityPool
Send coins directly to the community pool:MsgCommunityPoolSpend
Spend funds from the community pool (governance or authorized accounts):- Authority must match the module authority address
- Recipient cannot be a blocked address
- Amount must be available in the pool
MsgCreateContinuousFund
Create a continuous fund stream to a recipient:MsgCancelContinuousFund
Cancel an existing continuous fund:Continuous Fund Distribution
The keeper distributes continuous funds inBeginBlock:
Percentage Calculation
- Escrow has 10,000 stake
- Fund A has 10% (0.1)
- Fund B has 5% (0.05)
- Fund A receives: 10,000 * 0.1 = 1,000 stake
- Fund B receives: 10,000 * 0.05 = 500 stake
- Community pool receives: 10,000 - 1,000 - 500 = 8,500 stake
Query Endpoints
CommunityPool
Query the community pool balance:ContinuousFund
Query a specific continuous fund:ContinuousFunds
Query all continuous funds:Module Parameters
CLI Examples
Fund Community Pool
Create Continuous Fund (via Governance)
Query Community Pool
Query Continuous Funds
Integration with x/distribution
Whenx/protocolpool is enabled, x/distribution automatically routes community pool operations to it:
x/distribution endpoints will return errors:
QueryService/CommunityPoolMsgService/CommunityPoolSpendMsgService/FundCommunityPool
Use Cases
Development Team Funding
Security Budget
Marketing Fund
Migration from x/distribution
To migrate fromx/distribution community pool:
- Enable x/protocolpool in your app.go:
- Wire distribution keeper to use protocol pool:
- Migrate funds via upgrade handler:
Best Practices
- Use governance for creating continuous funds to ensure community consensus
- Set expiration times for continuous funds to allow reevaluation
- Monitor percentages to ensure total allocations don’t exceed 100%
- Whitelist denoms in parameters to control which tokens are distributed
- Track distributions via events for transparency
- Set reasonable distribution frequency to balance accuracy and gas costs
Security Considerations
- Only the module authority (governance) can create/cancel continuous funds
- Blocked addresses cannot receive distributions
- Percentages are validated to be between 0 and 1
- Expired funds are automatically removed to prevent stale state
- Distribution failures for unauthorized addresses don’t halt the chain