Skip to main content
Version: Next

x/protocolpool

Concepts

Protopool is a module that handle functionality around community pool funds. This provides a separate module account for community pool making it easier to track the pool assets. We no longer track community pool assets in distribution module, but instead in this protocolpool module. Funds are migrated from the distribution module's community pool to protocolpool's module account.

The module is also designed with a lazy "claim-based" system, which means that users are required to actively claim allocated funds from allocated budget if any budget proposal has been submitted and passed. The module does not automatically distribute funds to recipients. This design choice allows for more flexibility and control over fund distribution.

State Transitions

FundCommunityPool

FundCommunityPool can be called by any valid account to send funds to the protocolpool module account.

  // FundCommunityPool defines a method to allow an account to directly
// fund the community pool.
rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse);

CommunityPoolSpend

CommunityPoolSpend can be called by the module authority (default governance module account) or any account with authorization to spend funds from the protocolpool module account to a receiver address.

  // CommunityPoolSpend defines a governance  operation for sending tokens from
// the community pool in the x/protocolpool module to another account, which
// could be the governance module itself. The authority is defined in the
// keeper.
rpc CommunityPoolSpend(MsgCommunityPoolSpend) returns (MsgCommunityPoolSpendResponse);

SubmitBudgetProposal

SubmitBudgetProposal is a message used to propose a budget allocation for a specific recipient. The proposed funds will be distributed periodically over a specified time frame.

It's the responsibility of users to actively claim their allocated funds based on the terms of the approved budget proposals.

  // SubmitBudgetProposal defines a method to set a budget proposal.
rpc SubmitBudgetProposal(MsgSubmitBudgetProposal) returns (MsgSubmitBudgetProposalResponse);

ClaimBudget

ClaimBudget is a message used to claim funds from a previously submitted budget proposal. When a budget proposal is approved and funds are allocated, recipients can use this message to claim their share of the budget. Funds are distributed in tranches over specific periods, and users can claim their share of budget at the appropriate time.

  // ClaimBudget defines a method to claim the distributed budget.
rpc ClaimBudget(MsgClaimBudget) returns (MsgClaimBudgetResponse);

Messages

MsgFundCommunityPool

This message sends coins directly from the sender to the community pool.

tip

If you know the protocolpool module account address, you can directly use bank send transaction instead. ::::

proto/cosmos/protocolpool/v1/tx.proto
loading...
  • The msg will fail if the amount cannot be transferred from the sender to the protocolpool module account.
func (k Keeper) FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error {
return k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, amount)
}

MsgCommunityPoolSpend

This message distributes funds from the protocolpool module account to the recipient using DistributeFromFeePool keeper method.

proto/cosmos/protocolpool/v1/tx.proto
loading...

The message will fail under the following conditions:

  • The amount cannot be transferred to the recipient from the protocolpool module account.
  • The recipient address is restricted
func (k Keeper) DistributeFromFeePool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error {
return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receiveAddr, amount)
}

MsgSubmitBudgetProposal

This message is used to submit a budget proposal to allocate funds for a specific recipient. The proposed funds will be distributed periodically over a specified time frame.

proto/cosmos/protocolpool/v1/tx.proto
loading...

The message will fail under the following conditions:

  • The total budget is zero.
  • The recipient address is empty or restricted.
  • The start time is less than current block time.
  • The number of tranches is not a positive integer.
  • The period length is not a positive integer.

If two budgets to the same address are created, the budget would be updated with the new budget. :::

x/protocolpool/keeper/msg_server.go
loading...

MsgClaimBudget

This message is used to claim funds from a previously submitted budget proposal. When a budget proposal is passed and funds are allocated, recipients can use this message to claim their share of the budget.

proto/cosmos/protocolpool/v1/tx.proto
loading...

The message will fail under the following conditions:

  • The recipient address is empty or restricted.
  • The budget proposal for the recipient does not exist.
  • The budget proposal has not reached its distribution start time.
  • The budget proposal's distribution period has not passed yet.
x/protocolpool/keeper/msg_server.go
loading...

Client

It takes the advantage of AutoCLI

x/protocolpool/autocli.go
loading...