Function calculateMaximumWithdrawAmount