using System.Numerics;
using Managing.ABI.GmxV2.Reader.ContractDefinition;

namespace Managing.Infrastructure.Evm.Models.Gmx.v2;

public class GmxV2Order
{
    public byte[] Key { get; set; }
    public string Account { get; set; }
    public string Receiver { get; set; }
    public string CallbackContract { get; set; }
    public string MarketAddress { get; set; }
    public string InitialCollateralTokenAddress { get; set; }
    public List<string> SwapPath { get; set; }
    public BigInteger SizeDeltaUsd { get; set; }
    public BigInteger InitialCollateralDeltaAmount { get; set; }
    public BigInteger ContractTriggerPrice { get; set; }
    public BigInteger ContractAcceptablePrice { get; set; }
    public BigInteger ExecutionFee { get; set; }
    public BigInteger CallbackGasLimit { get; set; }
    public BigInteger MinOutputAmount { get; set; }
    public BigInteger UpdatedAtBlock { get; set; }
    public bool IsLong { get; set; }
    public bool ShouldUnwrapNativeToken { get; set; }
    public bool IsFrozen { get; set; }
    public GmxV2OrderType OrderType { get; set; }
    public GmxV2DecreasePositionSwapType DecreasePositionSwapType { get; set; }
    public Props Data { get; set; }
    public DateTime Date { get; set; }
}

public enum GmxV2DecreasePositionSwapType
{
    NoSwap = 0,
    SwapPnlTokenToCollateralToken = 1,
    SwapCollateralTokenToPnlToken = 2
}

public enum GmxV2OrderType
{
    // the order will be cancelled if the minOutputAmount cannot be fulfilled
    MarketSwap = 0,

    // @dev LimitSwap: swap token A to token B if the minOutputAmount can be fulfilled
    LimitSwap = 1,

    // @dev MarketIncrease: increase position at the current market price
    // the order will be cancelled if the position cannot be increased at the acceptablePrice
    MarketIncrease = 2,

    // @dev LimitIncrease: increase position if the triggerPrice is reached and the acceptablePrice can be fulfilled
    LimitIncrease = 3,

    // @dev MarketDecrease: decrease position at the current market price
    // the order will be cancelled if the position cannot be decreased at the acceptablePrice
    MarketDecrease = 4,

    // @dev LimitDecrease: decrease position if the triggerPrice is reached and the acceptablePrice can be fulfilled
    LimitDecrease = 5,

    // @dev StopLossDecrease: decrease position if the triggerPrice is reached and the acceptablePrice can be fulfilled
    StopLossDecrease = 6,

    // @dev Liquidation: allows liquidation of positions if the criteria for liquidation are met
    Liquidation = 7
}