using System.Numerics;
using Managing.Tools.ABI.PositionRouter.ContractDefinition;
using Nethereum.Contracts.ContractHandlers;
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Web3;

namespace Managing.Tools.ABI.PositionRouter
{
    public class PositionRouterService
    {
        public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Web3 web3,
            PositionRouterDeployment positionRouterDeployment, CancellationTokenSource cancellationTokenSource = null)
        {
            return web3.Eth.GetContractDeploymentHandler<PositionRouterDeployment>()
                .SendRequestAndWaitForReceiptAsync(positionRouterDeployment, cancellationTokenSource);
        }

        public static Task<string> DeployContractAsync(Web3 web3, PositionRouterDeployment positionRouterDeployment)
        {
            return web3.Eth.GetContractDeploymentHandler<PositionRouterDeployment>()
                .SendRequestAsync(positionRouterDeployment);
        }

        public static async Task<PositionRouterService> DeployContractAndGetServiceAsync(Web3 web3,
            PositionRouterDeployment positionRouterDeployment, CancellationTokenSource cancellationTokenSource = null)
        {
            var receipt =
                await DeployContractAndWaitForReceiptAsync(web3, positionRouterDeployment, cancellationTokenSource);
            return new PositionRouterService(web3, receipt.ContractAddress);
        }

        protected IWeb3 Web3 { get; }

        public ContractHandler ContractHandler { get; }

        public PositionRouterService(Web3 web3, string contractAddress)
        {
            Web3 = web3;
            ContractHandler = web3.Eth.GetContractHandler(contractAddress);
        }

        public PositionRouterService(IWeb3 web3, string contractAddress)
        {
            Web3 = web3;
            ContractHandler = web3.Eth.GetContractHandler(contractAddress);
        }

        public Task<BigInteger> BasisPointsDivisorQueryAsync(BasisPointsDivisorFunction basisPointsDivisorFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<BasisPointsDivisorFunction, BigInteger>(basisPointsDivisorFunction,
                blockParameter);
        }


