From e8ab2f4d75079157d008eba9f310b199573eed28 Mon Sep 17 00:00:00 2001 From: Hanjun Kim Date: Wed, 9 Jun 2021 04:54:59 +0900 Subject: [PATCH] Treat a pool with zero reserve coin as depleted (#394) * keep zero reserve coins from GetReserveCoins * treat pool with zero pool coin supply as depleted also change Mul/QuoTruncate to Mul/Quo. fixes #364 * rollback change of Quo/MulTruncate to Quo/Mul this should be done in #380 * treat a pool with zero reserve coin as depleted --- x/liquidity/keeper/liquidity_pool.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/liquidity/keeper/liquidity_pool.go b/x/liquidity/keeper/liquidity_pool.go index 97b70f124..a3e96930b 100644 --- a/x/liquidity/keeper/liquidity_pool.go +++ b/x/liquidity/keeper/liquidity_pool.go @@ -473,7 +473,10 @@ func (k Keeper) GetPoolCoinTotalSupply(ctx sdk.Context, pool types.Pool) sdk.Int // IsDepletedPool returns true if the pool is depleted. func (k Keeper) IsDepletedPool(ctx sdk.Context, pool types.Pool) bool { - return !k.GetPoolCoinTotalSupply(ctx, pool).IsPositive() + reserveCoins := k.GetReserveCoins(ctx, pool) + return !k.GetPoolCoinTotalSupply(ctx, pool).IsPositive() || + reserveCoins.AmountOf(pool.ReserveCoinDenoms[0]).IsZero() || + reserveCoins.AmountOf(pool.ReserveCoinDenoms[1]).IsZero() } // GetPoolCoinTotal returns total supply of pool coin of the pool in form of sdk.Coin