From 31069e567fc19a4b560ce23b1dee2257317757e5 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 31 Dec 2024 11:32:35 +0800 Subject: [PATCH] deposit2transfer: try to repay with the maximum available balance --- pkg/strategy/deposit2transfer/strategy.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/deposit2transfer/strategy.go b/pkg/strategy/deposit2transfer/strategy.go index 349c23ca3..b44a849be 100644 --- a/pkg/strategy/deposit2transfer/strategy.go +++ b/pkg/strategy/deposit2transfer/strategy.go @@ -293,7 +293,8 @@ func (s *Strategy) repay(ctx context.Context, d types.Deposit, amount fixedpoint s.logger.Infof("found %s balance debt: %s", d.Asset, bal.Debt().String()) - amount = fixedpoint.Min(bal.Debt(), amount) + amount = fixedpoint.Min(bal.Debt(), + fixedpoint.Max(amount, bal.Available)) if amount.Sign() <= 0 { s.logger.Infof("%s has no debt to repay", d.Asset)