Skip to content

Commit

Permalink
Merge branch 'withdraw_do_not_allow_post_reorder' of github.com:P-U-D…
Browse files Browse the repository at this point in the history
…-G-E/sge into reorder_fix
  • Loading branch information
P-U-D-G-E committed Sep 27, 2023
2 parents b137eff + b256d40 commit a955e41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions x/orderbook/keeper/participation.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ func (k Keeper) CalcWithdrawalAmount(
return sdkmath.Int{}, sdkerrors.Wrapf(types.ErrMismatchInDepositorAddress, "%s", bp.ParticipantAddress)
}

bpE, err := k.GetExposureByOrderBookAndParticipationIndex(ctx, marketUID, participationIndex)
if err != nil {
return sdkmath.Int{}, sdkerrors.Wrapf(types.ErrParticipationExposuresNotFound, "%d", participationIndex)
}
if len(bpE) == 0 {
return sdkmath.Int{}, sdkerrors.Wrapf(types.ErrParticipationExposuresNotFound, "%d", participationIndex)
}
if bpE[0].Round != 1 {
return sdkmath.Int{}, sdkerrors.Wrapf(types.ErrWithdrawalNotAllowedPostRequeing, "%d", bpE[0].Round)
}

if mode == housetypes.WithdrawalMode_WITHDRAWAL_MODE_PARTIAL {
if bp.Liquidity.Sub(totalWithdrawnAmount).LT(amount) {
return sdkmath.Int{}, sdkerrors.Wrapf(types.ErrWithdrawalTooLarge, "%d", amount.Int64())
Expand Down
1 change: 1 addition & 0 deletions x/orderbook/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (
ErrInsufficientFundToCoverPayout = sdkerrors.Register(ModuleName, 6024, "insufficient fund in the participations to cover the payout")
ErrUnknownMarketStatus = sdkerrors.Register(ModuleName, 6025, "unknown market status of orderbook settlement")
ErrWithdrawalTooLarge = sdkerrors.Register(ModuleName, 6026, "withdrawal is more than unused amount")
ErrWithdrawalNotAllowedPostRequeing = sdkerrors.Register(ModuleName, 6027, "withdrawal is not allowed post requeing")
)

// ErrTextInvalidDepositor x/orderbook module sentinel error text
Expand Down

0 comments on commit a955e41

Please sign in to comment.