xbalance: add foreign fee for withdrawal

This commit is contained in:
c9s 2021-06-09 01:33:40 +08:00
parent 18f72a9118
commit 990da5ad3b

View File

@ -109,9 +109,10 @@ func (r *WithdrawalRequest) SlackAttachment() slack.Attachment {
}
type Address struct {
Address string `json:"address"`
AddressTag string `json:"addressTag"`
Network string `json:"network"`
Address string `json:"address"`
AddressTag string `json:"addressTag"`
Network string `json:"network"`
ForeignFee fixedpoint.Value `json:"foreignFee"`
}
func (a *Address) UnmarshalJSON(body []byte) error {
@ -207,6 +208,10 @@ func (s *Strategy) checkBalance(ctx context.Context, sessions map[string]*bbgo.E
return
}
if toAddress.ForeignFee > 0 {
requiredAmount += toAddress.ForeignFee
}
if s.state != nil {
if s.MaxDailyNumberOfTransfer > 0 {
if s.state.DailyNumberOfTransfers >= s.MaxDailyNumberOfTransfer {
@ -380,4 +385,3 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
return nil
}