using System.Numerics;
using Managing.ABI.GmxV2.Reader.ContractDefinition;
using Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition;
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Web3;
using GetAccountOrdersFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetAccountOrdersFunction;
using GetAccountOrdersOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetAccountOrdersOutputDTO;
using GetAccountPositionInfoListFunction =
    Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetAccountPositionInfoListFunction;
using GetAccountPositionInfoListOutputDTO =
    Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetAccountPositionInfoListOutputDTO;
using GetAccountPositionsFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetAccountPositionsFunction;
using GetAccountPositionsOutputDTO =
    Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetAccountPositionsOutputDTO;
using GetAdlStateFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetAdlStateFunction;
using GetAdlStateOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetAdlStateOutputDTO;
using GetDepositAmountOutFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetDepositAmountOutFunction;
using GetDepositFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetDepositFunction;
using GetDepositOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetDepositOutputDTO;
using GetExecutionPriceFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetExecutionPriceFunction;
using GetExecutionPriceOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetExecutionPriceOutputDTO;
using GetMarketBySaltFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketBySaltFunction;
using GetMarketBySaltOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketBySaltOutputDTO;
using GetMarketFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketFunction;
using GetMarketInfoFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketInfoFunction;
using GetMarketInfoListFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketInfoListFunction;
using GetMarketInfoListOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketInfoListOutputDTO;
using GetMarketInfoOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketInfoOutputDTO;
using GetMarketOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketOutputDTO;
using GetMarketsFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketsFunction;
using GetMarketsOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketsOutputDTO;
using GetMarketTokenPriceFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketTokenPriceFunction;
using GetMarketTokenPriceOutputDTO =
    Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetMarketTokenPriceOutputDTO;
using GetNetPnlFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetNetPnlFunction;
using GetOpenInterestWithPnlFunction =
    Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetOpenInterestWithPnlFunction;
using GetOrderFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetOrderFunction;
using GetOrderOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetOrderOutputDTO;
using GetPnlFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetPnlFunction;
using GetPnlToPoolFactorFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetPnlToPoolFactorFunction;
using GetPositionFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetPositionFunction;
using GetPositionInfoFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetPositionInfoFunction;
using GetPositionInfoOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetPositionInfoOutputDTO;
using GetPositionOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetPositionOutputDTO;
using GetPositionPnlUsdFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetPositionPnlUsdFunction;
using GetPositionPnlUsdOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetPositionPnlUsdOutputDTO;
using GetShiftFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetShiftFunction;
using GetShiftOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetShiftOutputDTO;
using GetSwapAmountOutFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetSwapAmountOutFunction;
using GetSwapAmountOutOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetSwapAmountOutOutputDTO;
using GetSwapPriceImpactFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetSwapPriceImpactFunction;
using GetSwapPriceImpactOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetSwapPriceImpactOutputDTO;
using GetWithdrawalAmountOutFunction =
    Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetWithdrawalAmountOutFunction;
using GetWithdrawalAmountOutOutputDTO =
    Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetWithdrawalAmountOutOutputDTO;
using GetWithdrawalFunction = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetWithdrawalFunction;
using GetWithdrawalOutputDTO = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.GetWithdrawalOutputDTO;
using MarketPrices = Managing.ABI.GmxV2.SyntheticsReader.ContractDefinition.MarketPrices;

namespace Managing.ABI.GmxV2.SyntheticsReader
{
    public partial class SyntheticsReaderService : ContractWeb3ServiceBase
    {
        public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(IWeb3 web3,
            SyntheticsReaderDeployment syntheticsReaderDeployment,
            CancellationTokenSource cancellationTokenSource = null)
        {
            return web3.Eth.GetContractDeploymentHandler<SyntheticsReaderDeployment>()
                .SendRequestAndWaitForReceiptAsync(syntheticsReaderDeployment, cancellationTokenSource);
        }

        public static Task<string> DeployContractAsync(IWeb3 web3,
            SyntheticsReaderDeployment syntheticsReaderDeployment)
        {
            return web3.Eth.GetContractDeploymentHandler<SyntheticsReaderDeployment>()
                .SendRequestAsync(syntheticsReaderDeployment);
        }

        public static async Task<SyntheticsReaderService> DeployContractAndGetServiceAsync(IWeb3 web3,
            SyntheticsReaderDeployment syntheticsReaderDeployment,
            CancellationTokenSource cancellationTokenSource = null)
        {
            var receipt =
                await DeployContractAndWaitForReceiptAsync(web3, syntheticsReaderDeployment, cancellationTokenSource);
            return new SyntheticsReaderService(web3, receipt.ContractAddress);
        }

