cosmos-sdk/x/protocolpool
Emmanuel T Odeke 0692fdc6fd
refactor: create go.mod for x/params (#17776)
Co-authored-by: Julien Robert <julien@rbrt.fr>
2023-10-03 12:56:07 +00:00
..
keeper feat: Move CommunityPool to its own module (#17657) 2023-09-27 09:09:04 +00:00
simulation feat: Move CommunityPool to its own module (#17657) 2023-09-27 09:09:04 +00:00
testutil refactor: create go.mod for x/params (#17776) 2023-10-03 12:56:07 +00:00
types feat: Move CommunityPool to its own module (#17657) 2023-09-27 09:09:04 +00:00
autocli.go feat: Move CommunityPool to its own module (#17657) 2023-09-27 09:09:04 +00:00
go.mod refactor: create go.mod for x/params (#17776) 2023-10-03 12:56:07 +00:00
go.sum refactor: create go.mod for x/params (#17776) 2023-10-03 12:56:07 +00:00
module.go feat: Move CommunityPool to its own module (#17657) 2023-09-27 09:09:04 +00:00
README.md docs(x/protocolpool): Update README.md (#17898) 2023-09-27 11:28:28 +00:00
sonar-project.properties feat: Move CommunityPool to its own module (#17657) 2023-09-27 09:09:04 +00:00

sidebar_position
1

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.

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);

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. ::::

https://github.com/cosmos/cosmos-sdk/blob/9dd34510e27376005e7e7ff3628eab9dbc8ad6dc/proto/cosmos/protocolpool/v1/tx.proto#L31-L41
  • 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.

https://github.com/cosmos/cosmos-sdk/blob/9dd34510e27376005e7e7ff3628eab9dbc8ad6dc/proto/cosmos/protocolpool/v1/tx.proto#L46-L59

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)
}

Client

It takes the advantage of AutoCLI

https://github.com/cosmos/cosmos-sdk/blob/9dd34510e27376005e7e7ff3628eab9dbc8ad6dc/x/protocolpool/autocli.go