From c134b91d45e82363c39e50074356afe07e968f15 Mon Sep 17 00:00:00 2001 From: Andrey Mashukov Date: Mon, 8 Jul 2024 13:19:09 +0800 Subject: [PATCH] Swap validation changed --- src/config/container.go | 38 +++++++++----- src/service/exchange/sbb_swap_finder.go | 13 +++-- src/service/exchange/sbs_swap_finder.go | 13 +++-- src/service/exchange/ssb_swap_finder.go | 13 +++-- src/service/exchange/swap_executor.go | 36 ++++++++------ src/validator/swap_validator.go | 4 +- tests/sbb_swap_finder_test.go | 66 ++++++++++++++++--------- tests/sbs_swap_finder_test.go | 44 +++++++++++------ tests/ssb_swap_finder_test.go | 22 ++++++--- 9 files changed, 156 insertions(+), 93 deletions(-) diff --git a/src/config/container.go b/src/config/container.go index 1568c7e..db82477 100644 --- a/src/config/container.go +++ b/src/config/container.go @@ -207,16 +207,25 @@ func InitServiceContainer() Container { SwapRepository: &swapRepository, Formatter: &formatter, SBSSwapFinder: &exchange.SBSSwapFinder{ - ExchangeRepository: &exchangeRepository, - Formatter: &formatter, + ExchangeRepository: &exchangeRepository, + Formatter: &formatter, + SwapFirstAmendmentSteps: 10, + SwapSecondAmendmentSteps: 50, + SwapThirdAmendmentSteps: 250, }, SSBSwapFinder: &exchange.SSBSwapFinder{ - ExchangeRepository: &exchangeRepository, - Formatter: &formatter, + ExchangeRepository: &exchangeRepository, + Formatter: &formatter, + SwapFirstAmendmentSteps: 10, + SwapSecondAmendmentSteps: 50, + SwapThirdAmendmentSteps: 250, }, SBBSwapFinder: &exchange.SBBSwapFinder{ - ExchangeRepository: &exchangeRepository, - Formatter: &formatter, + ExchangeRepository: &exchangeRepository, + Formatter: &formatter, + SwapFirstAmendmentSteps: 10, + SwapSecondAmendmentSteps: 50, + SwapThirdAmendmentSteps: 250, }, } @@ -401,13 +410,16 @@ func InitServiceContainer() Container { CallbackManager: &callbackManager, SwapRepository: &swapRepository, SwapExecutor: &exchange.SwapExecutor{ - BalanceService: &balanceService, - SwapRepository: &swapRepository, - OrderRepository: &orderRepository, - Binance: exchangeApi, - Formatter: &formatter, - TimeService: &timeService, - CurrentBot: currentBot, + BalanceService: &balanceService, + SwapRepository: &swapRepository, + OrderRepository: &orderRepository, + Binance: exchangeApi, + Formatter: &formatter, + TimeService: &timeService, + CurrentBot: currentBot, + SwapFirstAmendmentSteps: 10, + SwapSecondAmendmentSteps: 50, + SwapThirdAmendmentSteps: 250, }, SwapValidator: &swapValidator, Formatter: &formatter, diff --git a/src/service/exchange/sbb_swap_finder.go b/src/service/exchange/sbb_swap_finder.go index 70e28ef..cb4b633 100644 --- a/src/service/exchange/sbb_swap_finder.go +++ b/src/service/exchange/sbb_swap_finder.go @@ -11,8 +11,11 @@ import ( ) type SBBSwapFinder struct { - ExchangeRepository repository.SwapPairRepositoryInterface - Formatter *utils.Formatter + ExchangeRepository repository.SwapPairRepositoryInterface + Formatter *utils.Formatter + SwapFirstAmendmentSteps float64 + SwapSecondAmendmentSteps float64 + SwapThirdAmendmentSteps float64 } func (s *SBBSwapFinder) Find(asset string) model.BBSArbitrageChain { @@ -35,7 +38,7 @@ func (s *SBBSwapFinder) Find(asset string) model.BBSArbitrageChain { // Do not validate first order for gainer/looser and bull/bear - option0Price := option0.SellPrice - (option0.MinPrice * SwapFirstAmendmentSteps) + option0Price := option0.SellPrice - (option0.MinPrice * s.SwapFirstAmendmentSteps) option0Price = s.Formatter.FormatPrice(option0, option0Price) //log.Printf("[%s] formatted [3] %f -> %f", option0.Symbol, option0.SellPrice, option0Price) sell0Quantity := initialBalance //s.Formatter.FormatQuantity(option0, initialBalance) @@ -68,7 +71,7 @@ func (s *SBBSwapFinder) Find(asset string) model.BBSArbitrageChain { continue } - option1Price := option1.BuyPrice + (option1.MinPrice * SwapSecondAmendmentSteps) + option1Price := option1.BuyPrice + (option1.MinPrice * s.SwapSecondAmendmentSteps) option1Price = s.Formatter.FormatPrice(option1, option1Price) //log.Printf("[%s] formatted [4] %f -> %f", option1.Symbol, option1.BuyPrice, option1Price) buy0Quantity := sell0.Balance //s.Formatter.FormatQuantity(option1, sell0.Balance) @@ -101,7 +104,7 @@ func (s *SBBSwapFinder) Find(asset string) model.BBSArbitrageChain { continue } - option2Price := option2.BuyPrice + (option2.MinPrice * SwapThirdAmendmentSteps) + option2Price := option2.BuyPrice + (option2.MinPrice * s.SwapThirdAmendmentSteps) option2Price = s.Formatter.FormatPrice(option2, option2Price) //log.Printf("[%s] formatted [5] %f -> %f", option2.Symbol, option2.BuyPrice, option2Price) buy1Quantity := buy0.Balance //s.Formatter.FormatQuantity(option2, buy0.Balance) diff --git a/src/service/exchange/sbs_swap_finder.go b/src/service/exchange/sbs_swap_finder.go index 10d06c1..d0d2330 100644 --- a/src/service/exchange/sbs_swap_finder.go +++ b/src/service/exchange/sbs_swap_finder.go @@ -11,8 +11,11 @@ import ( ) type SBSSwapFinder struct { - ExchangeRepository repository.SwapPairRepositoryInterface - Formatter *utils.Formatter + ExchangeRepository repository.SwapPairRepositoryInterface + Formatter *utils.Formatter + SwapFirstAmendmentSteps float64 + SwapSecondAmendmentSteps float64 + SwapThirdAmendmentSteps float64 } func (s *SBSSwapFinder) Find(asset string) model.BBSArbitrageChain { @@ -35,7 +38,7 @@ func (s *SBSSwapFinder) Find(asset string) model.BBSArbitrageChain { // Do not validate first order for gainer/looser and bull/bear - option0Price := option0.SellPrice - (option0.MinPrice * SwapFirstAmendmentSteps) + option0Price := option0.SellPrice - (option0.MinPrice * s.SwapFirstAmendmentSteps) option0Price = s.Formatter.FormatPrice(option0, option0Price) //log.Printf("[%s] formatted [3] %f -> %f", option0.Symbol, option0.SellPrice, option0Price) sell0Quantity := initialBalance //s.Formatter.FormatQuantity(option0, initialBalance) @@ -68,7 +71,7 @@ func (s *SBSSwapFinder) Find(asset string) model.BBSArbitrageChain { continue } - option1Price := option1.BuyPrice + (option1.MinPrice * SwapSecondAmendmentSteps) + option1Price := option1.BuyPrice + (option1.MinPrice * s.SwapSecondAmendmentSteps) option1Price = s.Formatter.FormatPrice(option1, option1Price) //log.Printf("[%s] formatted [4] %f -> %f", option1.Symbol, option1.BuyPrice, option1Price) buy0Quantity := sell0.Balance //s.Formatter.FormatQuantity(option1, sell0.Balance) @@ -101,7 +104,7 @@ func (s *SBSSwapFinder) Find(asset string) model.BBSArbitrageChain { continue } - option2Price := option2.SellPrice - (option2.MinPrice * SwapThirdAmendmentSteps) + option2Price := option2.SellPrice - (option2.MinPrice * s.SwapThirdAmendmentSteps) option2Price = s.Formatter.FormatPrice(option2, option2Price) //log.Printf("[%s] formatted [5] %f -> %f", option2.Symbol, option2.BuyPrice, option2Price) buy1Quantity := buy0.Balance //s.Formatter.FormatQuantity(option2, buy0.Balance) diff --git a/src/service/exchange/ssb_swap_finder.go b/src/service/exchange/ssb_swap_finder.go index a60dd4e..381cd2b 100644 --- a/src/service/exchange/ssb_swap_finder.go +++ b/src/service/exchange/ssb_swap_finder.go @@ -11,8 +11,11 @@ import ( ) type SSBSwapFinder struct { - ExchangeRepository repository.SwapPairRepositoryInterface - Formatter *utils.Formatter + ExchangeRepository repository.SwapPairRepositoryInterface + Formatter *utils.Formatter + SwapFirstAmendmentSteps float64 + SwapSecondAmendmentSteps float64 + SwapThirdAmendmentSteps float64 } func (s *SSBSwapFinder) Find(asset string) model.BBSArbitrageChain { @@ -35,7 +38,7 @@ func (s *SSBSwapFinder) Find(asset string) model.BBSArbitrageChain { // Do not validate first order for gainer/looser and bull/bear - option0Price := option0.SellPrice - (option0.MinPrice * SwapFirstAmendmentSteps) + option0Price := option0.SellPrice - (option0.MinPrice * s.SwapFirstAmendmentSteps) option0Price = s.Formatter.FormatPrice(option0, option0Price) //log.Printf("[%s] formatted [1] %f -> %f", option0.Symbol, option0.BuyPrice, option0Price) buy0Quantity := initialBalance //s.Formatter.FormatQuantity(option0, initialBalance) @@ -64,7 +67,7 @@ func (s *SSBSwapFinder) Find(asset string) model.BBSArbitrageChain { continue } - option1Price := option1.SellPrice - (option1.MinPrice * SwapSecondAmendmentSteps) + option1Price := option1.SellPrice - (option1.MinPrice * s.SwapSecondAmendmentSteps) option1Price = s.Formatter.FormatPrice(option1, option1Price) //log.Printf("[%s] formatted [1] %f -> %f", option1.Symbol, option1.BuyPrice, option1Price) buy1Quantity := buy0.Balance //s.Formatter.FormatQuantity(option1, buy0.Balance) @@ -97,7 +100,7 @@ func (s *SSBSwapFinder) Find(asset string) model.BBSArbitrageChain { continue } - option2Price := option2.BuyPrice + (option2.MinPrice * SwapThirdAmendmentSteps) + option2Price := option2.BuyPrice + (option2.MinPrice * s.SwapThirdAmendmentSteps) option2Price = s.Formatter.FormatPrice(option2, option2Price) //log.Printf("[%s] formatted [2] %f -> %f", option2.Symbol, option2.BuyPrice, option2Price) sell1Quantity := buy1.Balance //s.Formatter.FormatQuantity(option2, buy1.Balance) diff --git a/src/service/exchange/swap_executor.go b/src/service/exchange/swap_executor.go index 6ea95ed..99ec368 100644 --- a/src/service/exchange/swap_executor.go +++ b/src/service/exchange/swap_executor.go @@ -13,9 +13,9 @@ import ( "time" ) -const SwapFirstAmendmentSteps = 5 -const SwapSecondAmendmentSteps = 10 -const SwapThirdAmendmentSteps = 15 +const SwapFirstAmendmentSteps = 10 +const SwapSecondAmendmentSteps = 50 +const SwapThirdAmendmentSteps = 250 const SwapStepCommission = 0.002 type SwapExecutorInterface interface { @@ -23,13 +23,16 @@ type SwapExecutorInterface interface { } type SwapExecutor struct { - SwapRepository repository.SwapBasicRepositoryInterface - OrderRepository repository.OrderUpdaterInterface - BalanceService BalanceServiceInterface - Binance client.ExchangeOrderAPIInterface - TimeService utils.TimeServiceInterface - Formatter *utils.Formatter - CurrentBot *model.Bot + SwapRepository repository.SwapBasicRepositoryInterface + OrderRepository repository.OrderUpdaterInterface + BalanceService BalanceServiceInterface + Binance client.ExchangeOrderAPIInterface + TimeService utils.TimeServiceInterface + Formatter *utils.Formatter + CurrentBot *model.Bot + SwapFirstAmendmentSteps float64 + SwapSecondAmendmentSteps float64 + SwapThirdAmendmentSteps float64 } func (s *SwapExecutor) Execute(order model.Order) { @@ -112,7 +115,7 @@ func (s *SwapExecutor) ExecuteSwapOne(swapAction *model.SwapAction, order model. swapPrice := swapAction.SwapOnePrice swapPair, err := s.SwapRepository.GetSwapPairBySymbol(swapAction.SwapOneSymbol) // Price can grow before we start processing, take max price for swap - swapPrice = math.Max(swapPrice, swapPair.SellPrice-(swapPair.MinPrice*SwapFirstAmendmentSteps)) + swapPrice = math.Max(swapPrice, swapPair.SellPrice-(swapPair.MinPrice*s.SwapFirstAmendmentSteps)) binanceOrder, err := s.Binance.LimitOrder( swapAction.SwapOneSymbol, @@ -310,7 +313,7 @@ func (s *SwapExecutor) ExecuteSwapTwo( if swapChain.IsSSB() { // Price can grow before we start processing, take max price for swap - swapPrice = math.Max(swapPrice, swapPair.SellPrice-(swapPair.MinPrice*SwapSecondAmendmentSteps)) + swapPrice = math.Max(swapPrice, swapPair.SellPrice-(swapPair.MinPrice*s.SwapSecondAmendmentSteps)) binanceOrder, err = s.Binance.LimitOrder( swapAction.SwapTwoSymbol, @@ -323,7 +326,7 @@ func (s *SwapExecutor) ExecuteSwapTwo( if swapChain.IsSBB() || swapChain.IsSBS() { // Price can fall down before we start processing, take min price for swap - swapPrice = math.Min(swapPrice, swapPair.BuyPrice+(swapPair.MinPrice*SwapSecondAmendmentSteps)) + swapPrice = math.Min(swapPrice, swapPair.BuyPrice+(swapPair.MinPrice*s.SwapSecondAmendmentSteps)) binanceOrder, err = s.Binance.LimitOrder( swapAction.SwapTwoSymbol, @@ -472,6 +475,7 @@ func (s *SwapExecutor) ExecuteSwapThree( quantity = swapTwoOrder.ExecutedQty } + // todo: check difference and validate... if quantity > balance { quantity = balance } @@ -492,7 +496,7 @@ func (s *SwapExecutor) ExecuteSwapThree( if swapChain.IsSSB() || swapChain.IsSBB() { // Price can fall down before we start processing, take min price for swap - swapPrice = math.Min(swapPrice, swapPair.BuyPrice+(swapPair.MinPrice*SwapThirdAmendmentSteps)) + swapPrice = math.Min(swapPrice, swapPair.BuyPrice+(swapPair.MinPrice*s.SwapThirdAmendmentSteps)) binanceOrder, err = s.Binance.LimitOrder( swapAction.SwapThreeSymbol, @@ -505,7 +509,7 @@ func (s *SwapExecutor) ExecuteSwapThree( if swapChain.IsSBS() { // Price can grow before we start processing, take max price for swap - swapPrice = math.Max(swapPrice, swapPair.SellPrice-(swapPair.MinPrice*SwapThirdAmendmentSteps)) + swapPrice = math.Max(swapPrice, swapPair.SellPrice-(swapPair.MinPrice*s.SwapThirdAmendmentSteps)) binanceOrder, err = s.Binance.LimitOrder( swapAction.SwapThreeSymbol, @@ -709,6 +713,7 @@ func (s *SwapExecutor) TryRollbackSwapTwo( price = swapPair.BuyPrice + (swapPair.MinPrice * i) quantity := swapOneOrder.CummulativeQuoteQty + // todo: check difference and validate... if quantity > balance { quantity = balance } @@ -833,6 +838,7 @@ func (s *SwapExecutor) TryForceSwapThree( return err } + // todo: check difference and validate... if quantity > balance { quantity = balance } diff --git a/src/validator/swap_validator.go b/src/validator/swap_validator.go index ea20724..59ce6ce 100644 --- a/src/validator/swap_validator.go +++ b/src/validator/swap_validator.go @@ -103,11 +103,11 @@ func (v *SwapValidator) validateSwap(chain model.SwapChainEntity, order model.Or return errors.New(fmt.Sprintf("Swap [%s:%s] price is expired", entity.Operation, entity.Symbol)) } - if entity.IsBuy() && v.Formatter.ComparePercentage(entity.Price, swapCurrentKline.BuyPrice).Gte(100.10) { + if entity.IsBuy() && v.Formatter.ComparePercentage(entity.Price, swapCurrentKline.BuyPrice).Gte(100.50) { return errors.New(fmt.Sprintf("Swap [%s:%s] price is too high", entity.Operation, entity.Symbol)) } - if entity.IsSell() && v.Formatter.ComparePercentage(entity.Price, swapCurrentKline.SellPrice).Lte(99.90) { + if entity.IsSell() && v.Formatter.ComparePercentage(entity.Price, swapCurrentKline.SellPrice).Lte(99.50) { return errors.New(fmt.Sprintf("Swap [%s:%s] price is too low", entity.Operation, entity.Symbol)) } diff --git a/tests/sbb_swap_finder_test.go b/tests/sbb_swap_finder_test.go index 078ed18..abb2fdd 100644 --- a/tests/sbb_swap_finder_test.go +++ b/tests/sbb_swap_finder_test.go @@ -52,8 +52,11 @@ func TestSwapSellBuyBuy(t *testing.T) { //exchangeRepoMock.On("GetSwapPairsByQuoteAsset", "GBP").Return(options2) swapManager := exchange.SBBSwapFinder{ - Formatter: &utils.Formatter{}, - ExchangeRepository: exchangeRepoMock, + Formatter: &utils.Formatter{}, + ExchangeRepository: exchangeRepoMock, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } chain := swapManager.Find("SOL").BestChain @@ -307,12 +310,15 @@ func TestSwapSellBuyBuy(t *testing.T) { timeServiceMock.On("GetNowDiffMinutes", mock.Anything).Return(0.50) executor := exchange.SwapExecutor{ - SwapRepository: swapRepoMock, - OrderRepository: orderRepositoryMock, - BalanceService: balanceServiceMock, - Binance: binanceMock, - TimeService: timeServiceMock, - Formatter: &utils.Formatter{}, + SwapRepository: swapRepoMock, + OrderRepository: orderRepositoryMock, + BalanceService: balanceServiceMock, + Binance: binanceMock, + TimeService: timeServiceMock, + Formatter: &utils.Formatter{}, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } executor.Execute(order) @@ -368,8 +374,11 @@ func TestSwapSellBuyBuyRollback(t *testing.T) { //exchangeRepoMock.On("GetSwapPairsByQuoteAsset", "GBP").Return(options2) swapManager := exchange.SBBSwapFinder{ - Formatter: &utils.Formatter{}, - ExchangeRepository: exchangeRepoMock, + Formatter: &utils.Formatter{}, + ExchangeRepository: exchangeRepoMock, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } chain := swapManager.Find("SOL").BestChain @@ -628,12 +637,15 @@ func TestSwapSellBuyBuyRollback(t *testing.T) { }, nil) executor := exchange.SwapExecutor{ - SwapRepository: swapRepoMock, - OrderRepository: orderRepositoryMock, - BalanceService: balanceServiceMock, - Binance: binanceMock, - TimeService: timeServiceMock, - Formatter: &utils.Formatter{}, + SwapRepository: swapRepoMock, + OrderRepository: orderRepositoryMock, + BalanceService: balanceServiceMock, + Binance: binanceMock, + TimeService: timeServiceMock, + Formatter: &utils.Formatter{}, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } executor.Execute(order) @@ -692,8 +704,11 @@ func TestSwapSellBuyBuyForceSwap(t *testing.T) { //exchangeRepoMock.On("GetSwapPairsByQuoteAsset", "GBP").Return(options2) swapManager := exchange.SBBSwapFinder{ - Formatter: &utils.Formatter{}, - ExchangeRepository: exchangeRepoMock, + Formatter: &utils.Formatter{}, + ExchangeRepository: exchangeRepoMock, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } chain := swapManager.Find("SOL").BestChain @@ -977,12 +992,15 @@ func TestSwapSellBuyBuyForceSwap(t *testing.T) { }, nil) executor := exchange.SwapExecutor{ - SwapRepository: swapRepoMock, - OrderRepository: orderRepositoryMock, - BalanceService: balanceServiceMock, - Binance: binanceMock, - TimeService: timeServiceMock, - Formatter: &utils.Formatter{}, + SwapRepository: swapRepoMock, + OrderRepository: orderRepositoryMock, + BalanceService: balanceServiceMock, + Binance: binanceMock, + TimeService: timeServiceMock, + Formatter: &utils.Formatter{}, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } executor.Execute(order) diff --git a/tests/sbs_swap_finder_test.go b/tests/sbs_swap_finder_test.go index 1969b17..7ebb1b2 100644 --- a/tests/sbs_swap_finder_test.go +++ b/tests/sbs_swap_finder_test.go @@ -47,8 +47,11 @@ func TestSwapSellBuySell(t *testing.T) { exchangeRepoMock.On("GetSwapPairsByBaseAsset", "XRP").Return(options2) sbsFinder := exchange.SBSSwapFinder{ - ExchangeRepository: exchangeRepoMock, - Formatter: &utils.Formatter{}, + ExchangeRepository: exchangeRepoMock, + Formatter: &utils.Formatter{}, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } chain := sbsFinder.Find("ETH").BestChain @@ -315,12 +318,15 @@ func TestSwapSellBuySell(t *testing.T) { timeServiceMock.On("GetNowDiffMinutes", mock.Anything).Return(0.50) executor := exchange.SwapExecutor{ - SwapRepository: swapRepoMock, - OrderRepository: orderRepositoryMock, - BalanceService: balanceServiceMock, - Binance: binanceMock, - TimeService: timeServiceMock, - Formatter: &utils.Formatter{}, + SwapRepository: swapRepoMock, + OrderRepository: orderRepositoryMock, + BalanceService: balanceServiceMock, + Binance: binanceMock, + TimeService: timeServiceMock, + Formatter: &utils.Formatter{}, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } executor.Execute(order) @@ -373,8 +379,11 @@ func TestSwapSellBuySellForceSwap(t *testing.T) { exchangeRepoMock.On("GetSwapPairsByBaseAsset", "XRP").Return(options2) sbsFinder := exchange.SBSSwapFinder{ - ExchangeRepository: exchangeRepoMock, - Formatter: &utils.Formatter{}, + ExchangeRepository: exchangeRepoMock, + Formatter: &utils.Formatter{}, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } chain := sbsFinder.Find("ETH").BestChain @@ -674,12 +683,15 @@ func TestSwapSellBuySellForceSwap(t *testing.T) { timeServiceMock.On("GetNowDiffMinutes", mock.Anything).Return(50.00) executor := exchange.SwapExecutor{ - SwapRepository: swapRepoMock, - OrderRepository: orderRepositoryMock, - BalanceService: balanceServiceMock, - Binance: binanceMock, - TimeService: timeServiceMock, - Formatter: &utils.Formatter{}, + SwapRepository: swapRepoMock, + OrderRepository: orderRepositoryMock, + BalanceService: balanceServiceMock, + Binance: binanceMock, + TimeService: timeServiceMock, + Formatter: &utils.Formatter{}, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } executor.Execute(order) diff --git a/tests/ssb_swap_finder_test.go b/tests/ssb_swap_finder_test.go index 1c595ce..7c68056 100644 --- a/tests/ssb_swap_finder_test.go +++ b/tests/ssb_swap_finder_test.go @@ -53,8 +53,11 @@ func TestSwapSellSellBuy(t *testing.T) { exchangeRepoMock.On("GetSwapPairsByBaseAsset", "GBP").Return(options4) swapManager := &exchange.SSBSwapFinder{ - Formatter: &utils.Formatter{}, - ExchangeRepository: exchangeRepoMock, + Formatter: &utils.Formatter{}, + ExchangeRepository: exchangeRepoMock, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } chain := swapManager.Find("SOL").BestChain @@ -320,12 +323,15 @@ func TestSwapSellSellBuy(t *testing.T) { timeServiceMock.On("GetNowDiffMinutes", mock.Anything).Return(0.50) executor := exchange.SwapExecutor{ - SwapRepository: swapRepoMock, - OrderRepository: orderRepositoryMock, - BalanceService: balanceServiceMock, - Binance: binanceMock, - TimeService: timeServiceMock, - Formatter: &utils.Formatter{}, + SwapRepository: swapRepoMock, + OrderRepository: orderRepositoryMock, + BalanceService: balanceServiceMock, + Binance: binanceMock, + TimeService: timeServiceMock, + Formatter: &utils.Formatter{}, + SwapFirstAmendmentSteps: 5, + SwapSecondAmendmentSteps: 10, + SwapThirdAmendmentSteps: 15, } executor.Execute(order)