public static async Task <ArkClientIndexModel> GetClientsToPay(string passPhrase, double percentToPay, long amountToPay) { var returnModel = new ArkClientIndexModel(); var delegateAccount = await GetAccount(passPhrase); if (delegateAccount == null) { throw new Exception(StaticProperties.ARK_ACCOUNT_NOT_FOUND); } var delegateAccountTotalArk = delegateAccount.Balance; if (amountToPay < delegateAccountTotalArk) { delegateAccountTotalArk = amountToPay; } var delegateAccountVoters = await DelegateService.GetVotersAsync(delegateAccount.PublicKey); var feesToPay = ArkNetApi.Instance.NetworkSettings.Fee.Send * delegateAccountVoters.Accounts.Count(); var delegateAccountTotalArkToPay = (percentToPay / 100) * (delegateAccountTotalArk - feesToPay); var delegateAccountTotalArkVote = delegateAccountVoters.Accounts.Sum(x => x.Balance); var clientsToPay = new List <ArkClientModel>(); foreach (var voter in delegateAccountVoters.Accounts) { var voterAccount = await AccountService.GetByAddressAsync(voter.Address); var amountToPayVoter = (voterAccount.Account.Balance / (double)delegateAccountTotalArkVote) * (delegateAccountTotalArkToPay); clientsToPay.Add(new ArkClientModel(voter.Address, amountToPayVoter, voterAccount.Account.Balance)); } returnModel.ArkDelegateAccount = delegateAccount; returnModel.ArkClients = clientsToPay; return(returnModel); }
public static ArkClientIndexModel GetClientsToPay(string passPhrase, double percentToPay, long amountToPay) { var returnModel = new ArkClientIndexModel(); var delegateAccount = GetAccount(passPhrase); if (delegateAccount.Address == StaticProperties.ARK_ACCOUNT_NOT_FOUND) { throw new Exception(StaticProperties.ARK_ACCOUNT_NOT_FOUND); } var delegateAccountTotalArk = Convert.ToInt64(delegateAccount.Balance); if (Convert.ToInt64(amountToPay) < delegateAccountTotalArk) { delegateAccountTotalArk = amountToPay; } var delegateAccountVoters = DelegateService.GetVoters(delegateAccount.PublicKey); var feesToPay = ArkNetApi.Instance.NetworkSettings.Fee.Send * delegateAccountVoters.Count(); var delegateAccountTotalArkToPay = (percentToPay / 100) * (delegateAccountTotalArk - feesToPay); var delegateAccountTotalArkVote = delegateAccountVoters.Sum(x => Convert.ToInt64(x.Balance)); var clientsToPay = new List <ArkClientModel>(); foreach (var voter in delegateAccountVoters) { var voterAccount = AccountService.GetByAddress(voter.Address); var amountToPayVoter = (Convert.ToInt64(voterAccount.Balance) / (double)delegateAccountTotalArkVote) * (delegateAccountTotalArkToPay); clientsToPay.Add(new ArkClientModel(voter.Address, amountToPayVoter, Convert.ToInt64(voterAccount.Balance))); } returnModel.ArkDelegateAccount = delegateAccount; returnModel.ArkClients = clientsToPay; return(returnModel); }