Ejemplo n.º 1
0
        private string GetDepositWithdrawEventName(double amount, string assetId, int multiplier)
        {
            BaseAssetSettings baseAsset = null;
            string            assetType = null;

            if (_trackAssetsSttings.Fiat.Assets.Contains(assetId))
            {
                assetType = "Fiat";
                baseAsset = _trackAssetsSttings.Fiat.BaseAsset;
            }

            if (_trackAssetsSttings.Crypto.Assets.Contains(assetId))
            {
                assetType = "Crypto";
                baseAsset = _trackAssetsSttings.Crypto.BaseAsset;
            }

            return(!string.IsNullOrEmpty(assetType)
                ? $"{(amount > 0 ? "Deposit" : "Withdraw")}{assetType}{(baseAsset.Multiplier == 1 ? string.Empty : $"_{multiplier:g2}")}_{baseAsset.AssetId}"
                : null);
        }
Ejemplo n.º 2
0
        public async Task SendWithdrawDepositEventAsync(WithdrawDepositInfo model)
        {
            BaseAssetSettings baseAsset = GetBaseAsset(model.AssetId);

            if (baseAsset == null)
            {
                _log.WriteWarning(nameof(SendWithdrawDepositEventAsync), model.UserId, $"{model.AssetId} is not tracked. (asset is not in Fiat or Crypto lists)");
                return;
            }

            var assetAmount = await GetAmountAsync(model.AssetId, model.Amount, baseAsset.AssetId);

            if (assetAmount == 0)
            {
                _log.WriteWarning(nameof(SendWithdrawDepositEventAsync), model.UserId, $"Can't convert {model.Amount} {model.AssetId} to {baseAsset.AssetId} (Multiplier = {baseAsset.Multiplier})");
                return;
            }

            var walletEventName = await GetWalletEventNameAsync(assetAmount, model.AssetId);

            var eventName = GetDepositWithdrawEventName(assetAmount, model.AssetId, baseAsset.Multiplier);

            if (eventName == null)
            {
                return;
            }

            var trackerInfo = new TrackerInfo
            {
                Ip         = model.Ip,
                UserAgent  = model.UserAgent,
                UserId     = model.UserId,
                ClientInfo = model.ClientInfo
            };

            await SendEventAsync(trackerInfo, TrackerCategories.Wallet, walletEventName);
            await SendEventAsync(trackerInfo, TrackerCategories.Wallet, eventName, Math.Round(Math.Abs(assetAmount *baseAsset.Multiplier)).ToString(CultureInfo.InvariantCulture));
        }