Skip to content

Commit

Permalink
chore: improve log for shared handler saddle (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
lehainam-dev authored Jun 22, 2023
1 parent 964aab8 commit 57d1709
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion pkg/source/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package source

import (
"fmt"

"github.com/KyberNetwork/ethrpc"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/balancer"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/biswap"
Expand Down Expand Up @@ -386,7 +387,9 @@ func NewPoolTrackerHandler(
case oneswap.DexTypeOneSwap:
return oneswap.NewPoolTracker(ethrpcClient), nil
case saddle.DexTypeSaddle:
return saddle.NewPoolTracker(ethrpcClient), nil
var cfg saddle.Config
cfg.DexID = scanDexCfg.Id
return saddle.NewPoolTracker(&cfg, ethrpcClient), nil
case nerve.DexTypeNerve:
var cfg nerve.Config
err := PropertiesToStruct(scanDexCfg.Properties, &cfg)
Expand Down
8 changes: 5 additions & 3 deletions pkg/source/saddle/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ import (
)

type PoolTracker struct {
config *Config
ethrpcClient *ethrpc.Client
}

func NewPoolTracker(ethrpcClient *ethrpc.Client) *PoolTracker {
func NewPoolTracker(cfg *Config, ethrpcClient *ethrpc.Client) *PoolTracker {
return &PoolTracker{
config: cfg,
ethrpcClient: ethrpcClient,
}
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
logger.Infof("[Saddle] Start getting new state of pool: %v", p.Address)
logger.Infof("[%s] Start getting new state of pool: %v", d.config.DexID, p.Address)

var (
lpSupply *big.Int
Expand Down Expand Up @@ -92,7 +94,7 @@ func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entit
p.Reserves = reserves
p.Timestamp = time.Now().Unix()

logger.Infof("[Saddle] Finish updating state of pool: %v", p.Address)
logger.Infof("[%s] Finish updating state of pool: %v", d.config.DexID, p.Address)

return p, nil
}
2 changes: 1 addition & 1 deletion pkg/source/saddle/pools_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (d *PoolsListUpdater) initPools(ctx context.Context) ([]entity.Pool, error)
return nil, err
}

logger.Infof("got %v from pool path config file", len(poolItems))
logger.Infof("[%s] got %v from pool path config file", d.config.DexID, len(poolItems))

pools, err := d.processBatch(ctx, poolItems)
if err != nil {
Expand Down

0 comments on commit 57d1709

Please sign in to comment.