From 860b8db87dc84265eecfa29a9292ad20020dbb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=E1=BA=A3i=20Nam?= Date: Tue, 22 Oct 2024 14:37:55 +0700 Subject: [PATCH] EX-2312: add tickSpacing to extra when init univ3 pools (#549) --- pkg/source/nuriv2/pool_tracker.go | 2 +- pkg/source/nuriv2/pools_list_updater.go | 21 ++++++++ pkg/source/nuriv2/type.go | 4 +- pkg/source/pancakev3/pools_list_updater.go | 19 +++++++ pkg/source/ramsesv2/pool_tracker.go | 2 +- pkg/source/ramsesv2/pools_list_updater.go | 21 ++++++++ pkg/source/ramsesv2/type.go | 4 +- pkg/source/slipstream/pools_list_updater.go | 20 +++++++ pkg/source/solidly-v3/pool_tracker.go | 2 +- pkg/source/solidly-v3/pools_list_updater.go | 21 ++++++++ pkg/source/solidly-v3/type.go | 2 +- pkg/source/uniswapv3/constant.go | 1 + pkg/source/uniswapv3/pools_list_updater.go | 19 +++++++ pkg/source/uniswapv3/util.go | 58 +++++++++++++++++++++ 14 files changed, 188 insertions(+), 8 deletions(-) create mode 100644 pkg/source/uniswapv3/util.go diff --git a/pkg/source/nuriv2/pool_tracker.go b/pkg/source/nuriv2/pool_tracker.go index 20799a2a2..b988b2e07 100644 --- a/pkg/source/nuriv2/pool_tracker.go +++ b/pkg/source/nuriv2/pool_tracker.go @@ -219,7 +219,7 @@ func (d *PoolTracker) fetchRPCData(ctx context.Context, p entity.Pool, blockNumb Liquidity: liquidity, Slot0: slot0, FeeTier: feeTier.Int64(), - TickSpacing: tickSpacing.Int64(), + TickSpacing: tickSpacing.Uint64(), Reserve0: reserve0, Reserve1: reserve1, }, err diff --git a/pkg/source/nuriv2/pools_list_updater.go b/pkg/source/nuriv2/pools_list_updater.go index a6cffe702..e8eaaf387 100644 --- a/pkg/source/nuriv2/pools_list_updater.go +++ b/pkg/source/nuriv2/pools_list_updater.go @@ -9,20 +9,25 @@ import ( "time" "github.com/KyberNetwork/blockchain-toolkit/integer" + "github.com/KyberNetwork/ethrpc" "github.com/KyberNetwork/logger" "github.com/machinebox/graphql" + "github.com/samber/lo" "github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity" + "github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/uniswapv3" graphqlpkg "github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql" ) type PoolsListUpdater struct { config *Config graphqlClient *graphql.Client + ethrpcClient *ethrpc.Client } func NewPoolsListUpdater( cfg *Config, + ethrpcClient *ethrpc.Client, ) *PoolsListUpdater { graphqlClient := graphqlpkg.New(graphqlpkg.Config{ Url: cfg.SubgraphAPI, @@ -33,6 +38,7 @@ func NewPoolsListUpdater( return &PoolsListUpdater{ config: cfg, graphqlClient: graphqlClient, + ethrpcClient: ethrpcClient, } } @@ -78,11 +84,23 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte logger.Infof("got %v subgraph pools from %s subgraph", numSubgraphPools, d.config.DexID) + tickSpacings, _ := uniswapv3.FetchTickSpacings( + ctx, + lo.Map(subgraphPools, func(item SubgraphPool, _ int) string { return item.ID }), + d.ethrpcClient, + nuriV2PoolABI, + methodTickSpacing, + ) + pools := make([]entity.Pool, 0, len(subgraphPools)) for _, p := range subgraphPools { tokens := make([]*entity.PoolToken, 0, 2) reserves := make([]string, 0, 2) + extraField := Extra{ + TickSpacing: tickSpacings[p.ID], + } + if p.Token0.Address != emptyString { token0Decimals, err := strconv.Atoi(p.Token0.Decimals) @@ -125,6 +143,8 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64) + extraBytes, _ := json.Marshal(extraField) + var newPool = entity.Pool{ Address: p.ID, ReserveUsd: 0, @@ -135,6 +155,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte Timestamp: time.Now().Unix(), Reserves: reserves, Tokens: tokens, + Extra: string(extraBytes), } pools = append(pools, newPool) diff --git a/pkg/source/nuriv2/type.go b/pkg/source/nuriv2/type.go index 4ef32bd86..bbcc17493 100644 --- a/pkg/source/nuriv2/type.go +++ b/pkg/source/nuriv2/type.go @@ -63,7 +63,7 @@ type Extra struct { Liquidity *big.Int `json:"liquidity"` SqrtPriceX96 *big.Int `json:"sqrtPriceX96"` FeeTier int64 `json:"feeTier"` - TickSpacing int64 `json:"tickSpacing"` + TickSpacing uint64 `json:"tickSpacing"` Tick *big.Int `json:"tick"` Ticks []Tick `json:"ticks"` } @@ -82,7 +82,7 @@ type FetchRPCResult struct { Liquidity *big.Int Slot0 Slot0 FeeTier int64 - TickSpacing int64 + TickSpacing uint64 Reserve0 *big.Int Reserve1 *big.Int } diff --git a/pkg/source/pancakev3/pools_list_updater.go b/pkg/source/pancakev3/pools_list_updater.go index cd5961ec0..e61cdf5a4 100644 --- a/pkg/source/pancakev3/pools_list_updater.go +++ b/pkg/source/pancakev3/pools_list_updater.go @@ -9,20 +9,25 @@ import ( "time" "github.com/KyberNetwork/blockchain-toolkit/integer" + "github.com/KyberNetwork/ethrpc" "github.com/KyberNetwork/logger" "github.com/machinebox/graphql" + "github.com/samber/lo" "github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity" + "github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/uniswapv3" graphqlpkg "github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql" ) type PoolsListUpdater struct { config *Config graphqlClient *graphql.Client + ethrpcClient *ethrpc.Client } func NewPoolsListUpdater( cfg *Config, + ethrpcClient *ethrpc.Client, ) *PoolsListUpdater { graphqlClient := graphqlpkg.New(graphqlpkg.Config{ Url: cfg.SubgraphAPI, @@ -33,6 +38,7 @@ func NewPoolsListUpdater( return &PoolsListUpdater{ config: cfg, graphqlClient: graphqlClient, + ethrpcClient: ethrpcClient, } } @@ -83,10 +89,21 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte logger.Infof("got %v subgraph pools from Pancake V3 subgraph", numSubgraphPools) + tickSpacings, _ := uniswapv3.FetchTickSpacings( + ctx, + lo.Map(subgraphPools, func(item SubgraphPool, _ int) string { return item.ID }), + d.ethrpcClient, + pancakeV3PoolABI, + methodTickSpacing, + ) + pools := make([]entity.Pool, 0, len(subgraphPools)) for _, p := range subgraphPools { tokens := make([]*entity.PoolToken, 0, 2) reserves := make([]string, 0, 2) + extraField := Extra{ + TickSpacing: tickSpacings[p.ID], + } staticField := StaticExtra{ PoolId: p.ID, } @@ -133,6 +150,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64) + extraBytes, _ := json.Marshal(extraField) staticBytes, _ := json.Marshal(staticField) var newPool = entity.Pool{ Address: p.ID, @@ -144,6 +162,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte Timestamp: time.Now().Unix(), Reserves: reserves, Tokens: tokens, + Extra: string(extraBytes), StaticExtra: string(staticBytes), } diff --git a/pkg/source/ramsesv2/pool_tracker.go b/pkg/source/ramsesv2/pool_tracker.go index 047810383..aa3e1f9f0 100644 --- a/pkg/source/ramsesv2/pool_tracker.go +++ b/pkg/source/ramsesv2/pool_tracker.go @@ -219,7 +219,7 @@ func (d *PoolTracker) fetchRPCData(ctx context.Context, p entity.Pool, blockNumb Liquidity: liquidity, Slot0: slot0, FeeTier: feeTier.Int64(), - TickSpacing: tickSpacing.Int64(), + TickSpacing: tickSpacing.Uint64(), Reserve0: reserve0, Reserve1: reserve1, }, err diff --git a/pkg/source/ramsesv2/pools_list_updater.go b/pkg/source/ramsesv2/pools_list_updater.go index e0de79559..73b6261c7 100644 --- a/pkg/source/ramsesv2/pools_list_updater.go +++ b/pkg/source/ramsesv2/pools_list_updater.go @@ -9,20 +9,25 @@ import ( "time" "github.com/KyberNetwork/blockchain-toolkit/integer" + "github.com/KyberNetwork/ethrpc" "github.com/KyberNetwork/logger" "github.com/machinebox/graphql" + "github.com/samber/lo" "github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity" + "github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/uniswapv3" graphqlpkg "github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql" ) type PoolsListUpdater struct { config *Config graphqlClient *graphql.Client + ethrpcClient *ethrpc.Client } func NewPoolsListUpdater( cfg *Config, + ethrpcClient *ethrpc.Client, ) *PoolsListUpdater { graphqlClient := graphqlpkg.New(graphqlpkg.Config{ Url: cfg.SubgraphAPI, @@ -33,6 +38,7 @@ func NewPoolsListUpdater( return &PoolsListUpdater{ config: cfg, graphqlClient: graphqlClient, + ethrpcClient: ethrpcClient, } } @@ -78,11 +84,23 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte logger.Infof("got %v subgraph pools from %s subgraph", numSubgraphPools, d.config.DexID) + tickSpacings, _ := uniswapv3.FetchTickSpacings( + ctx, + lo.Map(subgraphPools, func(item SubgraphPool, _ int) string { return item.ID }), + d.ethrpcClient, + ramsesV2PoolABI, + methodTickSpacing, + ) + pools := make([]entity.Pool, 0, len(subgraphPools)) for _, p := range subgraphPools { tokens := make([]*entity.PoolToken, 0, 2) reserves := make([]string, 0, 2) + extraField := Extra{ + TickSpacing: tickSpacings[p.ID], + } + if p.Token0.Address != emptyString { token0Decimals, err := strconv.Atoi(p.Token0.Decimals) @@ -125,6 +143,8 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64) + extraBytes, _ := json.Marshal(extraField) + var newPool = entity.Pool{ Address: p.ID, ReserveUsd: 0, @@ -135,6 +155,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte Timestamp: time.Now().Unix(), Reserves: reserves, Tokens: tokens, + Extra: string(extraBytes), } pools = append(pools, newPool) diff --git a/pkg/source/ramsesv2/type.go b/pkg/source/ramsesv2/type.go index 5829d1f44..401554d61 100644 --- a/pkg/source/ramsesv2/type.go +++ b/pkg/source/ramsesv2/type.go @@ -63,7 +63,7 @@ type Extra struct { Liquidity *big.Int `json:"liquidity"` SqrtPriceX96 *big.Int `json:"sqrtPriceX96"` FeeTier int64 `json:"feeTier"` - TickSpacing int64 `json:"tickSpacing"` + TickSpacing uint64 `json:"tickSpacing"` Tick *big.Int `json:"tick"` Ticks []Tick `json:"ticks"` } @@ -82,7 +82,7 @@ type FetchRPCResult struct { Liquidity *big.Int Slot0 Slot0 FeeTier int64 - TickSpacing int64 + TickSpacing uint64 Reserve0 *big.Int Reserve1 *big.Int } diff --git a/pkg/source/slipstream/pools_list_updater.go b/pkg/source/slipstream/pools_list_updater.go index 81ac5371e..646be8e8a 100644 --- a/pkg/source/slipstream/pools_list_updater.go +++ b/pkg/source/slipstream/pools_list_updater.go @@ -9,20 +9,25 @@ import ( "time" "github.com/KyberNetwork/blockchain-toolkit/integer" + "github.com/KyberNetwork/ethrpc" "github.com/KyberNetwork/logger" "github.com/machinebox/graphql" + "github.com/samber/lo" "github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity" + "github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/uniswapv3" graphqlpkg "github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql" ) type PoolsListUpdater struct { config *Config graphqlClient *graphql.Client + ethrpcClient *ethrpc.Client } func NewPoolsListUpdater( cfg *Config, + ethrpcClient *ethrpc.Client, ) *PoolsListUpdater { graphqlClient := graphqlpkg.New(graphqlpkg.Config{ Url: cfg.SubgraphAPI, @@ -33,6 +38,7 @@ func NewPoolsListUpdater( return &PoolsListUpdater{ config: cfg, graphqlClient: graphqlClient, + ethrpcClient: ethrpcClient, } } @@ -83,10 +89,22 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte logger.Infof("got %v subgraph pools from %s subgraph", numSubgraphPools, d.config.DexID) + tickSpacings, _ := uniswapv3.FetchTickSpacings( + ctx, + lo.Map(subgraphPools, func(item SubgraphPool, _ int) string { return item.ID }), + d.ethrpcClient, + poolABI, + methodTickSpacing, + ) + pools := make([]entity.Pool, 0, len(subgraphPools)) for _, p := range subgraphPools { tokens := make([]*entity.PoolToken, 0, 2) reserves := make([]string, 0, 2) + + extraField := Extra{ + TickSpacing: tickSpacings[p.ID], + } staticField := StaticExtra{ PoolId: p.ID, } @@ -131,6 +149,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte reserves = append(reserves, zeroString) } + extraBytes, _ := json.Marshal(extraField) staticBytes, _ := json.Marshal(staticField) var newPool = entity.Pool{ Address: p.ID, @@ -142,6 +161,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte Timestamp: time.Now().Unix(), Reserves: reserves, Tokens: tokens, + Extra: string(extraBytes), StaticExtra: string(staticBytes), } diff --git a/pkg/source/solidly-v3/pool_tracker.go b/pkg/source/solidly-v3/pool_tracker.go index 5e9c83881..8c1e45c2c 100644 --- a/pkg/source/solidly-v3/pool_tracker.go +++ b/pkg/source/solidly-v3/pool_tracker.go @@ -105,7 +105,7 @@ func (d *PoolTracker) GetNewPoolState( extraBytes, err := json.Marshal(Extra{ Liquidity: rpcData.Liquidity, SqrtPriceX96: rpcData.Slot0.SqrtPriceX96, - TickSpacing: int32(rpcData.TickSpacing.Int64()), + TickSpacing: rpcData.TickSpacing.Uint64(), Tick: rpcData.Slot0.Tick, Ticks: ticks, }) diff --git a/pkg/source/solidly-v3/pools_list_updater.go b/pkg/source/solidly-v3/pools_list_updater.go index 771793679..62d5e933f 100644 --- a/pkg/source/solidly-v3/pools_list_updater.go +++ b/pkg/source/solidly-v3/pools_list_updater.go @@ -9,20 +9,25 @@ import ( "time" "github.com/KyberNetwork/blockchain-toolkit/integer" + "github.com/KyberNetwork/ethrpc" "github.com/KyberNetwork/logger" "github.com/machinebox/graphql" + "github.com/samber/lo" "github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity" + "github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/uniswapv3" graphqlpkg "github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql" ) type PoolsListUpdater struct { config *Config graphqlClient *graphql.Client + ethrpcClient *ethrpc.Client } func NewPoolsListUpdater( cfg *Config, + ethrpcClient *ethrpc.Client, ) *PoolsListUpdater { graphqlClient := graphqlpkg.New(graphqlpkg.Config{ Url: cfg.SubgraphAPI, @@ -33,6 +38,7 @@ func NewPoolsListUpdater( return &PoolsListUpdater{ config: cfg, graphqlClient: graphqlClient, + ethrpcClient: ethrpcClient, } } @@ -78,11 +84,23 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte logger.Infof("got %v subgraph pools from %s subgraph", numSubgraphPools, d.config.DexID) + tickSpacings, _ := uniswapv3.FetchTickSpacings( + ctx, + lo.Map(subgraphPools, func(item SubgraphPool, _ int) string { return item.ID }), + d.ethrpcClient, + solidlyV3PoolABI, + methodTickSpacing, + ) + pools := make([]entity.Pool, 0, len(subgraphPools)) for _, p := range subgraphPools { tokens := make([]*entity.PoolToken, 0, 2) reserves := make([]string, 0, 2) + extraField := Extra{ + TickSpacing: tickSpacings[p.ID], + } + if p.Token0.Address != emptyString { token0Decimals, err := strconv.Atoi(p.Token0.Decimals) @@ -125,6 +143,8 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64) + extraBytes, _ := json.Marshal(extraField) + var newPool = entity.Pool{ Address: p.ID, ReserveUsd: 0, @@ -135,6 +155,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte Timestamp: time.Now().Unix(), Reserves: reserves, Tokens: tokens, + Extra: string(extraBytes), } pools = append(pools, newPool) diff --git a/pkg/source/solidly-v3/type.go b/pkg/source/solidly-v3/type.go index c77b80f14..cd2923724 100644 --- a/pkg/source/solidly-v3/type.go +++ b/pkg/source/solidly-v3/type.go @@ -58,7 +58,7 @@ type Tick struct { type Extra struct { Liquidity *big.Int `json:"liquidity"` SqrtPriceX96 *big.Int `json:"sqrtPriceX96"` - TickSpacing int32 `json:"tickSpacing"` + TickSpacing uint64 `json:"tickSpacing"` Tick *big.Int `json:"tick"` Ticks []Tick `json:"ticks"` } diff --git a/pkg/source/uniswapv3/constant.go b/pkg/source/uniswapv3/constant.go index 71a38d5e4..e435837a0 100644 --- a/pkg/source/uniswapv3/constant.go +++ b/pkg/source/uniswapv3/constant.go @@ -14,6 +14,7 @@ const ( zeroString = "0" emptyString = "" graphQLRequestTimeout = 60 * time.Second + rpcChunkSize = 100 ) const ( diff --git a/pkg/source/uniswapv3/pools_list_updater.go b/pkg/source/uniswapv3/pools_list_updater.go index de5da26e0..4fc4c55db 100644 --- a/pkg/source/uniswapv3/pools_list_updater.go +++ b/pkg/source/uniswapv3/pools_list_updater.go @@ -9,8 +9,10 @@ import ( "time" "github.com/KyberNetwork/blockchain-toolkit/integer" + "github.com/KyberNetwork/ethrpc" "github.com/KyberNetwork/logger" "github.com/machinebox/graphql" + "github.com/samber/lo" "github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity" graphqlpkg "github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql" @@ -19,10 +21,12 @@ import ( type PoolsListUpdater struct { config *Config graphqlClient *graphql.Client + ethrpcClient *ethrpc.Client } func NewPoolsListUpdater( cfg *Config, + ethrpcClient *ethrpc.Client, ) *PoolsListUpdater { graphqlClient := graphqlpkg.New(graphqlpkg.Config{ Url: cfg.SubgraphAPI, @@ -33,6 +37,7 @@ func NewPoolsListUpdater( return &PoolsListUpdater{ config: cfg, graphqlClient: graphqlClient, + ethrpcClient: ethrpcClient, } } @@ -83,10 +88,22 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte logger.Infof("got %v subgraph pools from %s subgraph", numSubgraphPools, d.config.DexID) + tickSpacings, _ := FetchTickSpacings( + ctx, + lo.Map(subgraphPools, func(item SubgraphPool, _ int) string { return item.ID }), + d.ethrpcClient, + uniswapV3PoolABI, + methodTickSpacing, + ) + pools := make([]entity.Pool, 0, len(subgraphPools)) for _, p := range subgraphPools { tokens := make([]*entity.PoolToken, 0, 2) reserves := make([]string, 0, 2) + + extraField := Extra{ + TickSpacing: tickSpacings[p.ID], + } staticField := StaticExtra{ PoolId: p.ID, } @@ -133,6 +150,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64) + extraBytes, _ := json.Marshal(extraField) staticBytes, _ := json.Marshal(staticField) var newPool = entity.Pool{ Address: p.ID, @@ -144,6 +162,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte Timestamp: time.Now().Unix(), Reserves: reserves, Tokens: tokens, + Extra: string(extraBytes), StaticExtra: string(staticBytes), } diff --git a/pkg/source/uniswapv3/util.go b/pkg/source/uniswapv3/util.go new file mode 100644 index 000000000..1baec3b2a --- /dev/null +++ b/pkg/source/uniswapv3/util.go @@ -0,0 +1,58 @@ +package uniswapv3 + +import ( + "context" + "math/big" + + "github.com/KyberNetwork/ethrpc" + "github.com/KyberNetwork/logger" + "github.com/ethereum/go-ethereum/accounts/abi" +) + +// FetchTickSpacings fetches tick spacings of pools with given poolAddresses. +// Return a map between poolAddress to its tick spacing. +func FetchTickSpacings( + ctx context.Context, + poolAddresses []string, + ethrpcClient *ethrpc.Client, + poolABI abi.ABI, + methodTickSpacing string, +) (map[string]uint64, error) { + tickSpacings := make(map[string]uint64, len(poolAddresses)) + + for i := 0; i < len(poolAddresses); i += rpcChunkSize { + endIndex := i + rpcChunkSize + if endIndex > len(poolAddresses) { + endIndex = len(poolAddresses) + } + + chunk := poolAddresses[i:endIndex] + + rpcRequest := ethrpcClient.NewRequest().SetContext(ctx) + rpcResponse := make([]*big.Int, len(chunk)) + + for j, poolAddress := range chunk { + rpcRequest.AddCall(ðrpc.Call{ + ABI: poolABI, + Target: poolAddress, + Method: methodTickSpacing, + Params: nil, + }, []interface{}{&rpcResponse[j]}) + } + + _, err := rpcRequest.TryAggregate() + if err != nil { + logger.WithFields(logger.Fields{ + "error": err, + }).Error("[fetchTickSpacings] failed to process tryAggregate") + return nil, err + } + + for j := 0; j < len(chunk); j++ { + poolAddress := poolAddresses[i+j] + tickSpacings[poolAddress] = rpcResponse[j].Uint64() + } + } + + return tickSpacings, nil +}