From 5c2274c55c3daef87daef2fc9479f65c4899dc4b Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 23 Apr 2022 15:23:43 +0800 Subject: [PATCH] put sign check back --- pkg/strategy/autoborrow/strategy.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/strategy/autoborrow/strategy.go b/pkg/strategy/autoborrow/strategy.go index 5e6ef246c..aace69b5e 100644 --- a/pkg/strategy/autoborrow/strategy.go +++ b/pkg/strategy/autoborrow/strategy.go @@ -102,6 +102,10 @@ func (s *Strategy) checkAndBorrow(ctx context.Context) { // check if we over borrow if toBorrow.Add(b.Borrowed).Compare(marginAsset.MaxTotalBorrow) > 0 { toBorrow = toBorrow.Sub( toBorrow.Add(b.Borrowed).Sub(marginAsset.MaxTotalBorrow) ) + if toBorrow.Sign() < 0 { + log.Warnf("margin asset %s is over borrowed, skip", marginAsset.Asset) + continue + } } toBorrow = fixedpoint.Min(toBorrow.Add(b.Borrowed), marginAsset.MaxTotalBorrow) }