        public SyntheticsReaderService(IWeb3 web3, string contractAddress) : base(web3, contractAddress)
        {
        }

        public Task<GetAccountOrdersOutputDTO> GetAccountOrdersQueryAsync(
            GetAccountOrdersFunction getAccountOrdersFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetAccountOrdersFunction, GetAccountOrdersOutputDTO>(
                getAccountOrdersFunction, blockParameter);
        }

        public Task<GetAccountOrdersOutputDTO> GetAccountOrdersQueryAsync(string dataStore, string account,
            BigInteger start, BigInteger end, BlockParameter blockParameter = null)
        {
            var getAccountOrdersFunction = new GetAccountOrdersFunction();
            getAccountOrdersFunction.DataStore = dataStore;
            getAccountOrdersFunction.Account = account;
            getAccountOrdersFunction.Start = start;
            getAccountOrdersFunction.End = end;

            return ContractHandler.QueryDeserializingToObjectAsync<GetAccountOrdersFunction, GetAccountOrdersOutputDTO>(
                getAccountOrdersFunction, blockParameter);
        }

        public Task<GetAccountPositionInfoListOutputDTO> GetAccountPositionInfoListQueryAsync(
            GetAccountPositionInfoListFunction getAccountPositionInfoListFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetAccountPositionInfoListFunction,
                    GetAccountPositionInfoListOutputDTO>(getAccountPositionInfoListFunction, blockParameter);
        }

        public Task<GetAccountPositionInfoListOutputDTO> GetAccountPositionInfoListQueryAsync(string dataStore,
            string referralStorage, string account, List<string> markets, List<MarketPrices> marketPrices,
            string uiFeeReceiver, BigInteger start, BigInteger end, BlockParameter blockParameter = null)
        {
            var getAccountPositionInfoListFunction = new GetAccountPositionInfoListFunction();
            getAccountPositionInfoListFunction.DataStore = dataStore;
            getAccountPositionInfoListFunction.ReferralStorage = referralStorage;
            getAccountPositionInfoListFunction.Account = account;
            getAccountPositionInfoListFunction.Markets = markets;
            getAccountPositionInfoListFunction.MarketPrices = marketPrices;
            getAccountPositionInfoListFunction.UiFeeReceiver = uiFeeReceiver;
            getAccountPositionInfoListFunction.Start = start;
            getAccountPositionInfoListFunction.End = end;

            return ContractHandler
                .QueryDeserializingToObjectAsync<GetAccountPositionInfoListFunction,
                    GetAccountPositionInfoListOutputDTO>(getAccountPositionInfoListFunction, blockParameter);
        }

        public Task<GetAccountPositionsOutputDTO> GetAccountPositionsQueryAsync(
            GetAccountPositionsFunction getAccountPositionsFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetAccountPositionsFunction, GetAccountPositionsOutputDTO>(
                    getAccountPositionsFunction, blockParameter);
        }

        public Task<GetAccountPositionsOutputDTO> GetAccountPositionsQueryAsync(string dataStore, string account,
            BigInteger start, BigInteger end, BlockParameter blockParameter = null)
        {
            var getAccountPositionsFunction = new GetAccountPositionsFunction();
            getAccountPositionsFunction.DataStore = dataStore;
            getAccountPositionsFunction.Account = account;
            getAccountPositionsFunction.Start = start;
            getAccountPositionsFunction.End = end;

            return ContractHandler
                .QueryDeserializingToObjectAsync<GetAccountPositionsFunction, GetAccountPositionsOutputDTO>(
                    getAccountPositionsFunction, blockParameter);
        }

        public Task<GetAdlStateOutputDTO> GetAdlStateQueryAsync(GetAdlStateFunction getAdlStateFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetAdlStateFunction, GetAdlStateOutputDTO>(
                getAdlStateFunction, blockParameter);
        }

        public Task<GetAdlStateOutputDTO> GetAdlStateQueryAsync(string dataStore, string market, bool isLong,
            MarketPrices prices, BlockParameter blockParameter = null)
        {
            var getAdlStateFunction = new GetAdlStateFunction();
            getAdlStateFunction.DataStore = dataStore;
            getAdlStateFunction.Market = market;
            getAdlStateFunction.IsLong = isLong;
            getAdlStateFunction.Prices = prices;

            return ContractHandler.QueryDeserializingToObjectAsync<GetAdlStateFunction, GetAdlStateOutputDTO>(
                getAdlStateFunction, blockParameter);
        }

