Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log minOutAmount properly #181

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions service/amount_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ func (s *Service) GetQuote(ctx context.Context, symbol models.Symbol, side model
return models.QuoteRes{}, models.ErrIterFail
}
if !it.HasNext() {
logctx.Debug(ctx, "insufficient liquidity", logger.String("symbol", symbol.String()), logger.String("side", side.String()), logger.String("inAmount", inAmount.String()), logger.String("minOutAmount", fmt.Sprintf("%v", minOutAmount)))
logctx.Warn(ctx, "insufficient liquidity", logger.String("symbol", symbol.String()), logger.String("side", side.String()), logger.String("inAmount", inAmount.String()), logger.String("minOutAmount", minOutAmount.String()))
return models.QuoteRes{}, models.ErrInsufficientLiquity
}
res, err = getOutAmountInAToken(ctx, it, inAmount)

} else { // SELL
it = s.orderBookStore.GetMaxBid(ctx, symbol)
if it == nil {
logctx.Error(ctx, "GetMaxBid failed no orders in iterator")
logctx.Warn(ctx, "GetMaxBid failed no orders in iterator")
return models.QuoteRes{}, models.ErrIterFail
}
if !it.HasNext() {
Expand All @@ -50,6 +50,7 @@ func (s *Service) GetQuote(ctx context.Context, symbol models.Symbol, side model

// apply min amount out threshold
if minOutAmount != nil && (*minOutAmount).GreaterThanOrEqual(res.Size) {
logctx.Info(ctx, "minOutAmount was applied", logger.String("minOutAmount", minOutAmount.String()), logger.String("amountOut", res.Size.String()))
return models.QuoteRes{}, models.ErrMinOutAmount
}

Expand Down
Loading