Exemple #1
0
        public async Task <ProfitInfo> CreateProfitingAccountAsync(string accountId, string Name, ProfitingType ptype, decimal shareRito, int maxVoter)
        {
            var klWallet = CreateWallet(accountId);

            var result = await klWallet.CreateProfitingAccountAsync(Name, ptype, shareRito, maxVoter);

            if (result.ResultCode == APIResultCodes.Success)
            {
                var pgen    = result.GetBlock() as ProfitingGenesis;
                var pftinfo = new ProfitInfo
                {
                    owner      = pgen.OwnerAccountId,
                    pftid      = pgen.AccountID,
                    seats      = pgen.Seats,
                    shareratio = pgen.ShareRito,
                    name       = pgen.Name,
                    type       = pgen.PType.ToString()
                };

                return(pftinfo);
            }
            else
            {
                throw new Exception($"{result.ResultCode}: {result.ResultMessage}");
            }
        }
        public void UpdateView()
        {
            try
            {
                int      TimetoWait = 30;
                TimeSpan time       = DateTime.Now - lastTime;
                if (time.TotalSeconds < TimetoWait)
                {
                    return;
                }
                IMiner miner = Factory.Instance.CoreObject.SelectedMiner;
                ShowWarning(miner.HashRate);
                ProfitInfo profits = ((MinerBase)miner).Profit;
                if (profits != null)
                {
                    lblWarning.Visible = false;
                    //lblHeading.Text = "Profitability(" + miner.HashRate + ")";
                    lblDolDaily.Text = profits.revenue;
                    lblDigDaily.Text = profits.estimated_rewards;

                    float dailyDol = float.Parse(profits.revenue.Substring(1));
                    float dailyDig = float.Parse(profits.estimated_rewards);

                    lblDolWeekly.Text = "$" + (dailyDol * 7).ToString("F2");
                    lblDolMonth.Text  = "$" + (dailyDol * 30).ToString("F2");
                    lblDolYear.Text   = "$" + (dailyDol * 365).ToString("F2");

                    lblDgbWeekly.Text  = (dailyDig * 7).ToString("F2");
                    lblDgbMonthly.Text = (dailyDig * 30).ToString("F2");
                    lblDgbYear.Text    = (dailyDig * 365).ToString("F2");
                }
                lastTime = DateTime.Now;
            }
            catch (Exception e)
            {
            }
        }
Exemple #3
0
        public async Task <BrokerAccountsInfo> GetBrokerAccountsAsync(string accountId)
        {
            var result = await _node.GetAllBrokerAccountsForOwnerAsync(accountId);

            if (result.ResultCode == APIResultCodes.Success)
            {
                BrokerAccountsInfo accts = new BrokerAccountsInfo();
                accts.owner    = accountId;
                accts.profits  = new List <ProfitInfo>();
                accts.stakings = new List <StakingInfo>();

                var blks = result.GetBlocks();
                foreach (var blk in blks)
                {
                    if (blk is IProfiting pft)
                    {
                        var pftinfo = new ProfitInfo
                        {
                            owner      = pft.OwnerAccountId,
                            pftid      = (blk as TransactionBlock).AccountID,
                            seats      = pft.Seats,
                            shareratio = pft.ShareRito,
                            name       = pft.Name,
                            type       = pft.PType.ToString()
                        };
                        accts.profits.Add(pftinfo);
                    }

                    if (blk is IStaking stk)
                    {
                        decimal amt        = 0;
                        var     lastblkret = await _node.GetLastBlockAsync((stk as TransactionBlock).AccountID);

                        TransactionBlock lastblk = null;
                        if (lastblkret.Successful())
                        {
                            lastblk = lastblkret.GetBlock() as TransactionBlock;
                            if (lastblk.Balances.ContainsKey(LyraGlobal.OFFICIALTICKERCODE))
                            {
                                amt = lastblk.Balances[LyraGlobal.OFFICIALTICKERCODE].ToBalanceDecimal();
                            }
                        }

                        var laststk = lastblk as IStaking;
                        var stkinfo = new StakingInfo
                        {
                            owner = stk.OwnerAccountId,
                            stkid = (stk as TransactionBlock).AccountID,
                            name  = stk.Name,

                            start    = laststk.Start,
                            amount   = amt,
                            days     = laststk.Days,
                            voting   = laststk.Voting,
                            compound = laststk.CompoundMode
                        };

                        accts.stakings.Add(stkinfo);
                    }
                }
                return(accts);
            }
            else
            {
                throw new Exception($"{result.ResultCode}: {result.ResultMessage}");
            }
        }