        public Task<GetDepositOutputDTO> GetDepositQueryAsync(GetDepositFunction getDepositFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetDepositFunction, GetDepositOutputDTO>(
                getDepositFunction, blockParameter);
        }

        public Task<GetDepositOutputDTO> GetDepositQueryAsync(string dataStore, byte[] key,
            BlockParameter blockParameter = null)
        {
            var getDepositFunction = new GetDepositFunction();
            getDepositFunction.DataStore = dataStore;
            getDepositFunction.Key = key;

            return ContractHandler.QueryDeserializingToObjectAsync<GetDepositFunction, GetDepositOutputDTO>(
                getDepositFunction, blockParameter);
        }

        public Task<BigInteger> GetDepositAmountOutQueryAsync(GetDepositAmountOutFunction getDepositAmountOutFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GetDepositAmountOutFunction, BigInteger>(getDepositAmountOutFunction,
                blockParameter);
        }


        public Task<BigInteger> GetDepositAmountOutQueryAsync(string dataStore, MarketsProps market,
            MarketPrices prices, BigInteger longTokenAmount, BigInteger shortTokenAmount, string uiFeeReceiver,
            byte swapPricingType, bool includeVirtualInventoryImpact, BlockParameter blockParameter = null)
        {
            var getDepositAmountOutFunction = new GetDepositAmountOutFunction();
            getDepositAmountOutFunction.DataStore = dataStore;
            getDepositAmountOutFunction.Market = market;
            getDepositAmountOutFunction.Prices = prices;
            getDepositAmountOutFunction.LongTokenAmount = longTokenAmount;
            getDepositAmountOutFunction.ShortTokenAmount = shortTokenAmount;
            getDepositAmountOutFunction.UiFeeReceiver = uiFeeReceiver;
            getDepositAmountOutFunction.SwapPricingType = swapPricingType;
            getDepositAmountOutFunction.IncludeVirtualInventoryImpact = includeVirtualInventoryImpact;

            return ContractHandler.QueryAsync<GetDepositAmountOutFunction, BigInteger>(getDepositAmountOutFunction,
                blockParameter);
        }

        public Task<GetExecutionPriceOutputDTO> GetExecutionPriceQueryAsync(
            GetExecutionPriceFunction getExecutionPriceFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetExecutionPriceFunction, GetExecutionPriceOutputDTO>(
                    getExecutionPriceFunction, blockParameter);
        }

        public Task<GetExecutionPriceOutputDTO> GetExecutionPriceQueryAsync(string dataStore, string marketKey,
            Props indexTokenPrice, BigInteger positionSizeInUsd, BigInteger positionSizeInTokens,
            BigInteger sizeDeltaUsd, bool isLong, BlockParameter blockParameter = null)
        {
            var getExecutionPriceFunction = new GetExecutionPriceFunction();
            getExecutionPriceFunction.DataStore = dataStore;
            getExecutionPriceFunction.MarketKey = marketKey;
            getExecutionPriceFunction.IndexTokenPrice = indexTokenPrice;
            getExecutionPriceFunction.PositionSizeInUsd = positionSizeInUsd;
            getExecutionPriceFunction.PositionSizeInTokens = positionSizeInTokens;
            getExecutionPriceFunction.SizeDeltaUsd = sizeDeltaUsd;
            getExecutionPriceFunction.IsLong = isLong;

            return ContractHandler
                .QueryDeserializingToObjectAsync<GetExecutionPriceFunction, GetExecutionPriceOutputDTO>(
                    getExecutionPriceFunction, blockParameter);
        }

        public Task<GetMarketOutputDTO> GetMarketQueryAsync(GetMarketFunction getMarketFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetMarketFunction, GetMarketOutputDTO>(
                getMarketFunction, blockParameter);
        }

        public Task<GetMarketOutputDTO> GetMarketQueryAsync(string dataStore, string key,
            BlockParameter blockParameter = null)
        {
            var getMarketFunction = new GetMarketFunction();
            getMarketFunction.DataStore = dataStore;
            getMarketFunction.Key = key;

            return ContractHandler.QueryDeserializingToObjectAsync<GetMarketFunction, GetMarketOutputDTO>(
                getMarketFunction, blockParameter);
        }

        public Task<GetMarketBySaltOutputDTO> GetMarketBySaltQueryAsync(GetMarketBySaltFunction getMarketBySaltFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetMarketBySaltFunction, GetMarketBySaltOutputDTO>(
                getMarketBySaltFunction, blockParameter);
        }

