Skip to content

Commit 13c895b

Browse files
committed
refactor: add log for zksync dexes (#42)
(cherry picked from commit bcf7f05)
1 parent 7f05a00 commit 13c895b

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

pkg/source/muteswitch/pool_tracker.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ func NewPoolTracker(
2626
}
2727

2828
func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
29-
logger.Infof("[MuteSwitch] Start getting new state of pool %v", p.Address)
29+
logger.WithFields(logger.Fields{
30+
"address": p.Address,
31+
}).Infof("[%s] Start getting new state of pool", p.Type)
3032

3133
var (
3234
reserve Reserves
@@ -62,7 +64,9 @@ func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entit
6264
p.SwapFee = float64(pairFee.Int64()) / bps
6365
p.Timestamp = reserve.BlockTimestampLast.Int64()
6466

65-
logger.Infof("[MuteSwitch] Finish getting new state of pool %v", p.Address)
67+
logger.WithFields(logger.Fields{
68+
"address": p.Address,
69+
}).Infof("[%s] Finish getting new state of pool", p.Type)
6670

6771
return p, nil
6872
}

pkg/source/syncswap/pool_tracker.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"math/big"
8+
"time"
9+
710
"github.com/KyberNetwork/ethrpc"
8-
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
911
"github.com/KyberNetwork/logger"
1012
"github.com/ethereum/go-ethereum/common"
11-
"math/big"
12-
"time"
13+
14+
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
1315
)
1416

1517
type PoolTracker struct {
@@ -44,8 +46,7 @@ func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entit
4446
func (d *PoolTracker) getClassicPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
4547
logger.WithFields(logger.Fields{
4648
"address": p.Address,
47-
"type": p.Type,
48-
}).Infof("[Syncswap] Start getting new state of pool")
49+
}).Infof("[%s] Start getting new state of pool", p.Type)
4950

5051
var (
5152
swapFee0To1, swapFee1To0 *big.Int
@@ -121,17 +122,15 @@ func (d *PoolTracker) getClassicPoolState(ctx context.Context, p entity.Pool) (e
121122

122123
logger.WithFields(logger.Fields{
123124
"address": p.Address,
124-
"type": p.Type,
125-
}).Infof("[Syncswap] Finish getting new state of pool")
125+
}).Infof("[%s] Finish getting new state of pool", p.Type)
126126

127127
return p, nil
128128
}
129129

130130
func (d *PoolTracker) getStablePoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
131131
logger.WithFields(logger.Fields{
132132
"address": p.Address,
133-
"type": p.Type,
134-
}).Infof("[Syncswap] Start getting new state of pool")
133+
}).Infof("[%s] Start getting new state of pool", p.Type)
135134

136135
var (
137136
swapFee0To1, swapFee1To0 *big.Int
@@ -224,8 +223,7 @@ func (d *PoolTracker) getStablePoolState(ctx context.Context, p entity.Pool) (en
224223

225224
logger.WithFields(logger.Fields{
226225
"address": p.Address,
227-
"type": p.Type,
228-
}).Infof("[Syncswap] Finish getting new state of pool")
226+
}).Infof("[%s] Finish getting new state of pool", p.Type)
229227

230228
return p, nil
231229
}

pkg/source/velodrome/pool_tracker.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func NewPoolTracker(
2828

2929
func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
3030
logger.WithFields(logger.Fields{
31-
"poolAddress": p.Address,
31+
"address": p.Address,
3232
}).Infof("[%s] Start getting new state of pool", p.Type)
3333

3434
var (
@@ -87,6 +87,10 @@ func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entit
8787
p.SwapFee = float64(swapFee) / bps
8888
p.Timestamp = reserve.BlockTimestampLast.Int64()
8989

90+
logger.WithFields(logger.Fields{
91+
"address": p.Address,
92+
}).Infof("[%s] Finish getting new state of pool", p.Type)
93+
9094
return p, nil
9195
}
9296

0 commit comments

Comments
 (0)