public async Task <CreateWithdrawResponseModel> CreateWithdraw(string userId, CreateWithdrawModel model, bool isApi) { try { var estimatedPrice = await BalanceEstimationService.GetNZDPerCoin(model.CurrencyId).ConfigureAwait(false); var estimatedTotal = model.Amount * estimatedPrice; var verificationResult = await UserVerificationReader.GetVerificationStatus(userId); if (verificationResult.Level != VerificationLevel.Legacy && (verificationResult.Current + estimatedTotal) > verificationResult.Limit) { return new CreateWithdrawResponseModel { Error = $"Withdraw exceeds daily limit of ${verificationResult.Limit:F2} NZD." } } ; using (var tradeService = CreateService()) { var response = await tradeService.SubmitWithdrawAsync(new SubmitWithdrawRequest { Address = model.Address, Amount = model.Amount, CurrencyId = model.CurrencyId, TwoFactorToken = model.TwoFactorToken, Type = model.Type, UserId = new Guid(userId), EstimatedPrice = estimatedTotal, IsApi = isApi }).ConfigureAwait(false); return(new CreateWithdrawResponseModel { Error = response.Error, WithdrawId = response.WithdrawId // Notifications = await ProcessNotifications(response), }); } } catch (Exception) { return(new CreateWithdrawResponseModel { Error = "An Error occurred creating withdraw request, if problem persist please contact Cryptopia Support" }); } }
public async Task <CreateTransferResponseModel> CreateTransfer(string userId, CreateTransferModel model, bool isApi) { try { var estimatedPrice = await BalanceEstimationService.GetNZDPerCoin(model.CurrencyId).ConfigureAwait(false); var estimatedTotal = model.Amount * estimatedPrice; var verificationResult = await UserVerificationReader.GetVerificationStatus(userId); if (verificationResult.Level != VerificationLevel.Legacy && model.TransferType != TransferType.Paytopia && (verificationResult.Current + estimatedTotal) > verificationResult.Limit) { return new CreateTransferResponseModel { Error = $"Transfer exceeds daily limit of ${verificationResult.Limit:F2} NZD." } } ; using (var tradeService = CreateService()) { var response = await tradeService.SubmitTransferAsync(new SubmitTransferRequest { Amount = model.Amount, CurrencyId = model.CurrencyId, UserId = new Guid(userId), UserTo = new Guid(model.Receiver), TransferType = model.TransferType, EstimatedPrice = estimatedTotal, IsApi = isApi }).ConfigureAwait(false); return(new CreateTransferResponseModel { Error = response.Error, TransferId = response.TransferId, Notifications = await ProcessTransferNotifications(response), }); } } catch (Exception) { return(new CreateTransferResponseModel { Error = "An Error occurred placing transfer, if problem persist please contact Cryptopia Support" }); } }