Пример #1
0
        /// <summary>
        /// Evaluate if the user is eligible to withdraw the desired amount or not
        /// </summary>
        /// <param name="withdrawAmount"></param>
        /// <param name="withdrawLedgers"></param>
        /// <param name="withdrawLimit"></param>
        /// <param name="availableBalance"></param>
        /// <param name="currentBalance"></param>
        /// <param name="bestBid"> </param>
        /// <param name="bestAsk"> </param>
        /// <returns></returns>
        public bool EvaluateMaximumWithdrawLimit(decimal withdrawAmount, IList <Withdraw> withdrawLedgers,
                                                 WithdrawLimit withdrawLimit, decimal availableBalance, decimal currentBalance, decimal bestBid = 0, decimal bestAsk = 0)
        {
            if (withdrawLimit.DailyLimit != 0 && withdrawLimit.MonthlyLimit != 0)
            {
                // Set Daily and Monthly Limit
                SetLimits(withdrawLimit);
                // Set the amount used in the Daily and Monthly limit
                SetUsedLimits(withdrawLedgers, bestBid, bestAsk);
                // Evaluate the Maximum Withdraw, set it, and return response whether it went successfully or not
                if (EvaluateMaximumWithdrawUsd())
                {
                    // If we do not have sufficient balance, then the maximum withdrawal amount is the balance that we have
                    // at our disposal
                    if (availableBalance < _maximumWithdraw)
                    {
                        _maximumWithdraw = availableBalance;
                    }
                    _withheld = currentBalance - availableBalance;

                    // If the current withdraw amount is less than the maximum withdraw
                    return(withdrawAmount <= _maximumWithdraw);
                }
            }

            _maximumWithdraw  = 0;
            _dailyLimit       = 0;
            _dailyLimitUsed   = 0;
            _monthlyLimit     = 0;
            _monthlyLimitUsed = 0;

            return(false);
        }
Пример #2
0
 /// <summary>
 /// Sets teh limits of daily and monthly Withdraw limits
 /// </summary>
 private void SetLimits(WithdrawLimit withdrawLimit)
 {
     _dailyLimit   = withdrawLimit.DailyLimit;
     _monthlyLimit = withdrawLimit.MonthlyLimit;
 }