        public Task<GetMarketBySaltOutputDTO> GetMarketBySaltQueryAsync(string dataStore, byte[] salt,
            BlockParameter blockParameter = null)
        {
            var getMarketBySaltFunction = new GetMarketBySaltFunction();
            getMarketBySaltFunction.DataStore = dataStore;
            getMarketBySaltFunction.Salt = salt;

            return ContractHandler.QueryDeserializingToObjectAsync<GetMarketBySaltFunction, GetMarketBySaltOutputDTO>(
                getMarketBySaltFunction, blockParameter);
        }

        public Task<GetMarketInfoOutputDTO> GetMarketInfoQueryAsync(GetMarketInfoFunction getMarketInfoFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetMarketInfoFunction, GetMarketInfoOutputDTO>(
                getMarketInfoFunction, blockParameter);
        }

        public Task<GetMarketInfoOutputDTO> GetMarketInfoQueryAsync(string dataStore, MarketPrices prices,
            string marketKey, BlockParameter blockParameter = null)
        {
            var getMarketInfoFunction = new GetMarketInfoFunction();
            getMarketInfoFunction.DataStore = dataStore;
            getMarketInfoFunction.Prices = prices;
            getMarketInfoFunction.MarketKey = marketKey;

            return ContractHandler.QueryDeserializingToObjectAsync<GetMarketInfoFunction, GetMarketInfoOutputDTO>(
                getMarketInfoFunction, blockParameter);
        }

        public Task<GetMarketInfoListOutputDTO> GetMarketInfoListQueryAsync(
            GetMarketInfoListFunction getMarketInfoListFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetMarketInfoListFunction, GetMarketInfoListOutputDTO>(
                    getMarketInfoListFunction, blockParameter);
        }

        public Task<GetMarketInfoListOutputDTO> GetMarketInfoListQueryAsync(string dataStore,
            List<MarketPrices> marketPricesList, BigInteger start, BigInteger end, BlockParameter blockParameter = null)
        {
            var getMarketInfoListFunction = new GetMarketInfoListFunction();
            getMarketInfoListFunction.DataStore = dataStore;
            getMarketInfoListFunction.MarketPricesList = marketPricesList;
            getMarketInfoListFunction.Start = start;
            getMarketInfoListFunction.End = end;

            return ContractHandler
                .QueryDeserializingToObjectAsync<GetMarketInfoListFunction, GetMarketInfoListOutputDTO>(
                    getMarketInfoListFunction, blockParameter);
        }

        public Task<GetMarketTokenPriceOutputDTO> GetMarketTokenPriceQueryAsync(
            GetMarketTokenPriceFunction getMarketTokenPriceFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetMarketTokenPriceFunction, GetMarketTokenPriceOutputDTO>(
                    getMarketTokenPriceFunction, blockParameter);
        }

        public Task<GetMarketTokenPriceOutputDTO> GetMarketTokenPriceQueryAsync(string dataStore, Props market,
            Props indexTokenPrice, Props longTokenPrice, Props shortTokenPrice, byte[] pnlFactorType, bool maximize,
            BlockParameter blockParameter = null)
        {
            var getMarketTokenPriceFunction = new GetMarketTokenPriceFunction();
            getMarketTokenPriceFunction.DataStore = dataStore;
            getMarketTokenPriceFunction.Market = market;
            getMarketTokenPriceFunction.IndexTokenPrice = indexTokenPrice;
            getMarketTokenPriceFunction.LongTokenPrice = longTokenPrice;
            getMarketTokenPriceFunction.ShortTokenPrice = shortTokenPrice;
            getMarketTokenPriceFunction.PnlFactorType = pnlFactorType;
            getMarketTokenPriceFunction.Maximize = maximize;

            return ContractHandler
                .QueryDeserializingToObjectAsync<GetMarketTokenPriceFunction, GetMarketTokenPriceOutputDTO>(
                    getMarketTokenPriceFunction, blockParameter);
        }

        public Task<GetMarketsOutputDTO> GetMarketsQueryAsync(GetMarketsFunction getMarketsFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetMarketsFunction, GetMarketsOutputDTO>(
                getMarketsFunction, blockParameter);
        }