        public Task<BigInteger> BasisPointsDivisorQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<BasisPointsDivisorFunction, BigInteger>(null, blockParameter);
        }

        public Task<string> AdminQueryAsync(AdminFunction adminFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<AdminFunction, string>(adminFunction, blockParameter);
        }


        public Task<string> AdminQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<AdminFunction, string>(null, blockParameter);
        }

        public Task<string> ApproveRequestAsync(ApproveFunction approveFunction)
        {
            return ContractHandler.SendRequestAsync(approveFunction);
        }

        public Task<TransactionReceipt> ApproveRequestAndWaitForReceiptAsync(ApproveFunction approveFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(approveFunction, cancellationToken);
        }

        public Task<string> ApproveRequestAsync(string token, string spender, BigInteger amount)
        {
            var approveFunction = new ApproveFunction();
            approveFunction.Token = token;
            approveFunction.Spender = spender;
            approveFunction.Amount = amount;

            return ContractHandler.SendRequestAsync(approveFunction);
        }

        public Task<TransactionReceipt> ApproveRequestAndWaitForReceiptAsync(string token, string spender,
            BigInteger amount, CancellationTokenSource cancellationToken = null)
        {
            var approveFunction = new ApproveFunction();
            approveFunction.Token = token;
            approveFunction.Spender = spender;
            approveFunction.Amount = amount;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(approveFunction, cancellationToken);
        }

        public Task<BigInteger> CallbackGasLimitQueryAsync(CallbackGasLimitFunction callbackGasLimitFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<CallbackGasLimitFunction, BigInteger>(callbackGasLimitFunction,
                blockParameter);
        }


        public Task<BigInteger> CallbackGasLimitQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<CallbackGasLimitFunction, BigInteger>(null, blockParameter);
        }

        public Task<string> CancelDecreasePositionRequestAsync(
            CancelDecreasePositionFunction cancelDecreasePositionFunction)
        {
            return ContractHandler.SendRequestAsync(cancelDecreasePositionFunction);
        }

        public Task<TransactionReceipt> CancelDecreasePositionRequestAndWaitForReceiptAsync(
            CancelDecreasePositionFunction cancelDecreasePositionFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(cancelDecreasePositionFunction, cancellationToken);
        }

        public Task<string> CancelDecreasePositionRequestAsync(byte[] key, string executionFeeReceiver)
        {
            var cancelDecreasePositionFunction = new CancelDecreasePositionFunction();
            cancelDecreasePositionFunction.Key = key;
            cancelDecreasePositionFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAsync(cancelDecreasePositionFunction);
        }

        public Task<TransactionReceipt> CancelDecreasePositionRequestAndWaitForReceiptAsync(byte[] key,
            string executionFeeReceiver, CancellationTokenSource cancellationToken = null)
        {
            var cancelDecreasePositionFunction = new CancelDecreasePositionFunction();
            cancelDecreasePositionFunction.Key = key;
            cancelDecreasePositionFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(cancelDecreasePositionFunction, cancellationToken);
        }

        public Task<string> CancelIncreasePositionRequestAsync(
            CancelIncreasePositionFunction cancelIncreasePositionFunction)
        {
            return ContractHandler.SendRequestAsync(cancelIncreasePositionFunction);
        }

        public Task<TransactionReceipt> CancelIncreasePositionRequestAndWaitForReceiptAsync(
            CancelIncreasePositionFunction cancelIncreasePositionFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(cancelIncreasePositionFunction, cancellationToken);
        }

        public Task<string> CancelIncreasePositionRequestAsync(byte[] key, string executionFeeReceiver)
        {
            var cancelIncreasePositionFunction = new CancelIncreasePositionFunction();
            cancelIncreasePositionFunction.Key = key;
            cancelIncreasePositionFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAsync(cancelIncreasePositionFunction);
        }

        public Task<TransactionReceipt> CancelIncreasePositionRequestAndWaitForReceiptAsync(byte[] key,
            string executionFeeReceiver, CancellationTokenSource cancellationToken = null)
        {
            var cancelIncreasePositionFunction = new CancelIncreasePositionFunction();
            cancelIncreasePositionFunction.Key = key;
            cancelIncreasePositionFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(cancelIncreasePositionFunction, cancellationToken);
        }

        public Task<string> CreateDecreasePositionRequestAsync(
            CreateDecreasePositionFunction createDecreasePositionFunction)
        {
            return ContractHandler.SendRequestAsync(createDecreasePositionFunction);
        }

        public Task<TransactionReceipt> CreateDecreasePositionRequestAndWaitForReceiptAsync(
            CreateDecreasePositionFunction createDecreasePositionFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(createDecreasePositionFunction, cancellationToken);
        }

        public Task<string> CreateDecreasePositionRequestAsync(List<string> path, string indexToken,
            BigInteger collateralDelta, BigInteger sizeDelta, bool isLong, string receiver, BigInteger acceptablePrice,
            BigInteger minOut, BigInteger executionFee, bool withdrawETH, string callbackTarget)
        {
            var createDecreasePositionFunction = new CreateDecreasePositionFunction();
            createDecreasePositionFunction.Path = path;
            createDecreasePositionFunction.IndexToken = indexToken;
            createDecreasePositionFunction.CollateralDelta = collateralDelta;
            createDecreasePositionFunction.SizeDelta = sizeDelta;
            createDecreasePositionFunction.IsLong = isLong;
            createDecreasePositionFunction.Receiver = receiver;
            createDecreasePositionFunction.AcceptablePrice = acceptablePrice;
            createDecreasePositionFunction.MinOut = minOut;
            createDecreasePositionFunction.ExecutionFee = executionFee;
            createDecreasePositionFunction.WithdrawETH = withdrawETH;
            createDecreasePositionFunction.CallbackTarget = callbackTarget;

            return ContractHandler.SendRequestAsync(createDecreasePositionFunction);
        }

        public Task<TransactionReceipt> CreateDecreasePositionRequestAndWaitForReceiptAsync(List<string> path,
            string indexToken, BigInteger collateralDelta, BigInteger sizeDelta, bool isLong, string receiver,
            BigInteger acceptablePrice, BigInteger minOut, BigInteger executionFee, bool withdrawETH,
            string callbackTarget, CancellationTokenSource cancellationToken = null)
        {
            var createDecreasePositionFunction = new CreateDecreasePositionFunction();
            createDecreasePositionFunction.Path = path;
            createDecreasePositionFunction.IndexToken = indexToken;
            createDecreasePositionFunction.CollateralDelta = collateralDelta;
            createDecreasePositionFunction.SizeDelta = sizeDelta;
            createDecreasePositionFunction.IsLong = isLong;
            createDecreasePositionFunction.Receiver = receiver;
            createDecreasePositionFunction.AcceptablePrice = acceptablePrice;
            createDecreasePositionFunction.MinOut = minOut;
            createDecreasePositionFunction.ExecutionFee = executionFee;
            createDecreasePositionFunction.WithdrawETH = withdrawETH;
            createDecreasePositionFunction.CallbackTarget = callbackTarget;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(createDecreasePositionFunction, cancellationToken);
        }

        public Task<string> CreateIncreasePositionRequestAsync(
            CreateIncreasePositionFunction createIncreasePositionFunction)
        {
            return ContractHandler.SendRequestAsync(createIncreasePositionFunction);
        }

        public Task<TransactionReceipt> CreateIncreasePositionRequestAndWaitForReceiptAsync(
            CreateIncreasePositionFunction createIncreasePositionFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(createIncreasePositionFunction, cancellationToken);
        }

        public Task<string> CreateIncreasePositionRequestAsync(List<string> path, string indexToken,
            BigInteger amountIn, BigInteger minOut, BigInteger sizeDelta, bool isLong, BigInteger acceptablePrice,
            BigInteger executionFee, byte[] referralCode, string callbackTarget)
        {
            var createIncreasePositionFunction = new CreateIncreasePositionFunction();
            createIncreasePositionFunction.Path = path;
            createIncreasePositionFunction.IndexToken = indexToken;
            createIncreasePositionFunction.AmountIn = amountIn;
            createIncreasePositionFunction.MinOut = minOut;
            createIncreasePositionFunction.SizeDelta = sizeDelta;
            createIncreasePositionFunction.IsLong = isLong;
            createIncreasePositionFunction.AcceptablePrice = acceptablePrice;
            createIncreasePositionFunction.ExecutionFee = executionFee;
            createIncreasePositionFunction.ReferralCode = referralCode;
            createIncreasePositionFunction.CallbackTarget = callbackTarget;

            return ContractHandler.SendRequestAsync(createIncreasePositionFunction);
        }

        public Task<TransactionReceipt> CreateIncreasePositionRequestAndWaitForReceiptAsync(List<string> path,
            string indexToken, BigInteger amountIn, BigInteger minOut, BigInteger sizeDelta, bool isLong,
            BigInteger acceptablePrice, BigInteger executionFee, byte[] referralCode, string callbackTarget,
            CancellationTokenSource cancellationToken = null)
        {
            var createIncreasePositionFunction = new CreateIncreasePositionFunction();
            createIncreasePositionFunction.Path = path;
            createIncreasePositionFunction.IndexToken = indexToken;
            createIncreasePositionFunction.AmountIn = amountIn;
            createIncreasePositionFunction.MinOut = minOut;
            createIncreasePositionFunction.SizeDelta = sizeDelta;
            createIncreasePositionFunction.IsLong = isLong;
            createIncreasePositionFunction.AcceptablePrice = acceptablePrice;
            createIncreasePositionFunction.ExecutionFee = executionFee;
            createIncreasePositionFunction.ReferralCode = referralCode;
            createIncreasePositionFunction.CallbackTarget = callbackTarget;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(createIncreasePositionFunction, cancellationToken);
        }

        public Task<string> CreateIncreasePositionETHRequestAsync(
            CreateIncreasePositionETHFunction createIncreasePositionETHFunction)
        {
            return ContractHandler.SendRequestAsync(createIncreasePositionETHFunction);
        }

        public Task<TransactionReceipt> CreateIncreasePositionETHRequestAndWaitForReceiptAsync(
            CreateIncreasePositionETHFunction createIncreasePositionETHFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(createIncreasePositionETHFunction,
                cancellationToken);
        }

        public Task<string> CreateIncreasePositionETHRequestAsync(List<string> path, string indexToken,
            BigInteger minOut, BigInteger sizeDelta, bool isLong, BigInteger acceptablePrice, BigInteger executionFee,
            byte[] referralCode, string callbackTarget)
        {
            var createIncreasePositionETHFunction = new CreateIncreasePositionETHFunction();
            createIncreasePositionETHFunction.Path = path;
            createIncreasePositionETHFunction.IndexToken = indexToken;
            createIncreasePositionETHFunction.MinOut = minOut;
            createIncreasePositionETHFunction.SizeDelta = sizeDelta;
            createIncreasePositionETHFunction.IsLong = isLong;
            createIncreasePositionETHFunction.AcceptablePrice = acceptablePrice;
            createIncreasePositionETHFunction.ExecutionFee = executionFee;
            createIncreasePositionETHFunction.ReferralCode = referralCode;
            createIncreasePositionETHFunction.CallbackTarget = callbackTarget;

            return ContractHandler.SendRequestAsync(createIncreasePositionETHFunction);
        }

        public Task<TransactionReceipt> CreateIncreasePositionETHRequestAndWaitForReceiptAsync(List<string> path,
            string indexToken, BigInteger minOut, BigInteger sizeDelta, bool isLong, BigInteger acceptablePrice,
            BigInteger executionFee, byte[] referralCode, string callbackTarget,
            CancellationTokenSource cancellationToken = null)
        {
            var createIncreasePositionETHFunction = new CreateIncreasePositionETHFunction();
            createIncreasePositionETHFunction.Path = path;
            createIncreasePositionETHFunction.IndexToken = indexToken;
            createIncreasePositionETHFunction.MinOut = minOut;
            createIncreasePositionETHFunction.SizeDelta = sizeDelta;
            createIncreasePositionETHFunction.IsLong = isLong;
            createIncreasePositionETHFunction.AcceptablePrice = acceptablePrice;
            createIncreasePositionETHFunction.ExecutionFee = executionFee;
            createIncreasePositionETHFunction.ReferralCode = referralCode;
            createIncreasePositionETHFunction.CallbackTarget = callbackTarget;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(createIncreasePositionETHFunction,
                cancellationToken);
        }

        public Task<byte[]> DecreasePositionRequestKeysQueryAsync(
            DecreasePositionRequestKeysFunction decreasePositionRequestKeysFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<DecreasePositionRequestKeysFunction, byte[]>(
                decreasePositionRequestKeysFunction, blockParameter);
        }


        public Task<byte[]> DecreasePositionRequestKeysQueryAsync(BigInteger returnValue1,
            BlockParameter blockParameter = null)
        {
            var decreasePositionRequestKeysFunction = new DecreasePositionRequestKeysFunction();
            decreasePositionRequestKeysFunction.ReturnValue1 = returnValue1;

            return ContractHandler.QueryAsync<DecreasePositionRequestKeysFunction, byte[]>(
                decreasePositionRequestKeysFunction, blockParameter);
        }

        public Task<BigInteger> DecreasePositionRequestKeysStartQueryAsync(
            DecreasePositionRequestKeysStartFunction decreasePositionRequestKeysStartFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<DecreasePositionRequestKeysStartFunction, BigInteger>(
                decreasePositionRequestKeysStartFunction, blockParameter);
        }


        public Task<BigInteger> DecreasePositionRequestKeysStartQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<DecreasePositionRequestKeysStartFunction, BigInteger>(null,
                blockParameter);
        }

        public Task<DecreasePositionRequestsOutputDTO> DecreasePositionRequestsQueryAsync(
            DecreasePositionRequestsFunction decreasePositionRequestsFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<DecreasePositionRequestsFunction, DecreasePositionRequestsOutputDTO>(
                    decreasePositionRequestsFunction, blockParameter);
        }

        public Task<DecreasePositionRequestsOutputDTO> DecreasePositionRequestsQueryAsync(byte[] returnValue1,
            BlockParameter blockParameter = null)
        {
            var decreasePositionRequestsFunction = new DecreasePositionRequestsFunction();
            decreasePositionRequestsFunction.ReturnValue1 = returnValue1;

            return ContractHandler
                .QueryDeserializingToObjectAsync<DecreasePositionRequestsFunction, DecreasePositionRequestsOutputDTO>(
                    decreasePositionRequestsFunction, blockParameter);
        }

        public Task<BigInteger> DecreasePositionsIndexQueryAsync(
            DecreasePositionsIndexFunction decreasePositionsIndexFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<DecreasePositionsIndexFunction, BigInteger>(
                decreasePositionsIndexFunction, blockParameter);
        }


        public Task<BigInteger> DecreasePositionsIndexQueryAsync(string returnValue1,
            BlockParameter blockParameter = null)
        {
            var decreasePositionsIndexFunction = new DecreasePositionsIndexFunction();
            decreasePositionsIndexFunction.ReturnValue1 = returnValue1;

            return ContractHandler.QueryAsync<DecreasePositionsIndexFunction, BigInteger>(
                decreasePositionsIndexFunction, blockParameter);
        }

        public Task<BigInteger> DepositFeeQueryAsync(DepositFeeFunction depositFeeFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<DepositFeeFunction, BigInteger>(depositFeeFunction, blockParameter);
        }


        public Task<BigInteger> DepositFeeQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<DepositFeeFunction, BigInteger>(null, blockParameter);
        }

        public Task<string> ExecuteDecreasePositionRequestAsync(
            ExecuteDecreasePositionFunction executeDecreasePositionFunction)
        {
            return ContractHandler.SendRequestAsync(executeDecreasePositionFunction);
        }

        public Task<TransactionReceipt> ExecuteDecreasePositionRequestAndWaitForReceiptAsync(
            ExecuteDecreasePositionFunction executeDecreasePositionFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(executeDecreasePositionFunction,
                cancellationToken);
        }

        public Task<string> ExecuteDecreasePositionRequestAsync(byte[] key, string executionFeeReceiver)
        {
            var executeDecreasePositionFunction = new ExecuteDecreasePositionFunction();
            executeDecreasePositionFunction.Key = key;
            executeDecreasePositionFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAsync(executeDecreasePositionFunction);
        }

        public Task<TransactionReceipt> ExecuteDecreasePositionRequestAndWaitForReceiptAsync(byte[] key,
            string executionFeeReceiver, CancellationTokenSource cancellationToken = null)
        {
            var executeDecreasePositionFunction = new ExecuteDecreasePositionFunction();
            executeDecreasePositionFunction.Key = key;
            executeDecreasePositionFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(executeDecreasePositionFunction,
                cancellationToken);
        }

        public Task<string> ExecuteDecreasePositionsRequestAsync(
            ExecuteDecreasePositionsFunction executeDecreasePositionsFunction)
        {
            return ContractHandler.SendRequestAsync(executeDecreasePositionsFunction);
        }

        public Task<TransactionReceipt> ExecuteDecreasePositionsRequestAndWaitForReceiptAsync(
            ExecuteDecreasePositionsFunction executeDecreasePositionsFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(executeDecreasePositionsFunction,
                cancellationToken);
        }

        public Task<string> ExecuteDecreasePositionsRequestAsync(BigInteger endIndex, string executionFeeReceiver)
        {
            var executeDecreasePositionsFunction = new ExecuteDecreasePositionsFunction();
            executeDecreasePositionsFunction.EndIndex = endIndex;
            executeDecreasePositionsFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAsync(executeDecreasePositionsFunction);
        }

        public Task<TransactionReceipt> ExecuteDecreasePositionsRequestAndWaitForReceiptAsync(BigInteger endIndex,
            string executionFeeReceiver, CancellationTokenSource cancellationToken = null)
        {
            var executeDecreasePositionsFunction = new ExecuteDecreasePositionsFunction();
            executeDecreasePositionsFunction.EndIndex = endIndex;
            executeDecreasePositionsFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(executeDecreasePositionsFunction,
                cancellationToken);
        }

        public Task<string> ExecuteIncreasePositionRequestAsync(
            ExecuteIncreasePositionFunction executeIncreasePositionFunction)
        {
            return ContractHandler.SendRequestAsync(executeIncreasePositionFunction);
        }

        public Task<TransactionReceipt> ExecuteIncreasePositionRequestAndWaitForReceiptAsync(
            ExecuteIncreasePositionFunction executeIncreasePositionFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(executeIncreasePositionFunction,
                cancellationToken);
        }

        public Task<string> ExecuteIncreasePositionRequestAsync(byte[] key, string executionFeeReceiver)
        {
            var executeIncreasePositionFunction = new ExecuteIncreasePositionFunction();
            executeIncreasePositionFunction.Key = key;
            executeIncreasePositionFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAsync(executeIncreasePositionFunction);
        }

        public Task<TransactionReceipt> ExecuteIncreasePositionRequestAndWaitForReceiptAsync(byte[] key,
            string executionFeeReceiver, CancellationTokenSource cancellationToken = null)
        {
            var executeIncreasePositionFunction = new ExecuteIncreasePositionFunction();
            executeIncreasePositionFunction.Key = key;
            executeIncreasePositionFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(executeIncreasePositionFunction,
                cancellationToken);
        }

        public Task<string> ExecuteIncreasePositionsRequestAsync(
            ExecuteIncreasePositionsFunction executeIncreasePositionsFunction)
        {
            return ContractHandler.SendRequestAsync(executeIncreasePositionsFunction);
        }

        public Task<TransactionReceipt> ExecuteIncreasePositionsRequestAndWaitForReceiptAsync(
            ExecuteIncreasePositionsFunction executeIncreasePositionsFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(executeIncreasePositionsFunction,
                cancellationToken);
        }

        public Task<string> ExecuteIncreasePositionsRequestAsync(BigInteger endIndex, string executionFeeReceiver)
        {
            var executeIncreasePositionsFunction = new ExecuteIncreasePositionsFunction();
            executeIncreasePositionsFunction.EndIndex = endIndex;
            executeIncreasePositionsFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAsync(executeIncreasePositionsFunction);
        }

        public Task<TransactionReceipt> ExecuteIncreasePositionsRequestAndWaitForReceiptAsync(BigInteger endIndex,
            string executionFeeReceiver, CancellationTokenSource cancellationToken = null)
        {
            var executeIncreasePositionsFunction = new ExecuteIncreasePositionsFunction();
            executeIncreasePositionsFunction.EndIndex = endIndex;
            executeIncreasePositionsFunction.ExecutionFeeReceiver = executionFeeReceiver;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(executeIncreasePositionsFunction,
                cancellationToken);
        }

        public Task<BigInteger> FeeReservesQueryAsync(FeeReservesFunction feeReservesFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<FeeReservesFunction, BigInteger>(feeReservesFunction, blockParameter);
        }


        public Task<BigInteger> FeeReservesQueryAsync(string returnValue1, BlockParameter blockParameter = null)
        {
            var feeReservesFunction = new FeeReservesFunction();
            feeReservesFunction.ReturnValue1 = returnValue1;

            return ContractHandler.QueryAsync<FeeReservesFunction, BigInteger>(feeReservesFunction, blockParameter);
        }

        public Task<List<string>> GetDecreasePositionRequestPathQueryAsync(
            GetDecreasePositionRequestPathFunction getDecreasePositionRequestPathFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GetDecreasePositionRequestPathFunction, List<string>>(
                getDecreasePositionRequestPathFunction, blockParameter);
        }


        public Task<List<string>> GetDecreasePositionRequestPathQueryAsync(byte[] key,
            BlockParameter blockParameter = null)
        {
            var getDecreasePositionRequestPathFunction = new GetDecreasePositionRequestPathFunction();
            getDecreasePositionRequestPathFunction.Key = key;

            return ContractHandler.QueryAsync<GetDecreasePositionRequestPathFunction, List<string>>(
                getDecreasePositionRequestPathFunction, blockParameter);
        }

        public Task<List<string>> GetIncreasePositionRequestPathQueryAsync(
            GetIncreasePositionRequestPathFunction getIncreasePositionRequestPathFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GetIncreasePositionRequestPathFunction, List<string>>(
                getIncreasePositionRequestPathFunction, blockParameter);
        }


        public Task<List<string>> GetIncreasePositionRequestPathQueryAsync(byte[] key,
            BlockParameter blockParameter = null)
        {
            var getIncreasePositionRequestPathFunction = new GetIncreasePositionRequestPathFunction();
            getIncreasePositionRequestPathFunction.Key = key;

            return ContractHandler.QueryAsync<GetIncreasePositionRequestPathFunction, List<string>>(
                getIncreasePositionRequestPathFunction, blockParameter);
        }

        public Task<byte[]> GetRequestKeyQueryAsync(GetRequestKeyFunction getRequestKeyFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GetRequestKeyFunction, byte[]>(getRequestKeyFunction, blockParameter);
        }


        public Task<byte[]> GetRequestKeyQueryAsync(string account, BigInteger index,
            BlockParameter blockParameter = null)
        {
            var getRequestKeyFunction = new GetRequestKeyFunction();
            getRequestKeyFunction.Account = account;
            getRequestKeyFunction.Index = index;

            return ContractHandler.QueryAsync<GetRequestKeyFunction, byte[]>(getRequestKeyFunction, blockParameter);
        }

        public Task<GetRequestQueueLengthsOutputDTO> GetRequestQueueLengthsQueryAsync(
            GetRequestQueueLengthsFunction getRequestQueueLengthsFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetRequestQueueLengthsFunction, GetRequestQueueLengthsOutputDTO>(
                    getRequestQueueLengthsFunction, blockParameter);
        }

        public Task<GetRequestQueueLengthsOutputDTO> GetRequestQueueLengthsQueryAsync(
            BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<GetRequestQueueLengthsFunction, GetRequestQueueLengthsOutputDTO>(null,
                    blockParameter);
        }

        public Task<string> GovQueryAsync(GovFunction govFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GovFunction, string>(govFunction, blockParameter);
        }


        public Task<string> GovQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<GovFunction, string>(null, blockParameter);
        }

        public Task<BigInteger> IncreasePositionBufferBpsQueryAsync(
            IncreasePositionBufferBpsFunction increasePositionBufferBpsFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<IncreasePositionBufferBpsFunction, BigInteger>(
                increasePositionBufferBpsFunction, blockParameter);
        }


        public Task<BigInteger> IncreasePositionBufferBpsQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<IncreasePositionBufferBpsFunction, BigInteger>(null, blockParameter);
        }

        public Task<byte[]> IncreasePositionRequestKeysQueryAsync(
            IncreasePositionRequestKeysFunction increasePositionRequestKeysFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<IncreasePositionRequestKeysFunction, byte[]>(
                increasePositionRequestKeysFunction, blockParameter);
        }


        public Task<byte[]> IncreasePositionRequestKeysQueryAsync(BigInteger returnValue1,
            BlockParameter blockParameter = null)
        {
            var increasePositionRequestKeysFunction = new IncreasePositionRequestKeysFunction();
            increasePositionRequestKeysFunction.ReturnValue1 = returnValue1;

            return ContractHandler.QueryAsync<IncreasePositionRequestKeysFunction, byte[]>(
                increasePositionRequestKeysFunction, blockParameter);
        }

        public Task<BigInteger> IncreasePositionRequestKeysStartQueryAsync(
            IncreasePositionRequestKeysStartFunction increasePositionRequestKeysStartFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<IncreasePositionRequestKeysStartFunction, BigInteger>(
                increasePositionRequestKeysStartFunction, blockParameter);
        }


        public Task<BigInteger> IncreasePositionRequestKeysStartQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<IncreasePositionRequestKeysStartFunction, BigInteger>(null,
                blockParameter);
        }

        public Task<IncreasePositionRequestsOutputDTO> IncreasePositionRequestsQueryAsync(
            IncreasePositionRequestsFunction increasePositionRequestsFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler
                .QueryDeserializingToObjectAsync<IncreasePositionRequestsFunction, IncreasePositionRequestsOutputDTO>(
                    increasePositionRequestsFunction, blockParameter);
        }

        public Task<IncreasePositionRequestsOutputDTO> IncreasePositionRequestsQueryAsync(byte[] returnValue1,
            BlockParameter blockParameter = null)
        {
            var increasePositionRequestsFunction = new IncreasePositionRequestsFunction();
            increasePositionRequestsFunction.ReturnValue1 = returnValue1;

            return ContractHandler
                .QueryDeserializingToObjectAsync<IncreasePositionRequestsFunction, IncreasePositionRequestsOutputDTO>(
                    increasePositionRequestsFunction, blockParameter);
        }

        public Task<BigInteger> IncreasePositionsIndexQueryAsync(
            IncreasePositionsIndexFunction increasePositionsIndexFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<IncreasePositionsIndexFunction, BigInteger>(
                increasePositionsIndexFunction, blockParameter);
        }


        public Task<BigInteger> IncreasePositionsIndexQueryAsync(string returnValue1,
            BlockParameter blockParameter = null)
        {
            var increasePositionsIndexFunction = new IncreasePositionsIndexFunction();
            increasePositionsIndexFunction.ReturnValue1 = returnValue1;

            return ContractHandler.QueryAsync<IncreasePositionsIndexFunction, BigInteger>(
                increasePositionsIndexFunction, blockParameter);
        }

        public Task<bool> IsLeverageEnabledQueryAsync(IsLeverageEnabledFunction isLeverageEnabledFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<IsLeverageEnabledFunction, bool>(isLeverageEnabledFunction,
                blockParameter);
        }


        public Task<bool> IsLeverageEnabledQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<IsLeverageEnabledFunction, bool>(null, blockParameter);
        }

        public Task<bool> IsPositionKeeperQueryAsync(IsPositionKeeperFunction isPositionKeeperFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<IsPositionKeeperFunction, bool>(isPositionKeeperFunction, blockParameter);
        }


        public Task<bool> IsPositionKeeperQueryAsync(string returnValue1, BlockParameter blockParameter = null)
        {
            var isPositionKeeperFunction = new IsPositionKeeperFunction();
            isPositionKeeperFunction.ReturnValue1 = returnValue1;

            return ContractHandler.QueryAsync<IsPositionKeeperFunction, bool>(isPositionKeeperFunction, blockParameter);
        }

        public Task<BigInteger> MaxGlobalLongSizesQueryAsync(MaxGlobalLongSizesFunction maxGlobalLongSizesFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MaxGlobalLongSizesFunction, BigInteger>(maxGlobalLongSizesFunction,
                blockParameter);
        }


        public Task<BigInteger> MaxGlobalLongSizesQueryAsync(string returnValue1, BlockParameter blockParameter = null)
        {
            var maxGlobalLongSizesFunction = new MaxGlobalLongSizesFunction();
            maxGlobalLongSizesFunction.ReturnValue1 = returnValue1;

            return ContractHandler.QueryAsync<MaxGlobalLongSizesFunction, BigInteger>(maxGlobalLongSizesFunction,
                blockParameter);
        }

        public Task<BigInteger> MaxGlobalShortSizesQueryAsync(MaxGlobalShortSizesFunction maxGlobalShortSizesFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MaxGlobalShortSizesFunction, BigInteger>(maxGlobalShortSizesFunction,
                blockParameter);
        }


        public Task<BigInteger> MaxGlobalShortSizesQueryAsync(string returnValue1, BlockParameter blockParameter = null)
        {
            var maxGlobalShortSizesFunction = new MaxGlobalShortSizesFunction();
            maxGlobalShortSizesFunction.ReturnValue1 = returnValue1;

            return ContractHandler.QueryAsync<MaxGlobalShortSizesFunction, BigInteger>(maxGlobalShortSizesFunction,
                blockParameter);
        }

        public Task<BigInteger> MaxTimeDelayQueryAsync(MaxTimeDelayFunction maxTimeDelayFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MaxTimeDelayFunction, BigInteger>(maxTimeDelayFunction, blockParameter);
        }


        public Task<BigInteger> MaxTimeDelayQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MaxTimeDelayFunction, BigInteger>(null, blockParameter);
        }

        public Task<BigInteger> MinBlockDelayKeeperQueryAsync(MinBlockDelayKeeperFunction minBlockDelayKeeperFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MinBlockDelayKeeperFunction, BigInteger>(minBlockDelayKeeperFunction,
                blockParameter);
        }


        public Task<BigInteger> MinBlockDelayKeeperQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MinBlockDelayKeeperFunction, BigInteger>(null, blockParameter);
        }

        public Task<BigInteger> MinExecutionFeeQueryAsync(MinExecutionFeeFunction minExecutionFeeFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MinExecutionFeeFunction, BigInteger>(minExecutionFeeFunction,
                blockParameter);
        }


        public Task<BigInteger> MinExecutionFeeQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MinExecutionFeeFunction, BigInteger>(null, blockParameter);
        }

        public Task<BigInteger> MinTimeDelayPublicQueryAsync(MinTimeDelayPublicFunction minTimeDelayPublicFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MinTimeDelayPublicFunction, BigInteger>(minTimeDelayPublicFunction,
                blockParameter);
        }


        public Task<BigInteger> MinTimeDelayPublicQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<MinTimeDelayPublicFunction, BigInteger>(null, blockParameter);
        }

        public Task<string> ReferralStorageQueryAsync(ReferralStorageFunction referralStorageFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<ReferralStorageFunction, string>(referralStorageFunction, blockParameter);
        }


        public Task<string> ReferralStorageQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<ReferralStorageFunction, string>(null, blockParameter);
        }

        public Task<string> RouterQueryAsync(RouterFunction routerFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<RouterFunction, string>(routerFunction, blockParameter);
        }


        public Task<string> RouterQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<RouterFunction, string>(null, blockParameter);
        }

        public Task<string> SendValueRequestAsync(SendValueFunction sendValueFunction)
        {
            return ContractHandler.SendRequestAsync(sendValueFunction);
        }

        public Task<TransactionReceipt> SendValueRequestAndWaitForReceiptAsync(SendValueFunction sendValueFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(sendValueFunction, cancellationToken);
        }

        public Task<string> SendValueRequestAsync(string receiver, BigInteger amount)
        {
            var sendValueFunction = new SendValueFunction();
            sendValueFunction.Receiver = receiver;
            sendValueFunction.Amount = amount;

            return ContractHandler.SendRequestAsync(sendValueFunction);
        }

        public Task<TransactionReceipt> SendValueRequestAndWaitForReceiptAsync(string receiver, BigInteger amount,
            CancellationTokenSource cancellationToken = null)
        {
            var sendValueFunction = new SendValueFunction();
            sendValueFunction.Receiver = receiver;
            sendValueFunction.Amount = amount;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(sendValueFunction, cancellationToken);
        }

        public Task<string> SetAdminRequestAsync(SetAdminFunction setAdminFunction)
        {
            return ContractHandler.SendRequestAsync(setAdminFunction);
        }

        public Task<TransactionReceipt> SetAdminRequestAndWaitForReceiptAsync(SetAdminFunction setAdminFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setAdminFunction, cancellationToken);
        }

        public Task<string> SetAdminRequestAsync(string admin)
        {
            var setAdminFunction = new SetAdminFunction();
            setAdminFunction.Admin = admin;

            return ContractHandler.SendRequestAsync(setAdminFunction);
        }

        public Task<TransactionReceipt> SetAdminRequestAndWaitForReceiptAsync(string admin,
            CancellationTokenSource cancellationToken = null)
        {
            var setAdminFunction = new SetAdminFunction();
            setAdminFunction.Admin = admin;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setAdminFunction, cancellationToken);
        }

        public Task<string> SetCallbackGasLimitRequestAsync(SetCallbackGasLimitFunction setCallbackGasLimitFunction)
        {
            return ContractHandler.SendRequestAsync(setCallbackGasLimitFunction);
        }

        public Task<TransactionReceipt> SetCallbackGasLimitRequestAndWaitForReceiptAsync(
            SetCallbackGasLimitFunction setCallbackGasLimitFunction, CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setCallbackGasLimitFunction, cancellationToken);
        }

        public Task<string> SetCallbackGasLimitRequestAsync(BigInteger callbackGasLimit)
        {
            var setCallbackGasLimitFunction = new SetCallbackGasLimitFunction();
            setCallbackGasLimitFunction.CallbackGasLimit = callbackGasLimit;

            return ContractHandler.SendRequestAsync(setCallbackGasLimitFunction);
        }

        public Task<TransactionReceipt> SetCallbackGasLimitRequestAndWaitForReceiptAsync(BigInteger callbackGasLimit,
            CancellationTokenSource cancellationToken = null)
        {
            var setCallbackGasLimitFunction = new SetCallbackGasLimitFunction();
            setCallbackGasLimitFunction.CallbackGasLimit = callbackGasLimit;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setCallbackGasLimitFunction, cancellationToken);
        }

        public Task<string> SetDelayValuesRequestAsync(SetDelayValuesFunction setDelayValuesFunction)
        {
            return ContractHandler.SendRequestAsync(setDelayValuesFunction);
        }

        public Task<TransactionReceipt> SetDelayValuesRequestAndWaitForReceiptAsync(
            SetDelayValuesFunction setDelayValuesFunction, CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setDelayValuesFunction, cancellationToken);
        }

        public Task<string> SetDelayValuesRequestAsync(BigInteger minBlockDelayKeeper, BigInteger minTimeDelayPublic,
            BigInteger maxTimeDelay)
        {
            var setDelayValuesFunction = new SetDelayValuesFunction();
            setDelayValuesFunction.MinBlockDelayKeeper = minBlockDelayKeeper;
            setDelayValuesFunction.MinTimeDelayPublic = minTimeDelayPublic;
            setDelayValuesFunction.MaxTimeDelay = maxTimeDelay;

            return ContractHandler.SendRequestAsync(setDelayValuesFunction);
        }

        public Task<TransactionReceipt> SetDelayValuesRequestAndWaitForReceiptAsync(BigInteger minBlockDelayKeeper,
            BigInteger minTimeDelayPublic, BigInteger maxTimeDelay, CancellationTokenSource cancellationToken = null)
        {
            var setDelayValuesFunction = new SetDelayValuesFunction();
            setDelayValuesFunction.MinBlockDelayKeeper = minBlockDelayKeeper;
            setDelayValuesFunction.MinTimeDelayPublic = minTimeDelayPublic;
            setDelayValuesFunction.MaxTimeDelay = maxTimeDelay;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setDelayValuesFunction, cancellationToken);
        }

        public Task<string> SetDepositFeeRequestAsync(SetDepositFeeFunction setDepositFeeFunction)
        {
            return ContractHandler.SendRequestAsync(setDepositFeeFunction);
        }

        public Task<TransactionReceipt> SetDepositFeeRequestAndWaitForReceiptAsync(
            SetDepositFeeFunction setDepositFeeFunction, CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setDepositFeeFunction, cancellationToken);
        }

        public Task<string> SetDepositFeeRequestAsync(BigInteger depositFee)
        {
            var setDepositFeeFunction = new SetDepositFeeFunction();
            setDepositFeeFunction.DepositFee = depositFee;

            return ContractHandler.SendRequestAsync(setDepositFeeFunction);
        }

        public Task<TransactionReceipt> SetDepositFeeRequestAndWaitForReceiptAsync(BigInteger depositFee,
            CancellationTokenSource cancellationToken = null)
        {
            var setDepositFeeFunction = new SetDepositFeeFunction();
            setDepositFeeFunction.DepositFee = depositFee;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setDepositFeeFunction, cancellationToken);
        }

        public Task<string> SetGovRequestAsync(SetGovFunction setGovFunction)
        {
            return ContractHandler.SendRequestAsync(setGovFunction);
        }

        public Task<TransactionReceipt> SetGovRequestAndWaitForReceiptAsync(SetGovFunction setGovFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setGovFunction, cancellationToken);
        }

        public Task<string> SetGovRequestAsync(string gov)
        {
            var setGovFunction = new SetGovFunction();
            setGovFunction.Gov = gov;

            return ContractHandler.SendRequestAsync(setGovFunction);
        }

        public Task<TransactionReceipt> SetGovRequestAndWaitForReceiptAsync(string gov,
            CancellationTokenSource cancellationToken = null)
        {
            var setGovFunction = new SetGovFunction();
            setGovFunction.Gov = gov;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setGovFunction, cancellationToken);
        }

        public Task<string> SetIncreasePositionBufferBpsRequestAsync(
            SetIncreasePositionBufferBpsFunction setIncreasePositionBufferBpsFunction)
        {
            return ContractHandler.SendRequestAsync(setIncreasePositionBufferBpsFunction);
        }

        public Task<TransactionReceipt> SetIncreasePositionBufferBpsRequestAndWaitForReceiptAsync(
            SetIncreasePositionBufferBpsFunction setIncreasePositionBufferBpsFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setIncreasePositionBufferBpsFunction,
                cancellationToken);
        }

        public Task<string> SetIncreasePositionBufferBpsRequestAsync(BigInteger increasePositionBufferBps)
        {
            var setIncreasePositionBufferBpsFunction = new SetIncreasePositionBufferBpsFunction();
            setIncreasePositionBufferBpsFunction.IncreasePositionBufferBps = increasePositionBufferBps;

            return ContractHandler.SendRequestAsync(setIncreasePositionBufferBpsFunction);
        }

        public Task<TransactionReceipt> SetIncreasePositionBufferBpsRequestAndWaitForReceiptAsync(
            BigInteger increasePositionBufferBps, CancellationTokenSource cancellationToken = null)
        {
            var setIncreasePositionBufferBpsFunction = new SetIncreasePositionBufferBpsFunction();
            setIncreasePositionBufferBpsFunction.IncreasePositionBufferBps = increasePositionBufferBps;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setIncreasePositionBufferBpsFunction,
                cancellationToken);
        }

        public Task<string> SetIsLeverageEnabledRequestAsync(SetIsLeverageEnabledFunction setIsLeverageEnabledFunction)
        {
            return ContractHandler.SendRequestAsync(setIsLeverageEnabledFunction);
        }

        public Task<TransactionReceipt> SetIsLeverageEnabledRequestAndWaitForReceiptAsync(
            SetIsLeverageEnabledFunction setIsLeverageEnabledFunction, CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setIsLeverageEnabledFunction, cancellationToken);
        }

        public Task<string> SetIsLeverageEnabledRequestAsync(bool isLeverageEnabled)
        {
            var setIsLeverageEnabledFunction = new SetIsLeverageEnabledFunction();
            setIsLeverageEnabledFunction.IsLeverageEnabled = isLeverageEnabled;

            return ContractHandler.SendRequestAsync(setIsLeverageEnabledFunction);
        }

        public Task<TransactionReceipt> SetIsLeverageEnabledRequestAndWaitForReceiptAsync(bool isLeverageEnabled,
            CancellationTokenSource cancellationToken = null)
        {
            var setIsLeverageEnabledFunction = new SetIsLeverageEnabledFunction();
            setIsLeverageEnabledFunction.IsLeverageEnabled = isLeverageEnabled;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setIsLeverageEnabledFunction, cancellationToken);
        }

        public Task<string> SetMaxGlobalSizesRequestAsync(SetMaxGlobalSizesFunction setMaxGlobalSizesFunction)
        {
            return ContractHandler.SendRequestAsync(setMaxGlobalSizesFunction);
        }

        public Task<TransactionReceipt> SetMaxGlobalSizesRequestAndWaitForReceiptAsync(
            SetMaxGlobalSizesFunction setMaxGlobalSizesFunction, CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setMaxGlobalSizesFunction, cancellationToken);
        }

        public Task<string> SetMaxGlobalSizesRequestAsync(List<string> tokens, List<BigInteger> longSizes,
            List<BigInteger> shortSizes)
        {
            var setMaxGlobalSizesFunction = new SetMaxGlobalSizesFunction();
            setMaxGlobalSizesFunction.Tokens = tokens;
            setMaxGlobalSizesFunction.LongSizes = longSizes;
            setMaxGlobalSizesFunction.ShortSizes = shortSizes;

            return ContractHandler.SendRequestAsync(setMaxGlobalSizesFunction);
        }

        public Task<TransactionReceipt> SetMaxGlobalSizesRequestAndWaitForReceiptAsync(List<string> tokens,
            List<BigInteger> longSizes, List<BigInteger> shortSizes, CancellationTokenSource cancellationToken = null)
        {
            var setMaxGlobalSizesFunction = new SetMaxGlobalSizesFunction();
            setMaxGlobalSizesFunction.Tokens = tokens;
            setMaxGlobalSizesFunction.LongSizes = longSizes;
            setMaxGlobalSizesFunction.ShortSizes = shortSizes;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setMaxGlobalSizesFunction, cancellationToken);
        }

        public Task<string> SetMinExecutionFeeRequestAsync(SetMinExecutionFeeFunction setMinExecutionFeeFunction)
        {
            return ContractHandler.SendRequestAsync(setMinExecutionFeeFunction);
        }

        public Task<TransactionReceipt> SetMinExecutionFeeRequestAndWaitForReceiptAsync(
            SetMinExecutionFeeFunction setMinExecutionFeeFunction, CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setMinExecutionFeeFunction, cancellationToken);
        }

        public Task<string> SetMinExecutionFeeRequestAsync(BigInteger minExecutionFee)
        {
            var setMinExecutionFeeFunction = new SetMinExecutionFeeFunction();
            setMinExecutionFeeFunction.MinExecutionFee = minExecutionFee;

            return ContractHandler.SendRequestAsync(setMinExecutionFeeFunction);
        }

        public Task<TransactionReceipt> SetMinExecutionFeeRequestAndWaitForReceiptAsync(BigInteger minExecutionFee,
            CancellationTokenSource cancellationToken = null)
        {
            var setMinExecutionFeeFunction = new SetMinExecutionFeeFunction();
            setMinExecutionFeeFunction.MinExecutionFee = minExecutionFee;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setMinExecutionFeeFunction, cancellationToken);
        }

        public Task<string> SetPositionKeeperRequestAsync(SetPositionKeeperFunction setPositionKeeperFunction)
        {
            return ContractHandler.SendRequestAsync(setPositionKeeperFunction);
        }

        public Task<TransactionReceipt> SetPositionKeeperRequestAndWaitForReceiptAsync(
            SetPositionKeeperFunction setPositionKeeperFunction, CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setPositionKeeperFunction, cancellationToken);
        }

        public Task<string> SetPositionKeeperRequestAsync(string account, bool isActive)
        {
            var setPositionKeeperFunction = new SetPositionKeeperFunction();
            setPositionKeeperFunction.Account = account;
            setPositionKeeperFunction.IsActive = isActive;

            return ContractHandler.SendRequestAsync(setPositionKeeperFunction);
        }

        public Task<TransactionReceipt> SetPositionKeeperRequestAndWaitForReceiptAsync(string account, bool isActive,
            CancellationTokenSource cancellationToken = null)
        {
            var setPositionKeeperFunction = new SetPositionKeeperFunction();
            setPositionKeeperFunction.Account = account;
            setPositionKeeperFunction.IsActive = isActive;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setPositionKeeperFunction, cancellationToken);
        }

        public Task<string> SetReferralStorageRequestAsync(SetReferralStorageFunction setReferralStorageFunction)
        {
            return ContractHandler.SendRequestAsync(setReferralStorageFunction);
        }

        public Task<TransactionReceipt> SetReferralStorageRequestAndWaitForReceiptAsync(
            SetReferralStorageFunction setReferralStorageFunction, CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setReferralStorageFunction, cancellationToken);
        }

        public Task<string> SetReferralStorageRequestAsync(string referralStorage)
        {
            var setReferralStorageFunction = new SetReferralStorageFunction();
            setReferralStorageFunction.ReferralStorage = referralStorage;

            return ContractHandler.SendRequestAsync(setReferralStorageFunction);
        }

        public Task<TransactionReceipt> SetReferralStorageRequestAndWaitForReceiptAsync(string referralStorage,
            CancellationTokenSource cancellationToken = null)
        {
            var setReferralStorageFunction = new SetReferralStorageFunction();
            setReferralStorageFunction.ReferralStorage = referralStorage;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setReferralStorageFunction, cancellationToken);
        }

        public Task<string> SetRequestKeysStartValuesRequestAsync(
            SetRequestKeysStartValuesFunction setRequestKeysStartValuesFunction)
        {
            return ContractHandler.SendRequestAsync(setRequestKeysStartValuesFunction);
        }

        public Task<TransactionReceipt> SetRequestKeysStartValuesRequestAndWaitForReceiptAsync(
            SetRequestKeysStartValuesFunction setRequestKeysStartValuesFunction,
            CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(setRequestKeysStartValuesFunction,
                cancellationToken);
        }

        public Task<string> SetRequestKeysStartValuesRequestAsync(BigInteger increasePositionRequestKeysStart,
            BigInteger decreasePositionRequestKeysStart)
        {
            var setRequestKeysStartValuesFunction = new SetRequestKeysStartValuesFunction();
            setRequestKeysStartValuesFunction.IncreasePositionRequestKeysStart = increasePositionRequestKeysStart;
            setRequestKeysStartValuesFunction.DecreasePositionRequestKeysStart = decreasePositionRequestKeysStart;

            return ContractHandler.SendRequestAsync(setRequestKeysStartValuesFunction);
        }

        public Task<TransactionReceipt> SetRequestKeysStartValuesRequestAndWaitForReceiptAsync(
            BigInteger increasePositionRequestKeysStart, BigInteger decreasePositionRequestKeysStart,
            CancellationTokenSource cancellationToken = null)
        {
            var setRequestKeysStartValuesFunction = new SetRequestKeysStartValuesFunction();
            setRequestKeysStartValuesFunction.IncreasePositionRequestKeysStart = increasePositionRequestKeysStart;
            setRequestKeysStartValuesFunction.DecreasePositionRequestKeysStart = decreasePositionRequestKeysStart;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(setRequestKeysStartValuesFunction,
                cancellationToken);
        }

        public Task<string> ShortsTrackerQueryAsync(ShortsTrackerFunction shortsTrackerFunction,
            BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<ShortsTrackerFunction, string>(shortsTrackerFunction, blockParameter);
        }


        public Task<string> ShortsTrackerQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<ShortsTrackerFunction, string>(null, blockParameter);
        }

        public Task<string> VaultQueryAsync(VaultFunction vaultFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<VaultFunction, string>(vaultFunction, blockParameter);
        }


        public Task<string> VaultQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<VaultFunction, string>(null, blockParameter);
        }

        public Task<string> WethQueryAsync(WethFunction wethFunction, BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<WethFunction, string>(wethFunction, blockParameter);
        }


        public Task<string> WethQueryAsync(BlockParameter blockParameter = null)
        {
            return ContractHandler.QueryAsync<WethFunction, string>(null, blockParameter);
        }

        public Task<string> WithdrawFeesRequestAsync(WithdrawFeesFunction withdrawFeesFunction)
        {
            return ContractHandler.SendRequestAsync(withdrawFeesFunction);
        }

        public Task<TransactionReceipt> WithdrawFeesRequestAndWaitForReceiptAsync(
            WithdrawFeesFunction withdrawFeesFunction, CancellationTokenSource cancellationToken = null)
        {
            return ContractHandler.SendRequestAndWaitForReceiptAsync(withdrawFeesFunction, cancellationToken);
        }

        public Task<string> WithdrawFeesRequestAsync(string token, string receiver)
        {
            var withdrawFeesFunction = new WithdrawFeesFunction();
            withdrawFeesFunction.Token = token;
            withdrawFeesFunction.Receiver = receiver;

            return ContractHandler.SendRequestAsync(withdrawFeesFunction);
        }

        public Task<TransactionReceipt> WithdrawFeesRequestAndWaitForReceiptAsync(string token, string receiver,
            CancellationTokenSource cancellationToken = null)
        {
            var withdrawFeesFunction = new WithdrawFeesFunction();
            withdrawFeesFunction.Token = token;
            withdrawFeesFunction.Receiver = receiver;

            return ContractHandler.SendRequestAndWaitForReceiptAsync(withdrawFeesFunction, cancellationToken);
        }
    }
}