put sign check back

This commit is contained in:
c9s 2022-04-23 15:23:43 +08:00
parent 7b66d36f15
commit 5c2274c55c

View File

@ -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)
}