        public Task<GetMarketsOutputDTO> GetMarketsQueryAsync(string dataStore, BigInteger start, BigInteger end,
            BlockParameter blockParameter = null)
        {
            var getMarketsFunction = new GetMarketsFunction();
            getMarketsFunction.DataStore = dataStore;
            getMarketsFunction.Start = start;
            getMarketsFunction.End = end;

            return ContractHandler.QueryDeserializingToObjectAsync<GetMarketsFunction, GetMarketsOutputDTO>(
                getMarketsFunction, blockParameter);
        }

        public Task<BigInteger> GetNetPnlQueryAsync(GetNetPnlFunction getNetPnlFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GetNetPnlFunction, BigInteger>(getNetPnlFunction, blockParameter);
        }


        public Task<BigInteger> GetNetPnlQueryAsync(string dataStore, Props market, Props indexTokenPrice,
            bool maximize, BlockParameter blockParameter = null)
        {
            var getNetPnlFunction = new GetNetPnlFunction();
            getNetPnlFunction.DataStore = dataStore;
            getNetPnlFunction.Market = market;
            getNetPnlFunction.IndexTokenPrice = indexTokenPrice;
            getNetPnlFunction.Maximize = maximize;

            return ContractHandler.QueryAsync<GetNetPnlFunction, BigInteger>(getNetPnlFunction, blockParameter);
        }

        public Task<BigInteger> GetOpenInterestWithPnlQueryAsync(
            GetOpenInterestWithPnlFunction getOpenInterestWithPnlFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GetOpenInterestWithPnlFunction, BigInteger>(
                getOpenInterestWithPnlFunction, blockParameter);
        }


        public Task<BigInteger> GetOpenInterestWithPnlQueryAsync(string dataStore, Props market, Props indexTokenPrice,
            bool isLong, bool maximize, BlockParameter blockParameter = null)
        {
            var getOpenInterestWithPnlFunction = new GetOpenInterestWithPnlFunction();
            getOpenInterestWithPnlFunction.DataStore = dataStore;
            getOpenInterestWithPnlFunction.Market = market;
            getOpenInterestWithPnlFunction.IndexTokenPrice = indexTokenPrice;
            getOpenInterestWithPnlFunction.IsLong = isLong;
            getOpenInterestWithPnlFunction.Maximize = maximize;

            return ContractHandler.QueryAsync<GetOpenInterestWithPnlFunction, BigInteger>(
                getOpenInterestWithPnlFunction, blockParameter);
        }

        public Task<GetOrderOutputDTO> GetOrderQueryAsync(GetOrderFunction getOrderFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetOrderFunction, GetOrderOutputDTO>(
                getOrderFunction, blockParameter);
        }

        public Task<GetOrderOutputDTO> GetOrderQueryAsync(string dataStore, byte[] key,
            BlockParameter blockParameter = null)
        {
            var getOrderFunction = new GetOrderFunction();
            getOrderFunction.DataStore = dataStore;
            getOrderFunction.Key = key;

            return ContractHandler.QueryDeserializingToObjectAsync<GetOrderFunction, GetOrderOutputDTO>(
                getOrderFunction, blockParameter);
        }

        public Task<BigInteger> GetPnlQueryAsync(GetPnlFunction getPnlFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GetPnlFunction, BigInteger>(getPnlFunction, blockParameter);
        }


        public Task<BigInteger> GetPnlQueryAsync(string dataStore, Props market, Props indexTokenPrice, bool isLong,
            bool maximize, BlockParameter blockParameter = null)
        {
            var getPnlFunction = new GetPnlFunction();
            getPnlFunction.DataStore = dataStore;
            getPnlFunction.Market = market;
            getPnlFunction.IndexTokenPrice = indexTokenPrice;
            getPnlFunction.IsLong = isLong;
            getPnlFunction.Maximize = maximize;

            return ContractHandler.QueryAsync<GetPnlFunction, BigInteger>(getPnlFunction, blockParameter);
        }

        public Task<BigInteger> GetPnlToPoolFactorQueryAsync(GetPnlToPoolFactorFunction getPnlToPoolFactorFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GetPnlToPoolFactorFunction, BigInteger>(getPnlToPoolFactorFunction,
                blockParameter);
        }


        public Task<BigInteger> GetPnlToPoolFactorQueryAsync(string dataStore, string marketAddress,
            MarketPrices prices, bool isLong, bool maximize, BlockParameter blockParameter = null)
        {
            var getPnlToPoolFactorFunction = new GetPnlToPoolFactorFunction();
            getPnlToPoolFactorFunction.DataStore = dataStore;
            getPnlToPoolFactorFunction.MarketAddress = marketAddress;
            getPnlToPoolFactorFunction.Prices = prices;
            getPnlToPoolFactorFunction.IsLong = isLong;
            getPnlToPoolFactorFunction.Maximize = maximize;

            return ContractHandler.QueryAsync<GetPnlToPoolFactorFunction, BigInteger>(getPnlToPoolFactorFunction,
                blockParameter);
        }

