Skip to content

Commit

Permalink
Merge pull request #5 from zarbanio/fix-nil-pointer
Browse files Browse the repository at this point in the history
fix market data nil pointer
  • Loading branch information
amintalebi authored Oct 9, 2024
2 parents 1088aa0 + 441fee5 commit ba4a3cf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
30 changes: 18 additions & 12 deletions internal/cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,18 @@ func main(cfg configs.Config) {
Msg("market maker started")

buyDaiInUniswapSellTetherInNobitex := &strategy.BuyDaiUniswapSellTetherNobitex{
Store: postgresStore,
Nobitex: nobitexExchange,
DexQuoter: quoter,
DexTrader: dexTrader,
Tokens: tokens,
UniswapFee: domain.UniswapFeeFee01,
Marketsdata: make(map[strategy.Market]strategy.MarketData),
Config: strategyConfig,
Logger: logger,
Store: postgresStore,
Nobitex: nobitexExchange,
DexQuoter: quoter,
DexTrader: dexTrader,
Tokens: tokens,
UniswapFee: domain.UniswapFeeFee01,
Marketsdata: map[strategy.Market]strategy.MarketData{
strategy.Nobitex: strategy.NewMarketData(),
strategy.UniswapV3: strategy.NewMarketData(),
},
Config: strategyConfig,
Logger: logger,
}
buyTetherInNobitexSellDaiInUniswap := &strategy.SellDaiUniswapBuyTetherNobitex{
Store: postgresStore,
Expand All @@ -187,9 +190,12 @@ func main(cfg configs.Config) {
DexTrader: dexTrader,
Tokens: tokens,
UniswapFee: domain.UniswapFeeFee01,
Marketsdata: make(map[strategy.Market]strategy.MarketData),
Config: strategyConfig,
Logger: logger,
Marketsdata: map[strategy.Market]strategy.MarketData{
strategy.Nobitex: strategy.NewMarketData(),
strategy.UniswapV3: strategy.NewMarketData(),
},
Config: strategyConfig,
Logger: logger,
}

ctx := context.Background()
Expand Down
5 changes: 0 additions & 5 deletions internal/strategy/buy_uniswap_sell_nobitex.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ func (s *BuyDaiUniswapSellTetherNobitex) Name() string {
}

func (s *BuyDaiUniswapSellTetherNobitex) Setup() (MarketsData, error) {
if s.Marketsdata == nil {
marketsdata := make(map[Market]MarketData)
marketsdata[Nobitex] = NewMarketData()
marketsdata[UniswapV3] = NewMarketData()
}
_, err := s.getNobitexBalances()
if err != nil {
return nil, err
Expand Down
5 changes: 0 additions & 5 deletions internal/strategy/sell_uniswap_buy_nobitex.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ func (s *SellDaiUniswapBuyTetherNobitex) Name() string {
}

func (s *SellDaiUniswapBuyTetherNobitex) Setup() (MarketsData, error) {
if s.Marketsdata == nil {
marketsdata := make(map[Market]MarketData)
marketsdata[Nobitex] = NewMarketData()
marketsdata[UniswapV3] = NewMarketData()
}
_, err := s.getNobitexBalances()
if err != nil {
return nil, err
Expand Down

0 comments on commit ba4a3cf

Please sign in to comment.