private async Task UpdateColoredBalance(IObservableWallet wallet, int height, int minConfirmations) { var coloredCoins = await _blockChainProvider.GetColoredUnspentOutputsAsync(wallet.Address, minConfirmations); if (!coloredCoins.Any()) { return; } var coloredAssets = await _assetService.GetColoredAssetsAsync(); foreach (var coinsGroup in coloredCoins.GroupBy(o => o.AssetId)) { var blockchainAssetId = coinsGroup.Key.GetWif(_network).ToWif(); var coloredAsset = coloredAssets.FirstOrDefault(o => o.BlockchainAssetId == blockchainAssetId); if (coloredAsset == null) { _log.Warning($"Detected unknown colored asset deposit on address {wallet.Address}"); continue; } var balance = coinsGroup.Sum(o => o.Amount.Quantity); var walletBalanceEntity = WalletBalance.Create(wallet.Address, balance, height, coloredAsset.AssetId); await _balanceRepository.InsertOrReplaceAsync(walletBalanceEntity); } }
private object aspect_Symbol(object rowObject) { WalletBalance listItem = (WalletBalance)rowObject; int rowheight = listView.RowHeightEffective - 3; return(ContentManager.ResizeImage(ContentManager.GetSymbolIcon(listItem.Symbol), rowheight, rowheight)); }
private void toolStripButton_save_Click(object sender, EventArgs e) { foreach (Fork fork in forks) { WalletBalance listItem = PreferenceManager.WalletPreferences.WalletForks.FirstOrDefault(item => item.Name == wallet.Name && item.Symbol == fork.ticker.ToUpper()); if (listItem == null) { //fork.id = wallet.Name; Decimal balance = Decimal.Parse(fork.balance.expected.ToString(), System.Globalization.NumberStyles.Float) / 100000000; CoinMarketCapTicker ticker = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == fork.ticker.ToUpper() && item.name == fork.name); //decimal btcTotal = 0; //decimal usdTotal = 0; if (ticker != null) { fork.TotalInBTC = balance * ticker.price_btc; fork.TotalInUSD = balance * ticker.price_usd; } WalletBalance newBalance = new WalletBalance() { Address = fork.addr, Balance = balance, CoinName = fork.name, IsForkBalance = true, Name = wallet.Name, Symbol = fork.ticker.ToUpper(), TotalInBTC = fork.TotalInBTC, TotalInUSD = fork.TotalInUSD, WalletName = wallet.WalletName, Verified = true }; PreferenceManager.WalletPreferences.WalletForks.Add(newBalance); } else { Decimal balance = Decimal.Parse(fork.balance.expected.ToString(), System.Globalization.NumberStyles.Float) / 100000000; CoinMarketCapTicker ticker = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == fork.ticker.ToUpper() && item.name == fork.name); if (ticker != null) { listItem.Address = fork.addr; listItem.Verified = true; listItem.Balance = balance; listItem.TotalInBTC = balance * ticker.price_btc; listItem.TotalInUSD = balance * ticker.price_usd; } } PreferenceManager.UpdatePreferenceFile(PreferenceManager.PreferenceType.Wallet); FormManager.UpdateBalanceManager(true); //FormManager.UpdateWalletManager(); if (ParentForm != null) { ParentForm.Close(); } } }
private void listView_Wallets_CellEditFinishing(object sender, CellEditEventArgs e) { WalletBalance balance = listView_Wallets.SelectedObject as WalletBalance; if (balance != null) { WalletBalance listItem = PreferenceManager.WalletPreferences.WalletForks.FirstOrDefault(item => item.Symbol == balance.Symbol && item.Name == balance.Name); if (listItem != null) { try { Decimal newValue = Convert.ToDecimal(e.Control.Text); //LogManager.AddLogMessage(Name, "listView_Wallets_CellEditFinishing", balance.Symbol + " | " + e.Control.Text + " | " + e.Value, LogManager.LogMessageType.DEBUG); listItem.Balance = newValue; PreferenceManager.UpdatePreferenceFile(PreferenceManager.PreferenceType.Wallet); LoadWallets(); } catch (Exception ex) { LogManager.AddLogMessage(Name, "listView_Wallets_CellEditFinishing", ex.Message, LogManager.LogMessageType.EXCEPTION); } } } //LogManager.AddLogMessage(Name, "listView_Wallets_CellEditFinishing", sender + " | " + e.Control.Text + " | " + e.Value, LogManager.LogMessageType.DEBUG); }
public static List <WalletBalance> BinanceToWalletBalances(List <BalanceResponse> accountInfoBalances) { var walletBalances = new List <WalletBalance>(); foreach (var balance in accountInfoBalances) { if (balance.Locked + balance.Free > 0) { var walletBalance = new WalletBalance { Currency = balance.Asset, // BtcAmount = Convert.ToDecimal(balance.Value.BitcoinValue), Available = balance.Free, Balance = balance.Free + balance.Locked, Pending = balance.Locked, Exchange = Constants.Binance, Timestamp = DateTime.Now }; walletBalances.Add(walletBalance); } } return(walletBalances); }
public static List <WalletBalance> PoloniexToWalletBalances(IDictionary <string, Balance> balances) { var walletBalances = new List <WalletBalance>(); foreach (var balance in balances) { if (!(balance.Value.BitcoinValue > 0)) { continue; } var walletBalance = new WalletBalance { Currency = balance.Key, BtcAmount = Convert.ToDecimal(balance.Value.BitcoinValue), Available = Convert.ToDecimal(balance.Value.QuoteAvailable), Balance = Convert.ToDecimal(balance.Value.QuoteAvailable), Pending = Convert.ToDecimal(balance.Value.QuoteOnOrders), Exchange = Constants.Poloniex, Timestamp = DateTime.Now, Address = String.Empty }; walletBalances.Add(walletBalance); } return(walletBalances); }
private void listView_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (listView.FocusedItem.Bounds.Contains(e.Location) == true) { if (listView.SelectedObject != null) { WalletBalance item = listView.SelectedObject as WalletBalance; ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem menuItem = new ToolStripMenuItem() { Text = "Remove " + item.Name + "_" + item.Symbol + "_" + item.Address }; menuItem.Click += new EventHandler(RemoveItem_Menu_Click); menu.Items.Add(menuItem); //ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem importItem = new ToolStripMenuItem() { Text = "Import Forks For " + item.Name + "_" + item.Symbol + "_" + item.Address }; importItem.Click += new EventHandler(ImportItem_Menu_Click); menu.Items.Add(importItem); menu.Show(Cursor.Position); } } } }
public static List <WalletBalance> BittrexToWalletBalances(BittrexBalance[] response) { var walletBalances = new List <WalletBalance>(); foreach (var wallet in response) { if (wallet.Balance > 0) { var walletBalance = new WalletBalance { Exchange = Constants.Bittrex, Timestamp = DateTime.Now, Address = wallet.CryptoAddress, Available = wallet.Available, Balance = wallet.Balance, Pending = wallet.Pending, Currency = wallet.Currency, Requested = wallet.Requested, Uuid = wallet.Uuid }; if (String.IsNullOrEmpty(wallet.CryptoAddress)) { walletBalance.Address = String.Empty; } walletBalances.Add(walletBalance); } } return(walletBalances); }
private object aspect_walletIcon(object rowObject) { WalletBalance balance = (WalletBalance)rowObject; int rowheight = listView_Wallets.RowHeightEffective - 3; return(ContentManager.ResizeImage(ContentManager.GetWalletIcon(balance.WalletName), rowheight, rowheight)); //return ContentManager.GetWalletIcon(balance.WalletName); }
private async Task SendDustNotification(WalletBalance walletBalance) { var message = $"<strong>{Constants.Bittrex}</strong>: {DateTime.Now:g}\n" + $"<strong>Dust detected for {walletBalance.Currency}</strong>\n" + $"BTC Amount: {walletBalance.BtcAmount:#0.#############}\n"; await _bus.SendAsync(new SendMessageCommand(message)); }
private async Task DustManagement(WalletBalance walletBalance) { var bagDetected = _config.DustNotification != null && walletBalance.BtcAmount <= _config.DustNotification.Value; if (bagDetected) { await SendDustNotification(walletBalance); } }
private async Task BagManagement(decimal currentPrice, decimal averagePrice, WalletBalance walletBalance) { var percentageDrop = ProfitCalculator.PriceDifference(currentPrice, averagePrice); if (_config.BagNotification != null && percentageDrop < -_config.BagNotification.Value) { await SendBagNotification(walletBalance, averagePrice, currentPrice, percentageDrop); } }
private async Task SendDustNotification(WalletBalance walletBalance) { var sb = new StringBuffer(); sb.Append($"{StringContants.StrongOpen}{Constants.Binance}{StringContants.StrongClose}: {DateTime.Now:g}\n"); sb.Append($"{StringContants.StrongOpen}Dust detected for {walletBalance.Currency}{StringContants.StrongClose}\n"); sb.Append($"{_generalConfig.TradingCurrency} Amount: {walletBalance.BtcAmount:#0.#############}\n"); await _bus.SendAsync(new SendMessageCommand(sb)); }
private async Task DustManagement(WalletBalance walletBalance) { var bagDetected = walletBalance.BtcAmount <= _dustConfig.BtcAmount; if (bagDetected) { await SendDustNotification(walletBalance); } }
private void listView_Wallets_FormatRow(object sender, FormatRowEventArgs e) { WalletBalance wallet = (WalletBalance)e.Model; if (wallet.Verified) { //e.Item.BackColor = PreferenceManager.preferences.Theme.Yellow; e.Item.BackColor = PreferenceManager.preferences.Theme.Green; } }
private void listView_Wallets_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (listView_Wallets.FocusedItem.Bounds.Contains(e.Location) == true) { if (listView_Wallets.SelectedObject != null) { WalletBalance item = listView_Wallets.SelectedObject as WalletBalance; ForkData fork = ForkList.FirstOrDefault(f => f.Symbol == item.Symbol && f.Name == item.CoinName); ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem menuItem = new ToolStripMenuItem() { Text = "Copy Address To Clipboard " + item.Address, Image = ContentManager.GetIcon("ClipboardLoad") }; menuItem.Click += new EventHandler(CopyItem_Menu_Click); menu.Items.Add(menuItem); if (fork != null) { if (fork.Explorer.Length > 0) { ToolStripMenuItem importItem = new ToolStripMenuItem() { Text = "Check Balance For " + item.Name + "_" + item.Symbol + "_" + item.Address, Image = ContentManager.GetIcon("SearchList") }; importItem.Click += new EventHandler(CheckItem_Menu_Click); menu.Items.Add(importItem); } } menu.Items.Add(new ToolStripSeparator()); ToolStripMenuItem verifyItem = new ToolStripMenuItem() { Text = "Verify " + item.Address, Image = ContentManager.GetIcon("Unknown") }; verifyItem.Click += new EventHandler(VerifyItem_Menu_Click); menu.Items.Add(verifyItem); menu.Show(Cursor.Position); } } } }
public static WalletBalanceModel ToApiModel(this WalletBalance wb) { return(new WalletBalanceModel { Asset = wb.Currency, //Available = wb.Available, Balance = wb.Amount, Reserved = wb.Amount - wb.Available, //Type = wb.Type }); }
public static WalletBalance ToDomain(this WalletBalanceEntity entity) { var balance = new WalletBalance { Address = entity.Address, AssetId = entity.AssetId, Balance = entity.Balance, Ledger = entity.Ledger }; return(balance); }
public async Task InsertOrReplaceAsync(WalletBalance balance) { var entity = new WalletBalanceEntity { PartitionKey = GetPartitionKey(), RowKey = GetRowKey(balance.Address), Balance = balance.Balance, Ledger = balance.Ledger }; await _table.InsertOrReplaceAsync(entity); }
private async Task SendBagNotification(WalletBalance walletBalance, Trade lastTradeForPair, decimal currentPrice, decimal percentageDrop) { var message = $"<strong>{Constants.Bittrex}</strong>: {DateTime.Now:g}\n" + $"<strong>Bag detected for {walletBalance.Currency}</strong>\n" + $"Bought price: {lastTradeForPair.Limit:#0.#############}\n" + $"Current price: {currentPrice:#0.#############}\n" + $"Percentage: {percentageDrop}%\n" + $"Bought on: {lastTradeForPair.TimeStamp:g}\n" + $"Value: {walletBalance.Balance * currentPrice:#0.#####} BTC"; await _bus.SendAsync(new SendMessageCommand(message)); }
private async Task SendNotification(WalletBalance walletBalance, Trade lastTradeForPair, decimal currentPrice) { var message = $"{DateTime.Now:g}\n" + $"<strong>Bag detected for {walletBalance.Currency}</strong>\n" + $"Bought price: {lastTradeForPair.Limit:#0.#############}\n" + $"Current price: {currentPrice:#0.#############}\n" + $"Percentage drop: {PriceDifference(currentPrice, lastTradeForPair.Limit)}%\n" + $"Bought on: {lastTradeForPair.TimeStamp:g}\n" + $"Value: {walletBalance.Balance * currentPrice:#0.#############}"; await _bus.SendAsync(new SendMessageCommand(message)); }
private async Task <IWalletBalance> UpdateBalance(string address, long balance, int lastBlock) { if (balance != 0) { var walletBalanceEntity = WalletBalance.Create(address, balance, lastBlock); await _balanceRepository.InsertOrReplace(walletBalanceEntity); return(walletBalanceEntity); } await _balanceRepository.DeleteIfExist(address); return(null); }
private void ProcessBalance( WalletBalance depositWallet, IReadOnlyDictionary <string, EnrolledBalance> enrolledBalances, int batchSize) { if (!_assets.TryGetValue(depositWallet.AssetId, out var asset)) { if (!_warningAssets.Contains(depositWallet.AssetId)) { _log.Warning(nameof(ProcessBalance), "Lykke asset for the blockchain asset is not found", context: depositWallet); _warningAssets.Add(depositWallet.AssetId); } return; } enrolledBalances.TryGetValue(GetEnrolledBalancesDictionaryKey(depositWallet.Address, depositWallet.AssetId), out var enrolledBalance); var cashinCouldBeStarted = CashinAggregate.CouldBeStarted( depositWallet.Balance, depositWallet.Block, enrolledBalance?.Balance ?? 0, enrolledBalance?.Block ?? 0, asset.Accuracy); if (!cashinCouldBeStarted) { return; } _cqrsEngine.SendCommand ( new LockDepositWalletCommand { BlockchainType = _blockchainType, BlockchainAssetId = depositWallet.AssetId, DepositWalletAddress = depositWallet.Address, DepositWalletBalance = depositWallet.Balance, DepositWalletBlock = depositWallet.Block, AssetId = asset.Id, AssetAccuracy = asset.Accuracy, BlockchainAssetAccuracy = GetAssetAccuracy(asset.BlockchainIntegrationLayerAssetId, batchSize), CashinMinimalAmount = (decimal)asset.CashinMinimalAmount, HotWalletAddress = _hotWalletAddress }, BlockchainCashinDetectorBoundedContext.Name, BlockchainCashinDetectorBoundedContext.Name ); }
private async Task SendBagNotification(WalletBalance walletBalance, decimal averagePrice, decimal currentPrice, decimal percentageDrop) { var lastBought = await _databaseService.GetLastBoughtAsync(_generalConfig.TradingCurrency, walletBalance.Currency, Constants.Bittrex); var message = $"<strong>{Constants.Bittrex}</strong>: {DateTime.Now:g}\n" + $"<strong>Bag detected for {walletBalance.Currency}</strong>\n" + $"Average bought price: {averagePrice:#0.#############}\n" + $"Current price: {currentPrice:#0.#############}\n" + $"Percentage: {percentageDrop}%\n" + $"Bought on: {lastBought:g}\n" + $"Value: {walletBalance.Balance * currentPrice:#0.#####} {_generalConfig.TradingCurrency}"; await _bus.SendAsync(new SendMessageCommand(message)); }
private async Task UpdateBalanceInRepo(int lastBlock, string address, decimal balance, string assetId) { if (balance != 0) { _log.Info($"[{lastBlock}] Detected balance on {address}: {balance} {assetId}"); await _walletBalanceRepository.InsertOrReplace( WalletBalance.Create(address, balance: balance, assetId: assetId, updatedAtBlock: lastBlock)); } else { await _walletBalanceRepository.DeleteIfExist(address, assetId); } }
private void aboutToCreateGroups(object sender, CreateGroupsEventArgs e) { //LogManager.AddLogMessage(Name, "aboutToCreateGroups", "view=" + view + " | group.count=" + e.Groups.Count, LogManager.LogMessageType.OTHER); //List<ExchangeBalance> balances = GetBalances(); listView.GroupImageList = ContentManager.WalletIconList; foreach (OLVGroup group in e.Groups) { string key = group.Key.ToString(); WalletBalance wallet = PreferenceManager.WalletPreferences.Wallets.FirstOrDefault(item => item.Name == key); if (!groupStates.ContainsKey(key)) { groupStates.Add(key, false); } List <WalletBalance> wallets = PreferenceManager.WalletPreferences.WalletForks.FindAll(item => item.Name == key); //LogManager.AddLogMessage(Name, "aboutToCreateGroups", "GroupId=" + group.Items.Count + " | Header=" + group.Header + " | id=" + group.Id + " | Key=" + group.Key + " | name=" + group.Name + " | " + group.Collapsed); decimal usdTotal = wallets.Sum(item => item.TotalInUSD); decimal btcTotal = wallets.Sum(item => item.TotalInBTC); group.Header = group.Header + " [" + wallets.Count + " Forks]"; group.TitleImage = wallet.WalletName; /* * if (group.Items.Count > 1) * { * group.Task = "[" + group.Items.Count + "] " + usdTotal.ToString("C"); * } * else * { * group.Task = usdTotal.ToString("C"); * } */ group.Task = usdTotal.ToString("C"); group.Subtitle = "(" + btcTotal.ToString("N8") + ")"; group.Collapsed = groupStates[key]; } }
private async Task SendBagNotification(WalletBalance walletBalance, decimal averagePrice, decimal currentPrice, decimal percentageDrop) { var lastBought = await _databaseService.GetLastBoughtAsync(_generalConfig.TradingCurrency, walletBalance.Currency, Constants.Binance); var sb = new StringBuffer(); sb.Append($"{StringContants.StrongOpen}{Constants.Binance}{StringContants.StrongClose}: {DateTime.Now:g}\n"); sb.Append($"{StringContants.StrongOpen}Bag detected for {walletBalance.Currency}{StringContants.StrongClose}\n"); sb.Append($"Average bought price: {averagePrice:#0.#############}\n"); sb.Append($"Current price: {currentPrice:#0.#############}\n"); sb.Append($"Percentage: {percentageDrop}%\n"); sb.Append($"Bought on: {lastBought:g}\n"); sb.Append($"Value: {walletBalance.Balance * currentPrice:#0.#####} {_generalConfig.TradingCurrency}"); await _bus.SendAsync(new SendMessageCommand(sb)); }
private void VerifyItem_Menu_Click(object sender, EventArgs e) { string data = sender.ToString().Replace("Verify ", ""); if (listView_Wallets.SelectedObject != null) { WalletBalance balance = listView_Wallets.SelectedObject as WalletBalance; //balance.Verified = true; WalletBalance listItem = PreferenceManager.WalletPreferences.WalletForks.FirstOrDefault(item => item.Symbol == balance.Symbol && item.Name == balance.Name); if (listItem != null) { listItem.Verified = true; PreferenceManager.UpdatePreferenceFile(PreferenceManager.PreferenceType.Wallet); LoadWallets(); } } }
private async Task <IWalletBalance> UpdateBitcoinBalance(IObservableWallet wallet, int height, int minConfirmations) { var balance = await _blockChainProvider.GetBalanceSatoshiFromUnspentOutputsAsync(wallet.Address, minConfirmations); if (balance != 0) { var walletBalanceEntity = WalletBalance.Create(wallet.Address, balance, height, Constants.Assets.Bitcoin.AssetId); await _balanceRepository.InsertOrReplaceAsync(walletBalanceEntity); return(walletBalanceEntity); } await _balanceRepository.DeleteIfExistAsync(wallet.Address, Constants.Assets.Bitcoin.AssetId); return(null); }
private void RemoveItem_Menu_Click(object sender, EventArgs e) { string data = sender.ToString().Replace("Remove ", ""); string[] split = data.Split('_'); string name = split[0]; string symbol = split[1]; string address = split[2]; //LogManager.AddLogMessage(Name, "RemoveItem_Menu_Click", "Removing " + symbol + " From Symbol List", LogManager.LogMessageType.DEBUG); WalletBalance wallet = PreferenceManager.WalletPreferences.Wallets.FirstOrDefault(item => item.Name == name && item.Symbol == symbol && item.Address == address); if (wallet != null) { PreferenceManager.WalletPreferences.Wallets.Remove(wallet); PreferenceManager.UpdatePreferenceFile(PreferenceManager.PreferenceType.Wallet); FormManager.UpdateBalanceManager(); UpdateUI(); } }