-
Notifications
You must be signed in to change notification settings - Fork 2
/
fee_pool.go
29 lines (24 loc) · 965 Bytes
/
fee_pool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package keeper
import (
sdk "github.com/hdac-io/friday/types"
"github.com/hdac-io/friday/x/distribution/types"
)
// DistributeFromFeePool distributes funds from the distribution module account to
// a receiver address while updating the community pool
func (k Keeper) DistributeFromFeePool(ctx sdk.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) sdk.Error {
feePool := k.GetFeePool(ctx)
// NOTE the community pool isn't a module account, however its coins
// are held in the distribution module account. Thus the community pool
// must be reduced separately from the SendCoinsFromModuleToAccount call
newPool, negative := feePool.CommunityPool.SafeSub(sdk.NewDecCoins(amount))
if negative {
return types.ErrBadDistribution(k.codespace)
}
feePool.CommunityPool = newPool
err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receiveAddr, amount)
if err != nil {
return err
}
k.SetFeePool(ctx, feePool)
return nil
}