/
fees.go
34 lines (27 loc) · 1.03 KB
/
fees.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
30
31
32
33
34
//nolint
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/furynet/furymod/modules/farm/types"
)
// DeductPoolCreationFee performs fee handling for creating farm pool
func (k Keeper) DeductPoolCreationFee(ctx sdk.Context, creator sdk.AccAddress) error {
params := k.GetParams(ctx)
poolCreationFee := params.PoolCreationFee
// compute community tax and burned coin
communityTaxCoin := sdk.NewCoin(poolCreationFee.Denom,
sdk.NewDecFromInt(poolCreationFee.Amount).Mul(params.TaxRate).TruncateInt())
burnedCoins := sdk.NewCoins(poolCreationFee.Sub(communityTaxCoin))
// send all fees to module account
if err := k.bk.SendCoinsFromAccountToModule(
ctx, creator, types.ModuleName, sdk.NewCoins(poolCreationFee),
); err != nil {
return err
}
// send community tax to feeCollector
if err := k.bk.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.feeCollectorName, sdk.NewCoins(communityTaxCoin)); err != nil {
return err
}
// burn burnedCoin
return k.bk.BurnCoins(ctx, types.ModuleName, burnedCoins)
}