From 9900ae21b4d83fafd052b420830a5399c46f61d7 Mon Sep 17 00:00:00 2001 From: SunSpirit <48086732+sunspirit99@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:23:27 +0700 Subject: [PATCH] Fix(Algebra-Integral): Wrong tick's type conversion --- pkg/liquidity-source/algebra/integral/plugin.go | 4 ++-- pkg/liquidity-source/algebra/integral/pool_tracker.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/liquidity-source/algebra/integral/plugin.go b/pkg/liquidity-source/algebra/integral/plugin.go index 5f47f26fe..120445dcf 100644 --- a/pkg/liquidity-source/algebra/integral/plugin.go +++ b/pkg/liquidity-source/algebra/integral/plugin.go @@ -539,7 +539,7 @@ func getOutputTokenDelta10(to, from, liquidity *uint256.Int) (*uint256.Int, erro func getToken0Delta(priceLower, priceUpper, liquidity *uint256.Int, roundUp bool) (*uint256.Int, error) { priceDelta := new(uint256.Int).Sub(priceUpper, priceLower) if priceDelta.Cmp(priceUpper) >= 0 { - return nil, errors.New("price delta must be greater than price upper") + return nil, errors.New("price delta must be smaller than price upper") } liquidityShifted := new(uint256.Int).Lsh(liquidity, RESOLUTION) @@ -570,7 +570,7 @@ func getToken0Delta(priceLower, priceUpper, liquidity *uint256.Int, roundUp bool func getToken1Delta(priceLower, priceUpper, liquidity *uint256.Int, roundUp bool) (*uint256.Int, error) { if priceUpper.Cmp(priceLower) < 0 { - return nil, errors.New("price upper must be greater than price lower") + return nil, errors.New("price upper must be greater or equal than price lower") } priceDelta := new(uint256.Int).Sub(priceUpper, priceLower) diff --git a/pkg/liquidity-source/algebra/integral/pool_tracker.go b/pkg/liquidity-source/algebra/integral/pool_tracker.go index 9b323ca63..de6e8f00f 100644 --- a/pkg/liquidity-source/algebra/integral/pool_tracker.go +++ b/pkg/liquidity-source/algebra/integral/pool_tracker.go @@ -232,7 +232,7 @@ func (d *PoolTracker) fetchRPCData(ctx context.Context, p entity.Pool, blockNumb res.State = GlobalState{ Price: uint256.MustFromBig(rpcState.Price), - Tick: int32(rpcState.Tick.Uint64()), + Tick: int32(rpcState.Tick.Int64()), LastFee: rpcState.LastFee, PluginConfig: rpcState.PluginConfig, CommunityFee: rpcState.CommunityFee,