Skip to content

Commit

Permalink
Treat a pool with zero reserve coin as depleted (#394)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hallazzang committed Jun 8, 2021
1 parent e47b7af commit e8ab2f4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion x/liquidity/keeper/liquidity_pool.go
Expand Up @@ -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
Expand Down

0 comments on commit e8ab2f4

Please sign in to comment.