Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(x/protocolpool): Update README.md #17898

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 49 additions & 12 deletions x/protocolpool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,67 @@ sidebar_position: 1

# `x/protocolpool`
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved

Functionality to handle 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.

## Concepts

## State
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.

```protobuf
// 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.

```protobuf
// 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

## Begin Block
### MsgFundCommunityPool
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved

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

```protobuf reference
https://github.com/cosmos/cosmos-sdk/blob/9dd34510e27376005e7e7ff3628eab9dbc8ad6dc/proto/cosmos/protocolpool/v1/tx.proto#L31-L41
```

## End Block
* The msg will fail if the amount cannot be transferred from the sender to the protocolpool module account.

## Hooks
```go
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
func (k Keeper) FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error {
return k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, amount)
}
```

## Events
### MsgCommunityPoolSpend

## Client
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
This message distributes funds from the protocolpool module account to the recipient using `DistributeFromFeePool` keeper method.

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

## Future Improvements
The message will fail under the following conditions:

## Tests
* The amount cannot be transferred to the recipient from the protocolpool module account.
* The `recipient` address is restricted

## Appendix
```go
func (k Keeper) DistributeFromFeePool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error {
return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receiveAddr, amount)
}
```