From 4a00c96313b2cc89891e4f9e68332f4bf7bad589 Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Thu, 7 Sep 2023 11:05:28 +0300 Subject: [PATCH] fix: current round liquidity check --- x/orderbook/keeper/exposure_odds.go | 2 +- x/orderbook/types/participation.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/x/orderbook/keeper/exposure_odds.go b/x/orderbook/keeper/exposure_odds.go index 6fef208e..efd3bc64 100644 --- a/x/orderbook/keeper/exposure_odds.go +++ b/x/orderbook/keeper/exposure_odds.go @@ -112,7 +112,7 @@ func (k Keeper) removeNotWithdrawableFromFulfillmentQueue( ctx sdk.Context, bp types.OrderBookParticipation, ) error { - if !bp.IsWithdrawable() { + if !bp.IsLiquidityInCurrentRound() { boes, err := k.GetOddsExposuresByOrderBook(ctx, bp.OrderBookUID) if err != nil { return err diff --git a/x/orderbook/types/participation.go b/x/orderbook/types/participation.go index 826cc106..e056fa3a 100644 --- a/x/orderbook/types/participation.go +++ b/x/orderbook/types/participation.go @@ -79,10 +79,9 @@ func (p *OrderBookParticipation) maxWithdrawalAmount() sdkmath.Int { return p.CurrentRoundLiquidity.Sub(p.CurrentRoundMaxLoss) } -// IsWithdrawable determines if the participation has enough funds in -// current round to be able to withdraw. -func (p *OrderBookParticipation) IsWithdrawable() bool { - return p.maxWithdrawalAmount().GT(sdk.ZeroInt()) +// IsLiquidityInCurrentRound determines if the participation has liquidity in current round. +func (p *OrderBookParticipation) IsLiquidityInCurrentRound() bool { + return p.CurrentRoundLiquidity.GT(sdk.ZeroInt()) } // WithdrawableAmount returns the withdrawal amount according to the withdrawal mode and max withdrawable amount.