code.vegaprotocol.io/vega@v0.79.0/core/execution/common/errors.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package common
    17  
    18  import (
    19  	"errors"
    20  )
    21  
    22  var (
    23  	// ErrMarketClosed signals that an action have been tried to be applied on a closed market.
    24  	ErrMarketClosed = errors.New("market closed")
    25  	// ErrPartyDoNotExists signals that the party used does not exists.
    26  	ErrPartyDoNotExists = errors.New("party does not exist")
    27  	// ErrMarginCheckFailed signals that a margin check for a position failed.
    28  	ErrMarginCheckFailed = errors.New("margin check failed")
    29  	// ErrMarginCheckInsufficient signals that a margin had not enough funds.
    30  	ErrMarginCheckInsufficient = errors.New("insufficient margin")
    31  	// ErrMissingGeneralAccountForParty ...
    32  	ErrMissingGeneralAccountForParty = errors.New("missing general account for party")
    33  	// ErrNotEnoughVolumeToZeroOutNetworkOrder ...
    34  	ErrNotEnoughVolumeToZeroOutNetworkOrder = errors.New("not enough volume to zero out network order")
    35  	// ErrInvalidAmendRemainQuantity signals incorrect remaining qty for a reduce by amend.
    36  	ErrInvalidAmendRemainQuantity = errors.New("incorrect remaining qty for a reduce by amend")
    37  	// ErrEmptyMarketID is returned if processed market has an empty id.
    38  	ErrEmptyMarketID = errors.New("invalid market id (empty)")
    39  	// ErrInvalidOrderType is returned if processed order has an invalid order type.
    40  	ErrInvalidOrderType = errors.New("invalid order type")
    41  	// ErrInvalidExpiresAtTime is returned if the expire time is before the createdAt time.
    42  	ErrInvalidExpiresAtTime = errors.New("invalid expiresAt time")
    43  	// ErrGFAOrderReceivedDuringContinuousTrading is returned is a gfa order hits the market when the market is in continuous trading state.
    44  	ErrGFAOrderReceivedDuringContinuousTrading = errors.New("gfa order received during continuous trading")
    45  	// ErrGFNOrderReceivedAuctionTrading is returned if a gfn order hits the market when in auction state.
    46  	ErrGFNOrderReceivedAuctionTrading = errors.New("gfn order received during auction trading")
    47  	// ErrIOCOrderReceivedAuctionTrading is returned if a ioc order hits the market when in auction state.
    48  	ErrIOCOrderReceivedAuctionTrading = errors.New("ioc order received during auction trading")
    49  	// ErrFOKOrderReceivedAuctionTrading is returned if a fok order hits the market when in auction state.
    50  	ErrFOKOrderReceivedAuctionTrading = errors.New("fok order received during auction trading")
    51  	// ErrUnableToReprice we are unable to get a price required to reprice.
    52  	ErrUnableToReprice = errors.New("unable to reprice")
    53  	// ErrOrderNotFound we cannot find the order in the market.
    54  	ErrOrderNotFound = errors.New("unable to find the order in the market")
    55  	// ErrTradingNotAllowed no trading related functionalities are allowed in the current state.
    56  	ErrTradingNotAllowed = errors.New("trading not allowed")
    57  	// ErrCommitmentSubmissionNotAllowed no commitment submission are permitted in the current state.
    58  	ErrCommitmentSubmissionNotAllowed = errors.New("commitment submission not allowed")
    59  	// ErrNotEnoughStake is returned when a LP update results in not enough commitment.
    60  	ErrNotEnoughStake = errors.New("commitment submission rejected, not enough stake")
    61  	// ErrPartyNotLiquidityProvider is returned when a LP update or cancel does not match an LP party.
    62  	ErrPartyNotLiquidityProvider = errors.New("party is not a liquidity provider")
    63  	// ErrPartyAlreadyLiquidityProvider is returned when a LP is submitted by a party which is already LP.
    64  	ErrPartyAlreadyLiquidityProvider = errors.New("party is already a liquidity provider")
    65  	// ErrCannotRejectMarketNotInProposedState.
    66  	ErrCannotRejectMarketNotInProposedState = errors.New("cannot reject a market not in proposed state")
    67  	// ErrCannotStateOpeningAuctionForMarketNotInProposedState.
    68  	ErrCannotStartOpeningAuctionForMarketNotInProposedState = errors.New("cannot start the opening auction for a market not in proposed state")
    69  	// ErrCannotRepriceDuringAuction.
    70  	ErrCannotRepriceDuringAuction = errors.New("cannot reprice during auction")
    71  	// ErrPartyInsufficientAssetBalance is returned when a party does not have sufficient balance of the required asset to perform an action.
    72  	ErrPartyInsufficientAssetBalance                        = errors.New("party has insufficient balance in asset")
    73  	ErrMaxStopOrdersPerPartyReached                         = errors.New("max stop orders per party reached")
    74  	ErrStopOrderSubmissionNotAllowedWithoutExistingPosition = errors.New("stop order submission not allowed without existing position")
    75  	ErrStopOrderSideNotClosingThePosition                   = errors.New("side used in stop order does not close the position")
    76  	ErrStopOrderMustBeReduceOnly                            = errors.New("stop order must be reduce only")
    77  	ErrStopOrderExpiryInThePast                             = errors.New("stop order expiry in the past")
    78  	ErrStopOrderSizeOverridePercentageInvalid               = errors.New("stop order size override percentage value is invalid")
    79  	ErrPartyHasNoExistingLiquidityProvision                 = errors.New("party has no existing liquidity provision")
    80  	// ErrStopOrderNotAllowedDuringOpeningAuction is returned if a trader attempts to send a stop order to a market that is in opening auction.
    81  	ErrStopOrderNotAllowedDuringOpeningAuction = errors.New("stop orders are not accepted during the opening auction")
    82  	// ErrStopOrderNotAllowedSameExpiryTimeForOCO is returned if both sides of an OCO have the same expiry time.
    83  	ErrStopOrderNotAllowedSameExpiry = errors.New("stop order OCOs must not have the same expiry time")
    84  	// ErrStopOrderSizeOverrideNotSupportedForSpots is returned when a stop order is received with size override for a spot product.
    85  	ErrStopOrderSizeOverrideNotSupportedForSpots = errors.New("stop order size override is not supported for spot product")
    86  	ErrAMMCannotRebase                           = errors.New("not enough liquidity for AMM to rebase")
    87  	// ErrInvalidOrderPrice is returned when an order is submitted to a capped future with a price > max price.
    88  	ErrInvalidOrderPrice = errors.New("invalid order price")
    89  	// ErrIsolatedMarginFullyCollateralised is returned when a party tries to switch margin modes on a fully collateralised market.
    90  	ErrIsolatedMarginFullyCollateralised = errors.New("isolated margin not permitted on fully collateralised markets")
    91  	// ErrSettlementDataOutOfRange is returned when a capped future receives settlement data that is outside of the acceptable range (either > max price, or neither 0 nor max for binary settlements).
    92  	ErrSettlementDataOutOfRange = errors.New("settlement data is outside of the price cap")
    93  	ErrAMMBoundsOutsidePriceCap = errors.New("an AMM bound is outside of the price cap")
    94  	// ErrSellOrderNotAllowed no sell orders are allowed in the current state.
    95  	ErrSellOrderNotAllowed = errors.New("sell order not allowed")
    96  )