Skip to content

Commit

Permalink
autoborrow: improve debt filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Dec 27, 2024
1 parent 345dca5 commit aaa43ba
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/strategy/autoborrow/alert_interest_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,16 @@ func (w *MarginHighInterestRateWorker) findMarginHighInterestRateAssets(
) (highRates types.MarginNextHourlyInterestRateMap, err error) {
highRates = make(types.MarginNextHourlyInterestRateMap)
for asset, rate := range rateMap {
_, ok := debts[asset]
bal, ok := debts[asset]
if !ok {
continue
}

debt := bal.Debt()
if debt.IsZero() {
continue
}

if rate.AnnualizedRate.IsZero() {
log.Warnf("annualized rate is zero for %s", asset)
}
Expand Down Expand Up @@ -202,10 +207,10 @@ func (w *MarginHighInterestRateWorker) Run(ctx context.Context) {
}

rate := rateMap[cur]
debtValue := bal.Debt().Mul(price)
nextTotalInterestValue = nextTotalInterestValue.Add(
bal.Debt().Mul(rate.HourlyRate).Mul(price))
debtValue.Mul(rate.HourlyRate))

debtValue := bal.Debt().Mul(price)
if w.config.MinDebtAmount.Sign() > 0 &&
debtValue.Compare(w.config.MinDebtAmount) > 0 {
exceededDebtAmount = true
Expand Down

0 comments on commit aaa43ba

Please sign in to comment.