From 70d26ff7752e7cbce19e219ce34f3288790c3ad8 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 14 Nov 2024 15:38:30 +0800 Subject: [PATCH] deposit2transfer: ignore dust deposits --- pkg/strategy/deposit2transfer/strategy.go | 26 +++++++++++++++++++++++ pkg/strategy/xmaker/signal_book.go | 1 + 2 files changed, 27 insertions(+) diff --git a/pkg/strategy/deposit2transfer/strategy.go b/pkg/strategy/deposit2transfer/strategy.go index 3cd9ebd6b..0bb7fd80f 100644 --- a/pkg/strategy/deposit2transfer/strategy.go +++ b/pkg/strategy/deposit2transfer/strategy.go @@ -55,6 +55,9 @@ type Strategy struct { Interval types.Duration `json:"interval"` TransferDelay types.Duration `json:"transferDelay"` + IgnoreDust bool `json:"ignoreDust"` + DustAmounts map[string]fixedpoint.Value `json:"dustAmounts"` + SlackAlert *SlackAlert `json:"slackAlert"` marginTransferService marginTransferService @@ -85,6 +88,15 @@ func (s *Strategy) Defaults() error { s.TransferDelay = types.Duration(3 * time.Second) } + if s.DustAmounts == nil { + s.DustAmounts = map[string]fixedpoint.Value{ + "USDC": fixedpoint.NewFromFloat(1.0), + "USDT": fixedpoint.NewFromFloat(1.0), + "BTC": fixedpoint.NewFromFloat(0.00001), + "ETH": fixedpoint.NewFromFloat(0.00001), + } + } + return nil } @@ -129,6 +141,16 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se return nil } +func (s *Strategy) isDust(asset string, amount fixedpoint.Value) bool { + if s.IgnoreDust { + if dustAmount, ok := s.DustAmounts[asset]; ok { + return amount.Compare(dustAmount) <= 0 + } + } + + return false +} + func (s *Strategy) tickWatcher(ctx context.Context, interval time.Duration) { ticker := time.NewTicker(interval) defer ticker.Stop() @@ -284,6 +306,10 @@ func (s *Strategy) scanDepositHistory(ctx context.Context, asset string, duratio continue } + if s.isDust(asset, deposit.Amount) { + continue + } + // if the deposit record is already in the watch list, update it if _, ok := s.watchingDeposits[deposit.TransactionID]; ok { s.addWatchingDeposit(deposit) diff --git a/pkg/strategy/xmaker/signal_book.go b/pkg/strategy/xmaker/signal_book.go index ecfb36637..c9612af78 100644 --- a/pkg/strategy/xmaker/signal_book.go +++ b/pkg/strategy/xmaker/signal_book.go @@ -28,6 +28,7 @@ type StreamBookSetter interface { type OrderBookBestPriceVolumeSignal struct { RatioThreshold fixedpoint.Value `json:"ratioThreshold"` MinVolume fixedpoint.Value `json:"minVolume"` + MinQuoteVolume fixedpoint.Value `json:"minQuoteVolume"` symbol string book *types.StreamOrderBook