Exemple #1
0
        public async Task <OperationFeesModel> GetOperationFeesAsync()
        {
            var operationFees = new OperationFeesModel();

            var operationFeesConfig = await _crossChainWalletLinkerClient.ConfigurationApi.GetAllAsync();

            foreach (var model in operationFeesConfig)
            {
                switch (model.Type)
                {
                case ConfigurationItemType.FirstTimeLinkingFee:
                    operationFees.FirstTimeLinkingFee = Money18.Parse(model.Value);
                    break;

                case ConfigurationItemType.SubsequentLinkingFee:
                    operationFees.SubsequentLinkingFee = Money18.Parse(model.Value);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            var crossChainTransferFee = await _crossChainTransfersClient.FeesApi.GetTransferToPublicFeeAsync();

            operationFees.CrossChainTransferFee = crossChainTransferFee.Fee;

            return(operationFees);
        }
        public async Task UpdateOperationFeesAsync(OperationFeesModel model)
        {
            if (model.CrossChainTransferFee.HasValue)
            {
                var setTransferToPublicFeeResponse = await _crossChainTransfersClient.FeesApi.SetTransferToPublicFeeAsync(new SetTransferToPublicFeeRequest
                {
                    Fee = model.CrossChainTransferFee.Value
                });

                if (setTransferToPublicFeeResponse.Error != FeesErrorCodes.None)
                {
                    throw LykkeApiErrorException.BadRequest(ApiErrorCodes.Service.UnknownError);
                }
            }

            if (model.FirstTimeLinkingFee.HasValue)
            {
                var configurationItemUpdateResponseModel = await _crossChainWalletLinkerClient.ConfigurationApi.UpdateOrInsertItemAsync(new ConfigurationItemRequestModel
                {
                    Type  = ConfigurationItemType.FirstTimeLinkingFee,
                    Value = model.FirstTimeLinkingFee.Value.ToString()
                });

                if (configurationItemUpdateResponseModel.Error != ConfigurationItemUpdateError.None)
                {
                    throw LykkeApiErrorException.BadRequest(ApiErrorCodes.Service.UnknownError);
                }
            }

            if (model.SubsequentLinkingFee.HasValue)
            {
                var configurationItemUpdateResponseModel = await _crossChainWalletLinkerClient.ConfigurationApi.UpdateOrInsertItemAsync(new ConfigurationItemRequestModel
                {
                    Type  = ConfigurationItemType.SubsequentLinkingFee,
                    Value = model.SubsequentLinkingFee.Value.ToString()
                });

                if (configurationItemUpdateResponseModel.Error != ConfigurationItemUpdateError.None)
                {
                    throw LykkeApiErrorException.BadRequest(ApiErrorCodes.Service.UnknownError);
                }
            }

            await _auditLogPublisher.PublishAuditLogAsync(_requestContext.UserId, model.ToJson(), ActionType.UpdateOperationFees);
        }