deposit2transfer: optimize slack messages

This commit is contained in:
c9s 2024-11-14 16:16:02 +08:00
parent ac0dfff59d
commit 10e3323c88
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -246,13 +246,21 @@ func (s *Strategy) checkDeposits(ctx context.Context) {
err2 := retry.GeneralBackoff(ctx, func() error {
return s.marginTransferService.TransferMarginAccountAsset(ctx, d.Asset, amount, types.TransferIn)
})
if err2 != nil {
logger.WithError(err2).Errorf("unable to transfer deposit asset into the margin account")
if s.SlackAlert != nil {
bbgo.PostLiveNote(&d,
livenote.Channel(s.SlackAlert.Channel),
livenote.Comment(fmt.Sprintf("Margin account transfer error: %+v", err2)),
livenote.Comment(fmt.Sprintf(":cross_mark: Margin account transfer error: %+v", err2)),
)
}
} else {
if s.SlackAlert != nil {
bbgo.PostLiveNote(&d,
livenote.Channel(s.SlackAlert.Channel),
livenote.Comment(fmt.Sprintf(":check_mark_button: %s %s transferred successfully", amount.String(), d.Asset)),
)
}
}