-
Notifications
You must be signed in to change notification settings - Fork 0
/
fees.go
34 lines (27 loc) · 1.04 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/coinswap/types"
)
// DeductPoolCreationFee performs fee handling for creating liquidity 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)
}