Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/update interface for pool tracker #154

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/KyberNetwork/blockchain-toolkit v0.2.0
github.com/KyberNetwork/elastic-go-sdk/v2 v2.0.2
github.com/KyberNetwork/ethrpc v0.3.0
github.com/KyberNetwork/ethrpc v0.4.0
github.com/KyberNetwork/logger v0.1.0
github.com/KyberNetwork/pancake-v3-sdk v0.1.0
github.com/daoleno/uniswap-sdk-core v0.1.7
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/KyberNetwork/elastic-go-sdk/v2 v2.0.2 h1:kN7ez6MPJEaFbacmvR+22PRa5pJk
github.com/KyberNetwork/elastic-go-sdk/v2 v2.0.2/go.mod h1:3DThBH6zHAYSWUVmtj9deQO1XuiwbawdKxj5yV4SuMo=
github.com/KyberNetwork/ethrpc v0.3.0 h1:LoqtmSR4ABgsCvSc+qPUbPibPhVZpd12YQLbMGAyVWk=
github.com/KyberNetwork/ethrpc v0.3.0/go.mod h1:QOlJ7bWKIVlo3ZfJt3cmyc5oke9uU+4hl9Vth5IHK/Y=
github.com/KyberNetwork/ethrpc v0.4.0 h1:ghG8s8D/V9fWAQMnTicIDUv0I6VFDSqN3T6kbE9No6c=
github.com/KyberNetwork/ethrpc v0.4.0/go.mod h1:QOlJ7bWKIVlo3ZfJt3cmyc5oke9uU+4hl9Vth5IHK/Y=
github.com/KyberNetwork/logger v0.1.0 h1:Iibu9Ls+tipjR+C0iXhzUYM1VtRgmmR1HHWGufPYcbs=
github.com/KyberNetwork/logger v0.1.0/go.mod h1:zBqHbtJ3nJn6HQnp6UW8pbQkR+U6tSRFd5CzfiKL3Kw=
github.com/KyberNetwork/pancake-v3-sdk v0.1.0 h1:HVUD13Qbwl4kiU1uSprQVpkis6fYYp3A32mVuK+f1Iw=
Expand Down Expand Up @@ -114,6 +116,7 @@ github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9yS
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/algebrav1/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/sourcegraph/conc/pool"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
sourcePool "github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/bignumber"
graphqlPkg "github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql"
)
Expand All @@ -38,7 +39,11 @@ func NewPoolTracker(
}, nil
}

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

var (
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/balancer-composable-stable/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/valueobject"
)

Expand All @@ -28,7 +29,11 @@ func NewPoolTracker(
}, nil
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
logger.WithFields(logger.Fields{
"poolAddress": p.Address,
}).Infof("[Balancer-Composable-Stable] Start updating state ...")
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/balancer/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -27,7 +28,11 @@ func NewPoolTracker(
}, nil
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
logger.WithFields(logger.Fields{
"poolAddress": p.Address,
}).Infof("[Balancer] Start updating state ...")
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/biswap/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -25,7 +26,11 @@ func NewPoolTracker(
}, nil
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
logger.WithFields(logger.Fields{
"poolAddress": p.Address,
}).Infof("[%s] Start getting new state of pool", d.config.DexID)
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/camelot/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/timer"
)

Expand All @@ -26,7 +27,11 @@ func NewPoolTracker(cfg *Config, ethrpcClient *ethrpc.Client) *PoolTracker {
}
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
finish := timer.Start(fmt.Sprintf("[%s] get new pool state", d.cfg.DexID))
defer finish()

Expand Down
2 changes: 2 additions & 0 deletions pkg/source/curve/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -34,6 +35,7 @@ func NewPoolTracker(
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
switch p.Type {
case poolTypeBase:
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/dmm/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -23,7 +24,11 @@ func NewPoolTracker(
}, nil
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
logger.WithFields(logger.Fields{
"poolAddress": p.Address,
}).Infof("[DMM] Start getting new state of pool")
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/dodo/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
cmap "github.com/orcaman/concurrent-map"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -39,7 +40,11 @@ func NewPoolTracker(
}, nil
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
var staticExtraData = struct {
Type string `json:"type"`
}{}
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/dystopia/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -20,7 +21,11 @@ func NewPoolTracker(ethrpcClient *ethrpc.Client) *PoolTracker {
}
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
log := logger.WithFields(logger.Fields{
"poolAddress": p.Address,
})
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/elastic/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/sourcegraph/conc/pool"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
sourcePool "github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
graphqlPkg "github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql"
)

Expand All @@ -35,7 +36,11 @@ func NewPoolTracker(
}, nil
}

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

var (
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/fraxswap/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -22,7 +23,11 @@ func NewPoolTracker(ethrpcClient *ethrpc.Client) *PoolTracker {
}
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
log := logger.WithFields(logger.Fields{
"poolAddress": p.Address,
})
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/gmx/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -27,7 +28,11 @@ func NewPoolTracker(
}, nil
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
log := logger.WithFields(logger.Fields{
"liquiditySource": DexTypeGmx,
"poolAddress": p.Address,
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/ironstable/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/timer"
)

Expand All @@ -26,7 +27,11 @@ func NewPoolTracker(cfg *Config, ethrpcClient *ethrpc.Client) (*PoolTracker, err
}, nil
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
finish := timer.Start(fmt.Sprintf("[%s] get new pool state", d.cfg.DexID))
defer finish()

Expand Down
7 changes: 6 additions & 1 deletion pkg/source/iziswap/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/KyberNetwork/ethrpc"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
sourcePool "github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
"github.com/KyberNetwork/logger"
"github.com/ethereum/go-ethereum/common"
"github.com/izumiFinance/iZiSwap-SDK-go/swap"
Expand All @@ -31,7 +32,11 @@ func NewPoolTracker(
}, nil
}

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

g := pool.New().WithContext(ctx)
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/kyber-pmm/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -24,7 +25,11 @@ func NewPoolTracker(cfg *Config, client IClient) *PoolTracker {
}
}

func (t *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (t *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
logger.Infof("[Kyber PMM] Start getting new states for pool %v", p.Address)

if len(p.Tokens) != 2 {
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/lido-steth/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/KyberNetwork/logger"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -21,7 +22,11 @@ func NewPoolTracker(ethrpcClient *ethrpc.Client) *PoolTracker {
}
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
log := logger.WithFields(logger.Fields{
"poolAddress": p.Address,
})
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/lido/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/common"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -23,7 +24,11 @@ func NewPoolTracker(ethrpcClient *ethrpc.Client) *PoolTracker {
}
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
log := logger.WithFields(logger.Fields{
"poolAddress": p.Address,
})
Expand Down
7 changes: 6 additions & 1 deletion pkg/source/limitorder/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"golang.org/x/sync/errgroup"

"github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity"
"github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pool"
)

type PoolTracker struct {
Expand All @@ -27,7 +28,11 @@ func NewPoolTracker(cfg *Config) *PoolTracker {
}
}

func (d *PoolTracker) GetNewPoolState(ctx context.Context, p entity.Pool) (entity.Pool, error) {
func (d *PoolTracker) GetNewPoolState(
ctx context.Context,
p entity.Pool,
_ pool.GetNewPoolStateParams,
) (entity.Pool, error) {
logger.Infof("[LimitOrder] Start getting new states for pool %v", p.Address)
if len(p.Tokens) < 2 {
err := errors.New("number of token should be greater than or equal 2")
Expand Down
Loading