        public Task<GetPositionOutputDTO> GetPositionQueryAsync(GetPositionFunction getPositionFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetPositionFunction, GetPositionOutputDTO>(
                getPositionFunction, blockParameter);
        }

        public Task<GetPositionOutputDTO> GetPositionQueryAsync(string dataStore, byte[] key,
            BlockParameter blockParameter = null)
        {
            var getPositionFunction = new GetPositionFunction();
            getPositionFunction.DataStore = dataStore;
            getPositionFunction.Key = key;

            return ContractHandler.QueryDeserializingToObjectAsync<GetPositionFunction, GetPositionOutputDTO>(
                getPositionFunction, blockParameter);
        }

        public Task<GetPositionInfoOutputDTO> GetPositionInfoQueryAsync(GetPositionInfoFunction getPositionInfoFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetPositionInfoFunction, GetPositionInfoOutputDTO>(
                getPositionInfoFunction, blockParameter);
        }

        public Task<GetPositionInfoOutputDTO> GetPositionInfoQueryAsync(string dataStore, string referralStorage,
            byte[] positionKey, MarketPrices prices, BigInteger sizeDeltaUsd, string uiFeeReceiver,
            bool usePositionSizeAsSizeDeltaUsd, BlockParameter blockParameter = null)
        {
            var getPositionInfoFunction = new GetPositionInfoFunction();
            getPositionInfoFunction.DataStore = dataStore;
            getPositionInfoFunction.ReferralStorage = referralStorage;
            getPositionInfoFunction.PositionKey = positionKey;
            getPositionInfoFunction.Prices = prices;
            getPositionInfoFunction.SizeDeltaUsd = sizeDeltaUsd;
            getPositionInfoFunction.UiFeeReceiver = uiFeeReceiver;
            getPositionInfoFunction.UsePositionSizeAsSizeDeltaUsd = usePositionSizeAsSizeDeltaUsd;

            return ContractHandler.QueryDeserializingToObjectAsync<GetPositionInfoFunction, GetPositionInfoOutputDTO>(
                getPositionInfoFunction, blockParameter);
        }

        public Task<GetPositionInfoListOutputDTO> GetPositionInfoListQueryAsync(
            GetPositionInfoListFunction getPositionInfoListFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetPositionInfoListFunction, GetPositionInfoListOutputDTO>(
                    getPositionInfoListFunction, blockParameter);
        }

        public Task<GetPositionInfoListOutputDTO> GetPositionInfoListQueryAsync(string dataStore,
            string referralStorage, List<byte[]> positionKeys, List<MarketPrices> prices, string uiFeeReceiver,
            BlockParameter blockParameter = null)
        {
            var getPositionInfoListFunction = new GetPositionInfoListFunction();
            getPositionInfoListFunction.DataStore = dataStore;
            getPositionInfoListFunction.ReferralStorage = referralStorage;
            getPositionInfoListFunction.PositionKeys = positionKeys;
            getPositionInfoListFunction.Prices = prices;
            getPositionInfoListFunction.UiFeeReceiver = uiFeeReceiver;

            return ContractHandler
                .QueryDeserializingToObjectAsync<GetPositionInfoListFunction, GetPositionInfoListOutputDTO>(
                    getPositionInfoListFunction, blockParameter);
        }

        public Task<GetPositionPnlUsdOutputDTO> GetPositionPnlUsdQueryAsync(
            GetPositionPnlUsdFunction getPositionPnlUsdFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetPositionPnlUsdFunction, GetPositionPnlUsdOutputDTO>(
                    getPositionPnlUsdFunction, blockParameter);
        }

        public Task<GetPositionPnlUsdOutputDTO> GetPositionPnlUsdQueryAsync(string dataStore, Props market,
            MarketPrices prices, byte[] positionKey, BigInteger sizeDeltaUsd, BlockParameter blockParameter = null)
        {
            var getPositionPnlUsdFunction = new GetPositionPnlUsdFunction();
            getPositionPnlUsdFunction.DataStore = dataStore;
            getPositionPnlUsdFunction.Market = market;
            getPositionPnlUsdFunction.Prices = prices;
            getPositionPnlUsdFunction.PositionKey = positionKey;
            getPositionPnlUsdFunction.SizeDeltaUsd = sizeDeltaUsd;

            return ContractHandler
                .QueryDeserializingToObjectAsync<GetPositionPnlUsdFunction, GetPositionPnlUsdOutputDTO>(
                    getPositionPnlUsdFunction, blockParameter);
        }

