func setMatchTxArguments(txInput *types.TxInput, isPartialTrade bool, position int, receiveAmounts uint64, isMaker bool) {
traderType := contract.Taker
+ feeRate := takerFeeRate
if isMaker {
traderType = contract.Maker
+ feeRate = makerFeeRate
}
var arguments [][]byte
if isPartialTrade {
- arguments = [][]byte{vm.Int64Bytes(int64(receiveAmounts)), vm.Int64Bytes(int64(position)), vm.Int64Bytes(contract.PartialTradeClauseSelector), vm.Int64Bytes(traderType)}
+ arguments = [][]byte{vm.Int64Bytes(int64(receiveAmounts)), vm.Int64Bytes(int64(position)), vm.Int64Bytes(contract.PartialTradeClauseSelector), vm.Int64Bytes(feeRate)}
} else {
arguments = [][]byte{vm.Int64Bytes(int64(position)), vm.Int64Bytes(contract.FullTradeClauseSelector), vm.Int64Bytes(traderType)}
}
ErrInvalidAmountOfFee = errors.New("amount of fee is invalid")
)
+const (
+ // rate of fee in units of 10000
+ makerFeeRate int64 = 0
+ takerFeeRate int64 = 3
+)
+
// AllocatedAssets represent reallocated assets after calculating fees
type AllocatedAssets struct {
Receives []*bc.AssetAmount
}
func (d *DefaultFeeStrategy) calcFeeAmount(amount uint64, isMaker bool) uint64 {
+ feeRate := takerFeeRate
if isMaker {
- return 0
+ feeRate = makerFeeRate
}
- return uint64(math.Ceil(float64(amount) / 1000))
+ return uint64(math.Ceil(float64(amount) * float64(feeRate) / 1E4))
}