Skip to content

Commit 52e0f77

Browse files
BE-723 | Edge case fix for pool liquidity (#641)
* BE-723 | Edge case fix for pool liquidity
1 parent a14e892 commit 52e0f77

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pools/usecase/pools_usecase.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,18 @@ func (p *poolsUseCase) GetPools(opts ...domain.PoolsOption) ([]ingesttypes.PoolI
575575
// StorePools implements mvc.PoolsUsecase.
576576
func (p *poolsUseCase) StorePools(pools []ingesttypes.PoolI) error {
577577
for _, pool := range pools {
578-
// Store pool
578+
// Set liquidity capitalization for the pool to previous value if it is nil or zero.
579+
// This value will be used for candidate route search and will be recomputed later.
579580
poolID := pool.GetId()
581+
oldPool, err := p.GetPool(poolID)
582+
if err == nil {
583+
liquidityCap := pool.GetLiquidityCap()
584+
if liquidityCap.IsNil() || liquidityCap.Equal(osmomath.ZeroInt()) {
585+
pool.SetLiquidityCap(oldPool.GetLiquidityCap())
586+
pool.SetLiquidityCapError(oldPool.GetLiquidityCapError())
587+
}
588+
}
589+
580590
p.pools.Store(poolID, pool)
581591

582592
// If orderbook, update top liquidity pool for base and quote denom if it has higher liquidity capitalization.

0 commit comments

Comments
 (0)