        public Task<GetShiftOutputDTO> GetShiftQueryAsync(GetShiftFunction getShiftFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetShiftFunction, GetShiftOutputDTO>(
                getShiftFunction, blockParameter);
        }

        public Task<GetShiftOutputDTO> GetShiftQueryAsync(string dataStore, byte[] key,
            BlockParameter blockParameter = null)
        {
            var getShiftFunction = new GetShiftFunction();
            getShiftFunction.DataStore = dataStore;
            getShiftFunction.Key = key;

            return ContractHandler.QueryDeserializingToObjectAsync<GetShiftFunction, GetShiftOutputDTO>(
                getShiftFunction, blockParameter);
        }

        public Task<GetSwapAmountOutOutputDTO> GetSwapAmountOutQueryAsync(
            GetSwapAmountOutFunction getSwapAmountOutFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetSwapAmountOutFunction, GetSwapAmountOutOutputDTO>(
                getSwapAmountOutFunction, blockParameter);
        }

        public Task<GetSwapAmountOutOutputDTO> GetSwapAmountOutQueryAsync(string dataStore, Props market,
            MarketPrices prices, string tokenIn, BigInteger amountIn, string uiFeeReceiver,
            BlockParameter blockParameter = null)
        {
            var getSwapAmountOutFunction = new GetSwapAmountOutFunction();
            getSwapAmountOutFunction.DataStore = dataStore;
            getSwapAmountOutFunction.Market = market;
            getSwapAmountOutFunction.Prices = prices;
            getSwapAmountOutFunction.TokenIn = tokenIn;
            getSwapAmountOutFunction.AmountIn = amountIn;
            getSwapAmountOutFunction.UiFeeReceiver = uiFeeReceiver;

            return ContractHandler.QueryDeserializingToObjectAsync<GetSwapAmountOutFunction, GetSwapAmountOutOutputDTO>(
                getSwapAmountOutFunction, blockParameter);
        }

        public Task<GetSwapPriceImpactOutputDTO> GetSwapPriceImpactQueryAsync(
            GetSwapPriceImpactFunction getSwapPriceImpactFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetSwapPriceImpactFunction, GetSwapPriceImpactOutputDTO>(
                    getSwapPriceImpactFunction, blockParameter);
        }

        public Task<GetSwapPriceImpactOutputDTO> GetSwapPriceImpactQueryAsync(string dataStore, string marketKey,
            string tokenIn, string tokenOut, BigInteger amountIn, Props tokenInPrice, Props tokenOutPrice,
            BlockParameter blockParameter = null)
        {
            var getSwapPriceImpactFunction = new GetSwapPriceImpactFunction();
            getSwapPriceImpactFunction.DataStore = dataStore;
            getSwapPriceImpactFunction.MarketKey = marketKey;
            getSwapPriceImpactFunction.TokenIn = tokenIn;
            getSwapPriceImpactFunction.TokenOut = tokenOut;
            getSwapPriceImpactFunction.AmountIn = amountIn;
            getSwapPriceImpactFunction.TokenInPrice = tokenInPrice;
            getSwapPriceImpactFunction.TokenOutPrice = tokenOutPrice;

            return ContractHandler
                .QueryDeserializingToObjectAsync<GetSwapPriceImpactFunction, GetSwapPriceImpactOutputDTO>(
                    getSwapPriceImpactFunction, blockParameter);
        }

        public Task<GetWithdrawalOutputDTO> GetWithdrawalQueryAsync(GetWithdrawalFunction getWithdrawalFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryDeserializingToObjectAsync<GetWithdrawalFunction, GetWithdrawalOutputDTO>(
                getWithdrawalFunction, blockParameter);
        }

        public Task<GetWithdrawalOutputDTO> GetWithdrawalQueryAsync(string dataStore, byte[] key,
            BlockParameter blockParameter = null)
        {
            var getWithdrawalFunction = new GetWithdrawalFunction();
            getWithdrawalFunction.DataStore = dataStore;
            getWithdrawalFunction.Key = key;

            return ContractHandler.QueryDeserializingToObjectAsync<GetWithdrawalFunction, GetWithdrawalOutputDTO>(
                getWithdrawalFunction, blockParameter);
        }

