using System.Numerics;
using Managing.ABI.GmxV2.Reader.ContractDefinition;
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Web3;

namespace Managing.ABI.GmxV2.Reader
{
    public partial class ReaderService : ContractWeb3ServiceBase
    {
        public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.IWeb3 web3,
            ReaderDeployment readerDeployment, CancellationTokenSource cancellationTokenSource = null)
        {
            return web3.Eth.GetContractDeploymentHandler<ReaderDeployment>()
                .SendRequestAndWaitForReceiptAsync(readerDeployment, cancellationTokenSource);
        }

        public static Task<string> DeployContractAsync(Nethereum.Web3.IWeb3 web3, ReaderDeployment readerDeployment)
        {
            return web3.Eth.GetContractDeploymentHandler<ReaderDeployment>().SendRequestAsync(readerDeployment);
        }

        public static async Task<ReaderService> DeployContractAndGetServiceAsync(Nethereum.Web3.IWeb3 web3,
            ReaderDeployment readerDeployment, CancellationTokenSource cancellationTokenSource = null)
        {
            var receipt = await DeployContractAndWaitForReceiptAsync(web3, readerDeployment, cancellationTokenSource);
            return new ReaderService(web3, receipt.ContractAddress);
        }

        public ReaderService(Nethereum.Web3.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, List<byte[]> positionKeys, List<MarketPrices> prices, string uiFeeReceiver,
            BlockParameter blockParameter = null)
        {
            var getAccountPositionInfoListFunction = new GetAccountPositionInfoListFunction();
            getAccountPositionInfoListFunction.DataStore = dataStore;
            getAccountPositionInfoListFunction.ReferralStorage = referralStorage;
            getAccountPositionInfoListFunction.PositionKeys = positionKeys;
            getAccountPositionInfoListFunction.Prices = prices;
            getAccountPositionInfoListFunction.UiFeeReceiver = uiFeeReceiver;

            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, Props 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, MarketsProps market,
            MarketPrice indexTokenPrice, MarketPrice longTokenPrice, MarketPrice 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<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 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(GetPositionPnlUsdFunction),
                typeof(GetShiftFunction),
                typeof(GetSwapAmountOutFunction),
                typeof(GetSwapPriceImpactFunction),
                typeof(GetWithdrawalFunction),
                typeof(GetWithdrawalAmountOutFunction)
            };
        }

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

        public override List<Type> GetAllErrorTypes()
        {
            return new List<Type>
            {
                typeof(DisabledMarketError),
                typeof(EmptyMarketError)
            };
        }
    }
}