Ejemplo n.º 1
0
        public async Task <IActionResult> Dex([FromServices] KyubeyContext db, [FromServices] ITokenRepository _tokenRepository, string token = null, CancellationToken cancellationToken = default)
        {
            var tokenStaticInfoList = _tokenRepository.GetAll();

            if (token != null)
            {
                token = token.ToUpper();
            }
            ViewBag.SearchToken = token;
            var ret    = new List <TokenDisplay>();
            var tokens = await DB.Tokens.ToListAsync(cancellationToken);

            foreach (var x in tokens)
            {
                if (!x.HasDex && !x.HasContractExchange)
                {
                    continue;
                }

                var t = new TokenDisplay
                {
                    Id                 = x.Id,
                    Name               = x.Name,
                    Protocol           = x.CurveId ?? SR["Unknown"],
                    ExchangeInDex      = x.HasDex,
                    ExchangeInContract = x.HasContractExchange
                };

                ret.Add(t);
            }

            return(View(ret));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Dex([FromServices] KyubeyContext db,
                                              [FromServices] ITokenRepository _tokenRepository, string token = null,
                                              CancellationToken cancellationToken = default)
        {
            var tokenStaticInfoList = _tokenRepository.GetAll();

            if (token != null)
            {
                token = token.ToUpper();
            }

            ViewBag.SearchToken = token;
            var ret    = new List <TokenDisplay>();
            var tokens = await DB.Tokens.Where(x => token == null || x.Id.Contains(token) || x.Name.Contains(token))
                         .ToListAsync(cancellationToken);

            var notStartedTokens = tokenStaticInfoList
                                   .Where(x => (x?.Incubation?.Begin_Time).HasValue && x?.Incubation?.Begin_Time > DateTime.Now)
                                   .Select(x => x.Id).ToList();

            foreach (var x in tokens.Where(t => !notStartedTokens.Contains(t.Id)))
            {
                if (!x.HasDex && !x.HasContractExchange)
                {
                    continue;
                }

                var t = new TokenDisplay
                {
                    Id                 = x.Id,
                    Name               = x.Name,
                    Protocol           = x.CurveId ?? SR["Unknown"],
                    ExchangeInDex      = x.HasDex,
                    ExchangeInContract = x.HasContractExchange
                };

                ret.Add(t);
            }

            return(View(ret));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Index([FromServices] KyubeyContext db, string token = null, CancellationToken cancellationToken = default)
        {
            if (token != null)
            {
                token = token.ToUpper();
            }
            ViewBag.SearchToken = token;
            IEnumerable <Bancor> bancors = db.Bancors.Include(x => x.Token);

            if (!string.IsNullOrEmpty(token))
            {
                bancors = bancors.Where(x => x.Id.Contains(token) || x.Token.Name.Contains(token));
            }
            bancors = bancors
                      .Where(x => x.Status == Status.Active)
                      .OrderByDescending(x => x.Token.Priority)
                      .ToList();

            IEnumerable <Otc> otcs = db.Otcs.Include(x => x.Token);

            if (!string.IsNullOrEmpty(token))
            {
                otcs = otcs.Where(x => x.Id.Contains(token) || x.Token.Name.Contains(token));
            }
            otcs = otcs
                   .Where(x => x.Status == Status.Active)
                   .OrderByDescending(x => x.Token.Priority)
                   .ToList();

            var ret    = new List <TokenDisplay>();
            var tokens = await DB.Tokens.ToListAsync(cancellationToken);

            foreach (var x in tokens)
            {
                if (!bancors.Any(y => y.Id == x.Id) && !otcs.Any(y => y.Id == x.Id))
                {
                    continue;
                }

                var t = new TokenDisplay
                {
                    Id                 = x.Id,
                    Name               = x.Name,
                    Protocol           = x.CurveId ?? SR["Unknown"],
                    ExchangeInDex      = otcs.Any(y => y.Id == x.Id),
                    ExchangeInContract = bancors.Any(y => y.Id == x.Id)
                };

                if (t.ExchangeInDex)
                {
                    t.Change = otcs.Single(y => y.Id == x.Id).Change;
                    t.Price  = otcs.Single(y => y.Id == x.Id).Price;
                }
                else
                {
                    t.Change = bancors.Single(y => y.Id == x.Id).Change;
                    t.Price  = bancors.Single(y => y.Id == x.Id).BuyPrice;
                }

                ret.Add(t);
            }

            return(View(ret));
        }