        public Task<GetWithdrawalAmountOutOutputDTO> GetWithdrawalAmountOutQueryAsync(
            GetWithdrawalAmountOutFunction getWithdrawalAmountOutFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetWithdrawalAmountOutFunction, GetWithdrawalAmountOutOutputDTO>(
                    getWithdrawalAmountOutFunction, blockParameter);
        }

        public Task<GetWithdrawalAmountOutOutputDTO> GetWithdrawalAmountOutQueryAsync(string dataStore, Props market,
            MarketPrices prices, BigInteger marketTokenAmount, string uiFeeReceiver, byte swapPricingType,
            BlockParameter blockParameter = null)
        {
            var getWithdrawalAmountOutFunction = new GetWithdrawalAmountOutFunction();
            getWithdrawalAmountOutFunction.DataStore = dataStore;
            getWithdrawalAmountOutFunction.Market = market;
            getWithdrawalAmountOutFunction.Prices = prices;
            getWithdrawalAmountOutFunction.MarketTokenAmount = marketTokenAmount;
            getWithdrawalAmountOutFunction.UiFeeReceiver = uiFeeReceiver;
            getWithdrawalAmountOutFunction.SwapPricingType = swapPricingType;

            return ContractHandler
                .QueryDeserializingToObjectAsync<GetWithdrawalAmountOutFunction, GetWithdrawalAmountOutOutputDTO>(
                    getWithdrawalAmountOutFunction, blockParameter);
        }

        public Task<IsPositionLiquidatableOutputDTO> IsPositionLiquidatableQueryAsync(
            IsPositionLiquidatableFunction isPositionLiquidatableFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<IsPositionLiquidatableFunction, IsPositionLiquidatableOutputDTO>(
                    isPositionLiquidatableFunction, blockParameter);
        }

        public Task<IsPositionLiquidatableOutputDTO> IsPositionLiquidatableQueryAsync(string dataStore,
            string referralStorage, byte[] positionKey, Props market, MarketPrices prices,
            bool shouldValidateMinCollateralUsd, BlockParameter blockParameter = null)
        {
            var isPositionLiquidatableFunction = new IsPositionLiquidatableFunction();
            isPositionLiquidatableFunction.DataStore = dataStore;
            isPositionLiquidatableFunction.ReferralStorage = referralStorage;
            isPositionLiquidatableFunction.PositionKey = positionKey;
            isPositionLiquidatableFunction.Market = market;
            isPositionLiquidatableFunction.Prices = prices;
            isPositionLiquidatableFunction.ShouldValidateMinCollateralUsd = shouldValidateMinCollateralUsd;

            return ContractHandler
                .QueryDeserializingToObjectAsync<IsPositionLiquidatableFunction, IsPositionLiquidatableOutputDTO>(
                    isPositionLiquidatableFunction, blockParameter);
        }

        public override List<Type> GetAllFunctionTypes()
        {
            return new List<Type>
            {
                typeof(GetAccountOrdersFunction),
                typeof(GetAccountPositionInfoListFunction),
                typeof(GetAccountPositionsFunction),
                typeof(GetAdlStateFunction),
                typeof(GetDepositFunction),
                typeof(GetDepositAmountOutFunction),
                typeof(GetExecutionPriceFunction),
                typeof(GetMarketFunction),
                typeof(GetMarketBySaltFunction),
                typeof(GetMarketInfoFunction),
                typeof(GetMarketInfoListFunction),
                typeof(GetMarketTokenPriceFunction),
                typeof(GetMarketsFunction),
                typeof(GetNetPnlFunction),
                typeof(GetOpenInterestWithPnlFunction),
                typeof(GetOrderFunction),
                typeof(GetPnlFunction),
                typeof(GetPnlToPoolFactorFunction),
                typeof(GetPositionFunction),
                typeof(GetPositionInfoFunction),
                typeof(GetPositionInfoListFunction),
                typeof(GetPositionPnlUsdFunction),
                typeof(GetShiftFunction),
                typeof(GetSwapAmountOutFunction),
                typeof(GetSwapPriceImpactFunction),
                typeof(GetWithdrawalFunction),
                typeof(GetWithdrawalAmountOutFunction),
                typeof(IsPositionLiquidatableFunction)
            };
        }

        public override List<Type> GetAllEventTypes()
        {
            return new List<Type>
            {
            };
        }

        public override List<Type> GetAllErrorTypes()
        {
            return new List<Type>
            {
            };
        }
    }
}